Go (golang) library for Minecraft utilities.
The only functionality currently implemented is a query client compatible with the vanilla Minecraft query protocol.
Planned packages:
query/query- rcon
Note: This package is being developed for use within the spencersharkey/mcapi application, aimed at exposing an HTTP client for various Minecraft-related utilities.
type SimpleResponse struct {
Hostname string `json:"hostname"`
GameType string `json:"gametype"`
Map string `json:"map"`
NumPlayers int `json:"numplayers"`
MaxPlayers int `json:"maxplayers"`
HostPort int16 `json:"hostport"`
HostIP string `json:"hostip"`
}
Simple request example:
req := query.NewRequest()
err := req.Connect("127.0.0.1:25565")
res, err := req.Simple()
{
"hostname": "Revive Minecraft! http://revive.gg/chat",
"gametype": "SMP",
"map": "world",
"numplayers": 4,
"maxplayers": 128,
"hostport": 25565,
"hostip": "127.0.0.1"
}
Note: FullResponse
embeds the SimpleResponse
struct
type FullResponse struct {
SimpleResponse
Info map[string]string `json:"info"`
Players []string `json:"players"`
}
Full request example:
req := query.NewRequest()
err := req.Connect("127.0.0.1:25565")
res, err := req.Full()
{
"hostname": "Revive Minecraft! http://revive.gg/chat",
"gametype": "SMP",
"map": "world",
"numplayers": 4,
"maxplayers": 128,
"hostport": 25565,
"hostip": "127.0.0.1",
"info": {
"game_id": "MINECRAFT",
"plugins": "",
"version": "1.12.2"
},
"players": [
"SpencerSharkey",
"RumBull",
"lonemajestyk",
"nakkirakki"
]
}