diff --git a/README.md b/README.md index 5fd5e88..22ca936 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Go-MC ![](https://img.shields.io/badge/Minecraft-1.14.4-blue.svg) -![](https://img.shields.io/badge/Protocol-497-blue.svg) +![](https://img.shields.io/badge/Protocol-498-blue.svg) [![GoDoc](https://godoc.org/github.com/Tnze/go-mc?status.svg)](https://godoc.org/github.com/Tnze/go-mc) [![Go Report Card](https://goreportcard.com/badge/github.com/Tnze/go-mc)](https://goreportcard.com/report/github.com/Tnze/go-mc) [![Build Status](https://travis-ci.org/Tnze/go-mc.svg?branch=master)](https://travis-ci.org/Tnze/go-mc) diff --git a/bot/ingame.go b/bot/ingame.go index 11ae4df..6541852 100644 --- a/bot/ingame.go +++ b/bot/ingame.go @@ -24,8 +24,8 @@ import ( // return int(math.Floor(p.X)), int(math.Floor(p.Y)), int(math.Floor(p.Z)) // } -// HandleGame recive server packet and response them correctly. -// Note that HandleGame will block if you don't recive from Events. +// HandleGame receive server packet and response them correctly. +// Note that HandleGame will block if you don't receive from Events. func (c *Client) HandleGame() error { for { select { @@ -212,7 +212,7 @@ func handleSetSlotPacket(c *Client, p pk.Packet) error { } // func handleMultiBlockChangePacket(c *Client, p pk.Packet) error { -// if !c.settings.ReciveMap { +// if !c.settings.ReceiveMap { // return nil // } @@ -253,7 +253,7 @@ func handleSetSlotPacket(c *Client, p pk.Packet) error { // } // func handleBlockChangePacket(c *Client, p pk.Packet) error { -// if !c.settings.ReciveMap { +// if !c.settings.ReceiveMap { // return nil // } // var pos pk.Position @@ -435,7 +435,7 @@ func handleHeldItemPacket(c *Client, p pk.Packet) error { } func handleChunkDataPacket(c *Client, p pk.Packet) error { - if !c.settings.ReciveMap { + if !c.settings.ReceiveMap { return nil } var ( diff --git a/bot/mcbot.go b/bot/mcbot.go index 4a01789..a5c9c19 100644 --- a/bot/mcbot.go +++ b/bot/mcbot.go @@ -13,7 +13,7 @@ import ( ) // ProtocolVersion , the protocol version number of minecraft net protocol -const ProtocolVersion = 497 +const ProtocolVersion = 498 // PingAndList check server status and list online player. // Returns a JSON data with server status, and the delay. diff --git a/bot/settings.go b/bot/settings.go index 91cb4d7..66b71a2 100644 --- a/bot/settings.go +++ b/bot/settings.go @@ -8,7 +8,7 @@ type Settings struct { ChatColors bool //聊天颜色 DisplayedSkinParts uint8 //皮肤显示 MainHand int //主手 - ReciveMap bool //接收地图数据 + ReceiveMap bool //接收地图数据 } /* @@ -32,5 +32,5 @@ var DefaultSettings = Settings{ ChatMode: 0, DisplayedSkinParts: Jacket | LeftSleeve | RightSleeve | LeftPantsLeg | RightPantsLeg | Hat, MainHand: 1, - ReciveMap: true, + ReceiveMap: true, } diff --git a/cmd/daze/daze.go b/cmd/daze/daze.go index da23faa..c2e1fa7 100644 --- a/cmd/daze/daze.go +++ b/cmd/daze/daze.go @@ -1,10 +1,12 @@ package main import ( + "bytes" "log" "github.com/Tnze/go-mc/bot" "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" // "github.com/Tnze/go-mc/authenticate" ) @@ -26,7 +28,7 @@ func main() { } log.Println("Login success") - //Regist event handlers + //Register event handlers c.Events.GameStart = onGameStart c.Events.ChatMsg = onChatMsg c.Events.Disconnect = onDisconnect @@ -55,6 +57,16 @@ func onDisconnect(c chat.Message) error { } func onPluginMessage(channel string, data []byte) error { - log.Println("PluginMessage", channel, data) + switch channel { + case "minecraft:brand": + var brand pk.String + if err := brand.Decode(bytes.NewReader(data)); err != nil { + return err + } + log.Println("Server brand is:", brand) + + default: + log.Println("PluginMessage", channel, data) + } return nil }