fix some misspell

This commit is contained in:
JunDao
2019-05-19 11:55:58 +08:00
parent 637d5e35a3
commit e088636fbc
3 changed files with 8 additions and 5 deletions

View File

@ -12,8 +12,8 @@ import (
pk "github.com/Tnze/go-mc/net/packet" pk "github.com/Tnze/go-mc/net/packet"
) )
// ProtocalVersion , the protocal version number of minecraft net protocal // ProtocolVersion , the protocol version number of minecraft net protocol
const ProtocalVersion = 480 const ProtocolVersion = 480
// PingAndList chack server status and list online player. // PingAndList chack server status and list online player.
// Returns a JSON data with server status, and the delay. // Returns a JSON data with server status, and the delay.
@ -30,7 +30,7 @@ func PingAndList(addr string, port int) ([]byte, time.Duration, error) {
//Handshake Packet //Handshake Packet
pk.Marshal( pk.Marshal(
0x00, //Handshake packet ID 0x00, //Handshake packet ID
pk.VarInt(ProtocalVersion), //Protocal version pk.VarInt(ProtocolVersion), //Protocol version
pk.String(addr), //Server's address pk.String(addr), //Server's address
pk.UnsignedShort(port), pk.UnsignedShort(port),
pk.Byte(1), pk.Byte(1),
@ -94,7 +94,7 @@ func (c *Client) JoinServer(addr string, port int) (err error) {
//Handshake Packet //Handshake Packet
pk.Marshal( pk.Marshal(
0x00, //Handshake packet ID 0x00, //Handshake packet ID
pk.VarInt(ProtocalVersion), //Protocal version pk.VarInt(ProtocolVersion), //Protocol version
pk.String(addr), //Server's address pk.String(addr), //Server's address
pk.UnsignedShort(port), pk.UnsignedShort(port),
pk.Byte(2), pk.Byte(2),

View File

@ -303,7 +303,7 @@ func (d *Decoder) readTag() (tagType byte, tagName string, err error) {
func (d *Decoder) readNByte(n int) (buf []byte, err error) { func (d *Decoder) readNByte(n int) (buf []byte, err error) {
buf = make([]byte, n) buf = make([]byte, n)
_, err = d.r.Read(buf) //what happend if (returned n) != (argument n) ? _, err = d.r.Read(buf) //what happened if (returned n) != (argument n) ?
return return
} }

View File

@ -6,15 +6,18 @@ import (
"math" "math"
) )
// A Field is both FieldEncoder and FieldDecoder
type Field interface { type Field interface {
FieldEncoder FieldEncoder
FieldDecoder FieldDecoder
} }
// A FieldEncoder can be encode as minecraft protocal used.
type FieldEncoder interface { type FieldEncoder interface {
Encode() []byte Encode() []byte
} }
// A FieldDecoder can Decode from minecraft protocal
type FieldDecoder interface { type FieldDecoder interface {
Decode(r DecodeReader) error Decode(r DecodeReader) error
} }