-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstatus.go
40 lines (34 loc) · 1.12 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mcpinger
import (
"encoding/json"
)
// Server info version
type Version struct {
Name string `json:"name"` // Version name
Protocol int32 `json:"protocol"` // Version protocol number
}
// Server info player
type Player struct {
Name string `json:"name"` // Player name
ID string `json:"id"` // Player UUID
}
// Server info players
type Players struct {
Max int32 `json:"max"` // Max amount of players allowed
Online int32 `json:"online"` // Amount of players online
Sample []Player // Sample of online players
}
// Server ping response
// https://wiki.vg/Server_List_Ping#Response
type ServerInfo struct {
Version Version `json:"version"` // Server version info
Players Players `json:"players"` // Server player info
Description ChatComponent `json:"description"` // Server description
Favicon string `json:"favicon"` // Server favicon
}
// Parses the provided json byte array into a ServerInfo struct
func parseServerInfo(infoJson []byte) (*ServerInfo, error) {
info := new(ServerInfo)
err := json.Unmarshal(infoJson, info)
return info, err
}