package client import ( "time" "git.0cd.xyz/michael/mcstatus/mcstatuspb" ) // GetStatus gets minecraft server status func (client *Client) GetStatus() (*mcstatuspb.Response, error) { if err := client.write(); err != nil { return nil, err } resp, err := client.read() if err != nil { return nil, err } return resp, nil } // PingServer pings Minecraft server func (client *Client) PingServer() (time.Duration, error) { ping := make([]byte, 1) start := time.Now() if _, err := client.Conn.Write([]byte{0x01, 0x00}); err != nil { return 0, err } client.Conn.Read(ping[:]) diff := time.Since(start) return diff, nil }