Documentation ¶
Overview ¶
Package bot implements a simple Minecraft client that can join a server or just ping it for getting information.
Runnable example could be found at examples/ .
Index ¶
- Constants
- func PingAndList(addr string) ([]byte, time.Duration, error)
- func PingAndListTimeout(addr string, timeout time.Duration) ([]byte, time.Duration, error)
- type Auth
- type Client
- type DisconnectErr
- type Events
- type LoginErr
- type PacketHandler
- type PacketHandlerError
- type PacketHandlerFunc
- type Position
Examples ¶
Constants ¶
const DefaultPort = 25565
const ProtocolVersion = 754
ProtocolVersion , the protocol version number of minecraft net protocol
Variables ¶
This section is empty.
Functions ¶
func PingAndList ¶
PingAndList check server status and list online player. Returns a JSON data with server status, and the delay.
For more information for JSON format, see https://wiki.vg/Server_List_Ping#Response
Example ¶
Output:
Types ¶
type Client ¶
Client is used to access Minecraft server
func NewClient ¶
func NewClient() *Client
NewClient init and return a new Client.
A new Client has default name "Steve" and zero UUID. It is usable for an offline-mode game.
For online-mode, you need login your Mojang account and load your Name, UUID and AccessToken to client.
func (*Client) HandleGame ¶
HandleGame receive server packet and response them correctly. Note that HandleGame will block if you don't receive from Events.
func (*Client) JoinServer ¶
JoinServer connect a Minecraft server for playing the game. Using roughly the same way to parse address as minecraft.
Example (Offline) ¶
Output:
Example (Online) ¶
Output:
type DisconnectErr ¶
func (DisconnectErr) Error ¶
func (d DisconnectErr) Error() string
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
func (*Events) AddGeneric ¶
func (e *Events) AddGeneric(listeners ...PacketHandler)
AddGeneric adds listeners like AddListener, but the packet ID is ignored. Generic listener is always called before specific packet listener.
func (*Events) AddListener ¶
func (e *Events) AddListener(listeners ...PacketHandler)
type PacketHandlerError ¶
func (PacketHandlerError) Error ¶
func (d PacketHandlerError) Error() string
func (PacketHandlerError) Unwrap ¶
func (d PacketHandlerError) Unwrap() error