mcproto

package
Version: v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2015 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandShakeID uint64 = 0
)

Variables

This section is empty.

Functions

func IsOldClient

func IsOldClient(err error) (old bool)

func ReadMCByteString

func ReadMCByteString(buff []byte) (bstr []byte, length int, err error)

func ReadMCString

func ReadMCString(buff []byte) (str string, length int, err error)

func WriteMCByteString

func WriteMCByteString(bstr []byte) (payload []byte)

func WriteMCString

func WriteMCString(str string) (payload []byte)

Types

type Icon

type Icon string

func (Icon) ToBinaryImage

func (icon Icon) ToBinaryImage() (img []byte, err error)

type MCHandShake

type MCHandShake struct {
	// ID is always 0x00
	Proto      uint64
	ServerAddr string
	ServerPort uint16
	NextState  uint64
}

func (*MCHandShake) ToRawPacket

func (handshake *MCHandShake) ToRawPacket() (pkt *RAWPacket, err error)

type MCKick

type MCKick mcchat.ChatMsg

func (*MCKick) ToRawPacket

func (kick *MCKick) ToRawPacket() (pkt *RAWPacket, err error)

type MCLogin

type MCLogin struct {
	Name string
}

func (*MCLogin) ToRawPacket

func (login *MCLogin) ToRawPacket() (pkt *RAWPacket, err error)

type MCPacket

type MCPacket interface {
	ToRawPacket() (*RAWPacket, error)
}

type MCSimpleStatusResponse

type MCSimpleStatusResponse struct {
	// ID is always 0x00
	Version struct {
		Name     string `json:"name"`
		Protocol int    `json:"protocol"`
	} `json:"version"`
	Players struct {
		Max    int `json:"max"`
		Online int `json:"online"`
	} `json:"players"`
	Description string `json:"description"`
	Favicon     Icon   `json:"favicon,omitempty"`
}

type MCStatusResponse

type MCStatusResponse struct {
	// ID is always 0x00
	Version struct {
		Name     string `json:"name"`
		Protocol int    `json:"protocol"`
	} `json:"version"`
	Players struct {
		Max    int `json:"max"`
		Online int `json:"online"`
	} `json:"players"`
	Description *mcchat.ChatMsg `json:"description"`
	Favicon     Icon            `json:"favicon,omitempty"`
}

func (*MCStatusResponse) ToRawPacket

func (resp *MCStatusResponse) ToRawPacket() (pkt *RAWPacket, err error)

type OldClient

type OldClient byte

func (OldClient) Error

func (err OldClient) Error() string

type RAWPacket

type RAWPacket struct {
	ID      uint64
	Payload []byte
}

func ReadInitialPacket

func ReadInitialPacket(r SocketReader) (packet *RAWPacket, err error)

func ReadPacket

func ReadPacket(r SocketReader) (packet *RAWPacket, err error)

func (*RAWPacket) IsStatusPing

func (pkt *RAWPacket) IsStatusPing() (status_ping bool)

func (*RAWPacket) IsStatusRequest

func (pkt *RAWPacket) IsStatusRequest() (status_req bool)

func (*RAWPacket) ToBytes

func (pkt *RAWPacket) ToBytes() (packet []byte)

func (*RAWPacket) ToHandShake

func (pkt *RAWPacket) ToHandShake() (handshake *MCHandShake, err error)

func (*RAWPacket) ToKick

func (pkt *RAWPacket) ToKick() (kick *MCKick, err error)

func (*RAWPacket) ToLogin

func (pkt *RAWPacket) ToLogin() (login *MCLogin, err error)

func (*RAWPacket) ToStatusResponse

func (pkt *RAWPacket) ToStatusResponse() (resp *MCStatusResponse, err error)

type SocketReader

type SocketReader interface {
	io.Reader
	io.ByteScanner
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL