net

package
v0.0.0-...-ed75f63 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package net provides tools for creating minecraft servers, such as packet sending, registry data, encryption, authentication, compression and more

Index

Constants

View Source
const (
	HandshakingState = iota
	StatusState
	LoginState
	ConfigurationState
	PlayState
)
View Source
const (
	ProtocolVersion = 767
)

Variables

View Source
var MaxCompressedPacketSize = 1024 * 1024

1MiB

View Source
var PacketDecodeInterceptor func(c *Conn, pk packet.Decodeable) (stop bool)
View Source
var PacketEncodeInterceptor func(c *Conn, pk packet.Encodeable) (stop bool)
View Source
var PacketReadInterceptor func(c *Conn, pk *bytes.Reader, packetId int32) (stop bool)
View Source
var PacketWriteInterceptor func(c *Conn, pk *bytes.Buffer, headerSize int32) (stop bool)
View Source
var ServerboundPool = map[int32]map[int32]func() packet.Decodeable{
	HandshakingState: {
		0x00: func() packet.Decodeable { return &handshake.Handshaking{} },
	},
	StatusState: {
		0x00: func() packet.Decodeable { return &status.StatusRequest{} },
		0x01: func() packet.Decodeable { return &status.Ping{} },
	},
	LoginState: {
		0x00: func() packet.Decodeable { return &login.LoginStart{} },
		0x02: func() packet.Decodeable { return &login.LoginPluginResponse{} },
		0x01: func() packet.Decodeable { return &login.EncryptionResponse{} },
		0x03: func() packet.Decodeable { return &login.LoginAcknowledged{} },
		0x04: func() packet.Decodeable { return &login.CookieResponse{} },
	},
	ConfigurationState: {
		0x00: func() packet.Decodeable { return &configuration.ClientInformation{} },
		0x01: func() packet.Decodeable { return &configuration.CookieResponse{} },
		0x02: func() packet.Decodeable { return &configuration.ServerboundPluginMessage{} },
		0x03: func() packet.Decodeable { return &configuration.AcknowledgeFinishConfiguration{} },
		0x04: func() packet.Decodeable { return &configuration.KeepAlive{} },
		0x05: func() packet.Decodeable { return &configuration.Pong{} },
	},
	PlayState: {
		0x00: func() packet.Decodeable { return &play.ConfirmTeleportation{} },
		0x04: func() packet.Decodeable { return &play.ChatCommand{} },
		0x05: func() packet.Decodeable { return &play.SignedChatCommand{} },
		0x06: func() packet.Decodeable { return &play.ChatMessage{} },
		0x08: func() packet.Decodeable { return &play.ChunkBatchReceived{} },
		0x07: func() packet.Decodeable { return &play.PlayerSession{} },
		0x0A: func() packet.Decodeable { return &play.ClientInformation{} },
		0x0E: func() packet.Decodeable { return &play.ClickContainer{} },
		0x0F: func() packet.Decodeable { return &play.CloseContainer{} },
		0x12: func() packet.Decodeable { return &play.ServerboundPluginMessage{} },
		0x16: func() packet.Decodeable { return &play.Interact{} },
		0x18: func() packet.Decodeable { return &play.ServerboundKeepAlive{} },
		0x1A: func() packet.Decodeable { return &play.SetPlayerPosition{} },
		0x1B: func() packet.Decodeable { return &play.SetPlayerPositionAndRotation{} },
		0x1C: func() packet.Decodeable { return &play.SetPlayerRotation{} },
		0x1D: func() packet.Decodeable { return &play.SetPlayerOnGround{} },
		0x23: func() packet.Decodeable { return &play.PlayerAbilitiesServerbound{} },
		0x25: func() packet.Decodeable { return &play.PlayerCommand{} },
		0x2F: func() packet.Decodeable { return &play.SetHeldItemServerbound{} },
		0x32: func() packet.Decodeable { return &play.SetCreativeModeSlot{} },
		0x36: func() packet.Decodeable { return &play.SwingArm{} },
		0x38: func() packet.Decodeable { return &play.UseItemOn{} },
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Status StatusProvider

	PacketWriteChanBuffer int
	IP                    net.IP
	Port                  int
	CompressionThreshold  int32
	Encrypt               bool
	Authenticate          bool
	AcceptTransfers       bool
}

func (Config) New

func (c Config) New() (*Listener, error)

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*Conn) Properties

func (conn *Conn) Properties() []login.Property

func (*Conn) PushPacket

func (conn *Conn) PushPacket(pk packet.Encodeable)

PushPacket adds a packet to the queue without waiting for it to be sent

func (*Conn) Read

func (conn *Conn) Read(dst []byte) (i int, err error)

func (*Conn) ReadPacket

func (conn *Conn) ReadPacket() (decoded packet.Decodeable, interceptionStopped bool, err error)

func (*Conn) SetState

func (conn *Conn) SetState(state int32)

func (*Conn) State

func (conn *Conn) State() int32

func (*Conn) UUID

func (conn *Conn) UUID() uuid.UUID

func (*Conn) Username

func (conn *Conn) Username() string

func (*Conn) UsesForge

func (conn *Conn) UsesForge() bool

func (*Conn) Write

func (conn *Conn) Write(data []byte) (i int, err error)

func (*Conn) WritePacket

func (conn *Conn) WritePacket(pk packet.Encodeable) error

type Listener

type Listener struct {
	net.Listener

	ApprovePlayer func(*Conn) (ok bool, disconnectionReason *text.TextComponent)
	// contains filtered or unexported fields
}

func (*Listener) Accept

func (l *Listener) Accept() (*Conn, error)

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) SetStatusProvider

func (l *Listener) SetStatusProvider(p StatusProvider)

func (*Listener) StatusProvider

func (l *Listener) StatusProvider() StatusProvider

type StatusProvider

type StatusProvider func(*Conn) status.StatusResponseData

Directories

Path Synopsis
io
encoding
Package encoding provides encoding and decoding of minecraft data types
Package encoding provides encoding and decoding of minecraft data types

Jump to

Keyboard shortcuts

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