proto

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Unknown          = &Version{-1, "Unknown"}
	Legacy           = &Version{-2, "Legacy"}
	Minecraft_1_7_2  = &Version{4, "1.7.2"}
	Minecraft_1_7_6  = &Version{5, "1.7.6"}
	Minecraft_1_8    = &Version{47, "1.8"}
	Minecraft_1_9    = &Version{107, "1.9"}
	Minecraft_1_9_1  = &Version{108, "1.9.1"}
	Minecraft_1_9_4  = &Version{110, "1.9.4"}
	Minecraft_1_11   = &Version{315, "1.11"}
	Minecraft_1_12   = &Version{335, "1.12"}
	Minecraft_1_12_1 = &Version{338, "1.12.1"}
	Minecraft_1_12_2 = &Version{340, "1.12.2"}
	Minecraft_1_13   = &Version{393, "1.13"}
	Minecraft_1_13_2 = &Version{404, "1.13.2"}
	Minecraft_1_14   = &Version{477, "1.14"}
	Minecraft_1_15   = &Version{573, "1.15"}
	Minecraft_1_16   = &Version{735, "1.16"}
	Minecraft_1_16_1 = &Version{736, "1.16.1"}
	Minecraft_1_16_2 = &Version{751, "1.16.2"}

	// Versions ordered from lowest to highest
	Versions = []*Version{
		Unknown,
		Legacy,
		Minecraft_1_7_2, Minecraft_1_7_6,
		Minecraft_1_8,
		Minecraft_1_9, Minecraft_1_9_1, Minecraft_1_9_4,
		Minecraft_1_11,
		Minecraft_1_12, Minecraft_1_12_1, Minecraft_1_12_2,
		Minecraft_1_13, Minecraft_1_13_2,
		Minecraft_1_14,
		Minecraft_1_15,
		Minecraft_1_16, Minecraft_1_16_1, Minecraft_1_16_2,
	}
)
View Source
var (
	IdToVersion = func() map[Protocol]*Version {
		m := make(map[Protocol]*Version, len(Versions))
		for _, v := range Versions {
			m[v.Protocol] = v
		}
		return m
	}()
	SupportedVersions = func() (v []*Version) {
		for _, ver := range Versions {
			if !ver.Unknown() && !ver.Legacy() {
				v = append(v, ver)
			}
		}
		return
	}()
)
View Source
var (
	// The lowest supported version.
	MinimumVersion = SupportedVersions[0]
	// The highest supported version.
	MaximumVersion = SupportedVersions[len(SupportedVersions)-1]
	// The supported versions range as a string.
	SupportedVersionsString = fmt.Sprintf("%s-%s", MinimumVersion, MaximumVersion)
)

Functions

func Supported

func Supported(protocol Protocol) bool

Supported returns whether the protocol is supported.

Types

type Direction

type Direction uint8

Direction is the direction a packet is meant to go to/come from.

const (
	ClientBound Direction = iota // Packets sent to the client.
	ServerBound                  // Packets send to this proxy.
)

func (Direction) String

func (d Direction) String() string

type Packet

type Packet interface {
	Encode(c *PacketContext, wr io.Writer) error       // Encodes the packet into the writer
	Decode(c *PacketContext, rd io.Reader) (err error) // Decodes a packet by reading from the reader
}

Packet should be implemented by any Minecraft protocol packet. It is the layer of the protocol packet's data.

type PacketContext

type PacketContext struct {
	Direction Direction // The direction the packet was bound to.
	Protocol  Protocol  // The protocol version of the packet.

	KnownPacket bool     // If false Packet field is nil.
	PacketId    PacketId // Is always set.
	Packet      Packet   // The decoded packet.

	// The unencrypted and uncompressed form of packet id + data.
	// It contains the actual received payload (may be longer than what the Packet's Decode read).
	// This can be used to skip encoding Packet.
	Payload []byte // Empty when encoding.
}

type PacketId

type PacketId int

PacketId identifies a packet.

func (PacketId) String

func (p PacketId) String() string

type PacketType

type PacketType reflect.Type

PacketType helps to instantiate a new packet of it's reflect type.

func TypeOf

func TypeOf(p Packet) PacketType

TypeOf is a helper func to make sure the reflect.Type of p implements Packet and returns a non-pointer type.

type Protocol

type Protocol int

func (Protocol) Greater

func (p Protocol) Greater(then *Version) bool

func (Protocol) GreaterEqual

func (p Protocol) GreaterEqual(then *Version) bool

func (Protocol) Legacy

func (p Protocol) Legacy() bool

func (Protocol) Lower

func (p Protocol) Lower(then *Version) bool

func (Protocol) LowerEqual

func (p Protocol) LowerEqual(then *Version) bool

func (Protocol) String

func (p Protocol) String() string

func (Protocol) Supported

func (p Protocol) Supported() bool

func (Protocol) Unknown

func (p Protocol) Unknown() bool

func (Protocol) Version added in v0.3.0

func (p Protocol) Version() *Version

type State

type State int

State is a client state.

const (
	HandshakeState State = iota
	StatusState
	LoginState
	PlayState
)

States the client connection can be in.

func (State) String

func (s State) String() string

type Version

type Version struct {
	Protocol
	Name string
}

Version is a Minecraft Java version.

func ProtocolVersion

func ProtocolVersion(protocol Protocol) *Version

ProtocolVersion gets the Version by the protocol id or returns the Unknown version if not found.

func (*Version) GreaterEqual

func (v *Version) GreaterEqual(then Version) bool

func (Version) String

func (v Version) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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