2023-08-13 20:19:47 +01:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
2023-08-13 23:01:29 +01:00
|
|
|
"time"
|
2023-08-13 20:19:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type MC struct {
|
2023-08-13 23:01:29 +01:00
|
|
|
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)
|
|
|
|
}
|
2023-08-14 19:01:00 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|