modulepackage
1.0.0
Repository: https://github.com/zeroerrors/go-bedrockping.git
Documentation: pkg.go.dev
# README
go-bedrockping

A simple Go library to ping Minecraft Bedrock/MCPE servers.
Usage
Installation
Install using go get github.com/ZeroErrors/go-bedrockping
Example Usage
package main
import (
"fmt"
"github.com/ZeroErrors/go-bedrockping"
"log"
"time"
)
func main() {
resp, err := bedrockping.Query("myip:19132", 5 * time.Second, 150 * time.Millisecond)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d/%d players are online.", resp.PlayerCount, resp.MaxPlayers)
}
(The default port, 19132, is also available as a const, bedrockping.DefaultPort
.)
Response
The response structure is described in bedrockping.Response
# Functions
Query makes a query to the specified address via the Minecraft Bedrock protocol, if successful it returns a Response containing data from the pong packet.
ReadUnconnectedPong reads the 'Unconnected Pong (0x1C)' packet from a connection into a Response struct.
ReadUTFString reads a UTF-8 string with a uint16 length header.
WriteUnconnectedPing writes the 'Unconnected Ping (0x01)' packet to a writer.
WriteUnconnectedPingPacket writes the 'Unconnected Ping (0x01)' as a single packet to a connection.
# Constants
DefaultPort is the default Minecraft Bedrock/MCPE server port.