mc-webserver/pageHandler/pages/index/mc.go

51 lines
1.1 KiB
Go
Raw Normal View History

2023-08-13 20:19:47 +01:00
package index
import (
"html/template"
"time"
2023-08-13 20:19:47 +01:00
)
type MC struct {
Timestamp time.Time
2023-08-13 20:19:47 +01:00
Version *string
ProtocolVersion *int64
Address string
Port uint16
Port6 *uint16
PlayerCount *int64
MaxPlayers *int64
Players []string
MOTD string
ActualHost *string
ActualPort *uint16
2023-08-14 17:36:14 +01:00
Favicon *string
2023-08-13 20:19:47 +01:00
Edition *string
ModCount int64
Mods []string
SecureProfilesEnforced *bool
PreviewChatEnforced *bool
}
2023-08-14 17:36:14 +01:00
func (m MC) GetFaviconSRC() template.HTMLAttr {
toReturn := "src=\""
if m.Favicon != nil {
toReturn += *m.Favicon
}
toReturn += "\""
return template.HTMLAttr(toReturn)
}
func (m MC) GetTimestamp() string {
return m.Timestamp.Format(time.RFC822)
}
func (m MC) GetPlayers(aap bool) []string {
toReturn := make([]string, 0)
for _, cpl := range m.Players {
if aap || cpl != "Anonymous Player" {
toReturn = append(toReturn, cpl)
}
}
return toReturn
}