protocol

package module
v0.0.0-...-47e95e7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: MIT Imports: 4 Imported by: 0

README

JungleMC/java-protocol

Minecraft: Java Edition packet codec library.

The branch name indicates protocol version.

Documentation

Index

Constants

View Source
const (
	ClientToServer = false
	ServerToClient = true
)
View Source
const LegacyPingPayload = 0xFE
View Source
const Version = 756
View Source
const VersionDescription = "1.17.1"

Variables

This section is empty.

Functions

func ReadBool

func ReadBool(buf *bufio.Reader) bool

func ReadByteSlice

func ReadByteSlice(buf *bufio.Reader) []byte

func ReadFloat32

func ReadFloat32(buf *bufio.Reader) float32

func ReadFloat64

func ReadFloat64(buf *bufio.Reader) float64

func ReadInt16

func ReadInt16(buf *bufio.Reader) int16

func ReadInt32

func ReadInt32(buf *bufio.Reader) int32

func ReadInt64

func ReadInt64(buf *bufio.Reader) int64

func ReadInt8

func ReadInt8(buf *bufio.Reader) int8

func ReadString

func ReadString(buf *bufio.Reader) string

func ReadUUID

func ReadUUID(buf *bufio.Reader) uuid.UUID

func ReadUint16

func ReadUint16(buf *bufio.Reader) uint16

func ReadUint32

func ReadUint32(buf *bufio.Reader) uint32

func ReadUint64

func ReadUint64(buf *bufio.Reader) uint64

func ReadUint8

func ReadUint8(buf *bufio.Reader) uint8

func ReadVarInt32

func ReadVarInt32(buf *bufio.Reader) int32

func ReadVarInt64

func ReadVarInt64(buf *bufio.Reader) int64

func WriteBool

func WriteBool(v bool) []byte

func WriteByteSlice

func WriteByteSlice(v []byte) []byte

func WriteFloat32

func WriteFloat32(v float32) []byte

func WriteFloat64

func WriteFloat64(v float64) []byte

func WriteInt16

func WriteInt16(v int16) []byte

func WriteInt32

func WriteInt32(v int32) []byte

func WriteInt64

func WriteInt64(v int64) []byte

func WriteInt8

func WriteInt8(v int8) []byte

func WriteString

func WriteString(v string) []byte

func WriteUUID

func WriteUUID(v uuid.UUID) []byte

func WriteUint16

func WriteUint16(v uint16) []byte

func WriteUint32

func WriteUint32(v uint32) []byte

func WriteUint64

func WriteUint64(v uint64) []byte

func WriteUint8

func WriteUint8(v uint8) []byte

func WriteVarInt32

func WriteVarInt32(v int32) []byte

func WriteVarInt64

func WriteVarInt64(v int64) []byte

Types

type ConnectionState

type ConnectionState int
const (
	Handshake ConnectionState = iota
	Status
	Login
	Play
)

func (ConnectionState) String

func (p ConnectionState) String() string

type Direction

type Direction bool

func (Direction) String

func (d Direction) String() string

type Disconnect

type Disconnect struct {
	Reason string // TODO: chat message json
}

func (*Disconnect) Decode

func (p *Disconnect) Decode(buf *bufio.Reader)

func (*Disconnect) Encode

func (p *Disconnect) Encode() []byte

func (*Disconnect) Id

func (p *Disconnect) Id() int32

type EncryptionRequest

type EncryptionRequest struct {
	ServerId    string
	PublicKey   []byte
	VerifyToken []byte
}

func (*EncryptionRequest) Decode

func (p *EncryptionRequest) Decode(buf *bufio.Reader)

func (*EncryptionRequest) Encode

func (p *EncryptionRequest) Encode() []byte

func (*EncryptionRequest) Id

func (p *EncryptionRequest) Id() int32

type EncryptionResponse

type EncryptionResponse struct {
	SharedSecret []byte
	VerifyToken  []byte
}

func (*EncryptionResponse) Decode

func (p *EncryptionResponse) Decode(buf *bufio.Reader)

func (*EncryptionResponse) Encode

func (p *EncryptionResponse) Encode() []byte

func (*EncryptionResponse) Id

func (p *EncryptionResponse) Id() int32

type HandshakePacket

type HandshakePacket struct {
	ProtocolVersion int32
	ServerHost      string
	ServerPort      uint16
	NextState       int32
}

func (*HandshakePacket) Decode

func (p *HandshakePacket) Decode(buf *bufio.Reader)

func (*HandshakePacket) Encode

func (p *HandshakePacket) Encode() []byte

func (*HandshakePacket) Id

func (p *HandshakePacket) Id() int32

type LegacyPingPacket

type LegacyPingPacket struct {
	Payload         byte
	ProtocolVersion byte
	PluginMessage   byte
	Hostname        string
	Port            int32
}

func (*LegacyPingPacket) Decode

func (p *LegacyPingPacket) Decode(buf *bufio.Reader)

func (*LegacyPingPacket) Encode

func (p *LegacyPingPacket) Encode() []byte

func (*LegacyPingPacket) Id

func (p *LegacyPingPacket) Id() int32

type LoginPluginRequest

type LoginPluginRequest struct {
	MessageId int32
	Channel   string
	Data      []byte
}

func (*LoginPluginRequest) Decode

func (p *LoginPluginRequest) Decode(buf *bufio.Reader)

func (*LoginPluginRequest) Encode

func (p *LoginPluginRequest) Encode() []byte

func (*LoginPluginRequest) Id

func (p *LoginPluginRequest) Id() int32

type LoginPluginResponse

type LoginPluginResponse struct {
	MessageID  int32
	Successful bool
	Data       []byte
}

func (*LoginPluginResponse) Decode

func (p *LoginPluginResponse) Decode(buf *bufio.Reader)

func (*LoginPluginResponse) Encode

func (p *LoginPluginResponse) Encode() []byte

func (*LoginPluginResponse) Id

func (p *LoginPluginResponse) Id() int32

type LoginStart

type LoginStart struct {
	Username string
}

func (*LoginStart) Decode

func (p *LoginStart) Decode(buf *bufio.Reader)

func (*LoginStart) Encode

func (p *LoginStart) Encode() []byte

func (*LoginStart) Id

func (p *LoginStart) Id() int32

type LoginSuccess

type LoginSuccess struct {
	UUID     uuid.UUID
	Username string
}

func (*LoginSuccess) Decode

func (p *LoginSuccess) Decode(buf *bufio.Reader)

func (*LoginSuccess) Encode

func (p *LoginSuccess) Encode() []byte

func (*LoginSuccess) Id

func (p *LoginSuccess) Id() int32

type Packet

type Packet interface {
	Id() int32
	Encode() []byte
	Decode(buffer *bufio.Reader)
}

func NewPacket

func NewPacket(state ConnectionState, direction Direction, id int32) Packet

type SetCompression

type SetCompression struct {
	Threshold int32
}

func (*SetCompression) Decode

func (p *SetCompression) Decode(buf *bufio.Reader)

func (*SetCompression) Encode

func (p *SetCompression) Encode() []byte

func (*SetCompression) Id

func (p *SetCompression) Id() int32

type StatusPing

type StatusPing struct {
	Time int64
}

func (*StatusPing) Decode

func (p *StatusPing) Decode(buf *bufio.Reader)

func (*StatusPing) Encode

func (p *StatusPing) Encode() []byte

func (*StatusPing) Id

func (p *StatusPing) Id() int32

type StatusPong

type StatusPong struct {
	Time int64
}

func (*StatusPong) Decode

func (p *StatusPong) Decode(buf *bufio.Reader)

func (*StatusPong) Encode

func (p *StatusPong) Encode() []byte

func (*StatusPong) Id

func (p *StatusPong) Id() int32

type StatusRequest

type StatusRequest struct{}

func (*StatusRequest) Decode

func (p *StatusRequest) Decode(_ *bufio.Reader)

func (*StatusRequest) Encode

func (p *StatusRequest) Encode() []byte

func (*StatusRequest) Id

func (p *StatusRequest) Id() int32

type StatusResponse

type StatusResponse struct {
	Response string
}

func (*StatusResponse) Decode

func (p *StatusResponse) Decode(buf *bufio.Reader)

func (*StatusResponse) Encode

func (p *StatusResponse) Encode() []byte

func (*StatusResponse) Id

func (p *StatusResponse) Id() int32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL