util

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxStringSize = bufio.MaxScanTokenSize
)
View Source
const ForgeMaxArrayLength = math.MaxInt32 & 0x1FFF9A

Variables

This section is empty.

Functions

func DefaultJsonCodec

func DefaultJsonCodec() codec.Codec

DefaultJsonCodec returns a legacy supportive codec.

func JsonCodec

func JsonCodec(protocol proto.Protocol) codec.Codec

JsonCodec returns the appropriate codec for the given protocol version. This is used to constrain messages sent to older clients.

func LatestJsonCodec

func LatestJsonCodec() codec.Codec

func MarshalPlain added in v0.19.0

func MarshalPlain(c component.Component) (string, error)

MarshalPlain marshals a component into plain text. A component.Translation is formatted as "{key}".

func ReadBool

func ReadBool(reader io.Reader) (val bool, err error)

func ReadByte

func ReadByte(reader io.Reader) (val byte, err error)

func ReadBytes

func ReadBytes(rd io.Reader) ([]byte, error)

func ReadBytes17

func ReadBytes17(rd io.Reader) ([]byte, error)

ReadBytes17 reads bytes with the Minecraft 1.7 style length.

func ReadBytesLen

func ReadBytesLen(rd io.Reader, maxLength int) (bytes []byte, err error)

func ReadComponent added in v0.19.0

func ReadComponent(rd io.Reader, protocol proto.Protocol) (component.Component, error)

func ReadExtendedForgeShort

func ReadExtendedForgeShort(rd io.Reader) (int, error)

ReadExtendedForgeShort reads a Minecraft-style extended short from the specified {@code buf}.

func ReadFloat32

func ReadFloat32(reader io.Reader) (val float32, err error)

func ReadFloat64

func ReadFloat64(reader io.Reader) (val float64, err error)

func ReadInt

func ReadInt(rd io.Reader) (int, error)

func ReadInt16

func ReadInt16(reader io.Reader) (val int16, err error)

func ReadInt32

func ReadInt32(reader io.Reader) (val int32, err error)

func ReadInt64

func ReadInt64(reader io.Reader) (val int64, err error)

func ReadInt8

func ReadInt8(reader io.Reader) (val int8, err error)

func ReadIntArray added in v0.12.0

func ReadIntArray(rd io.Reader) ([]int, error)

func ReadProperties

func ReadProperties(rd io.Reader) (props []profile.Property, err error)

func ReadRawBytes added in v0.15.1

func ReadRawBytes(rd io.Reader) ([]byte, error)

Reads a non length prefixed string from the reader. This is necessary for parsing certain packets like the velocity login/hello packet (no length prefix).

func ReadString

func ReadString(rd io.Reader) (string, error)

func ReadStringArray

func ReadStringArray(rd io.Reader) ([]string, error)

func ReadStringMax

func ReadStringMax(rd io.Reader, max int) (string, error)

func ReadStringWithoutLen

func ReadStringWithoutLen(rd io.Reader) (string, error)

ReadStringWithoutLen reads a non length-prefixed string from the Reader. We need this for the legacy 1.7 version, being inconsistent when sending the plugin message channel brand.

func ReadUTF

func ReadUTF(rd io.Reader) (string, error)

ReadUTF util function as exists in Java

func ReadUUID

func ReadUUID(rd io.Reader) (id uuid.UUID, err error)

func ReadUint16

func ReadUint16(reader io.Reader) (val uint16, err error)

func ReadUint32

func ReadUint32(reader io.Reader) (val uint32, err error)

func ReadUint64

func ReadUint64(reader io.Reader) (val uint64, err error)

func ReadUint8

func ReadUint8(reader io.Reader) (val uint8, err error)

func ReadUnixMilli added in v0.19.0

func ReadUnixMilli(rd io.Reader) (time.Time, error)

func ReadVarInt

func ReadVarInt(r io.Reader) (result int, err error)

func WriteBool

func WriteBool(writer io.Writer, val bool) (err error)

func WriteByte

func WriteByte(writer io.Writer, val byte) (err error)

equal to WriteUint8

func WriteBytes

func WriteBytes(wr io.Writer, b []byte) (err error)

func WriteBytes17

func WriteBytes17(wr io.Writer, b []byte, allowExtended bool) error

func WriteComponent added in v0.19.0

func WriteComponent(wr io.Writer, protocol proto.Protocol, c component.Component) error

func WriteExtendedForgeShort

func WriteExtendedForgeShort(wr io.Writer, toWrite int) (err error)

func WriteFloat32

func WriteFloat32(writer io.Writer, val float32) (err error)

func WriteFloat64

func WriteFloat64(writer io.Writer, val float64) (err error)

func WriteInt added in v0.12.0

func WriteInt(writer io.Writer, val int) (err error)

func WriteInt16

func WriteInt16(writer io.Writer, val int16) (err error)

func WriteInt32

func WriteInt32(writer io.Writer, val int32) (err error)

func WriteInt64

func WriteInt64(writer io.Writer, val int64) (err error)

func WriteInt8

func WriteInt8(writer io.Writer, val int8) (err error)

equal to WriteUint8

func WriteProperties

func WriteProperties(wr io.Writer, properties []profile.Property) error

func WriteRawBytes added in v0.15.1

func WriteRawBytes(wr io.Writer, b []byte) (err error)

Writes a raw strema of bytes to a file with no length prefix. Necessary for the Velocity hello/login packet (it uses a non-standard packet format)

func WriteString

func WriteString(writer io.Writer, val string) (err error)

func WriteStrings

func WriteStrings(wr io.Writer, a []string) error

func WriteUTF

func WriteUTF(wr io.Writer, s string) error

WriteUTF util function as exists in Java

func WriteUUID

func WriteUUID(wr io.Writer, uuid uuid.UUID) error

Encoded as an unsigned 128-bit integer (or two unsigned 64-bit integers: the most significant 64 bits and then the least significant 64 bits)

func WriteUint16

func WriteUint16(writer io.Writer, val uint16) (err error)

func WriteUint32

func WriteUint32(writer io.Writer, val uint32) (err error)

func WriteUint64

func WriteUint64(writer io.Writer, val uint64) (err error)

func WriteUint8

func WriteUint8(writer io.Writer, val uint8) (err error)

equal to WriteByte

func WriteUint8N added in v0.19.1

func WriteUint8N(writer io.Writer, val uint8) (n int, err error)

func WriteVarInt

func WriteVarInt(writer io.Writer, val int) (err error)

func WriteVarIntN added in v0.19.1

func WriteVarIntN(writer io.Writer, val int) (n int, err error)

Types

type NBT

type NBT map[string]any

NBT is a named binary tag.

func (NBT) Bool

func (b NBT) Bool(name string) (bool, bool)

func (NBT) ByteArray

func (b NBT) ByteArray(name string) (ret []byte, ok bool)

func (NBT) Float32

func (b NBT) Float32(name string) (ret float32, ok bool)

func (NBT) Float64

func (b NBT) Float64(name string) (ret float64, ok bool)

func (NBT) Int

func (b NBT) Int(name string) (int, bool)

func (NBT) Int16

func (b NBT) Int16(name string) (ret int16, ok bool)

func (NBT) Int32

func (b NBT) Int32(name string) (ret int32, ok bool)

func (NBT) Int32Array

func (b NBT) Int32Array(name string) (ret []int32, ok bool)

func (NBT) Int64

func (b NBT) Int64(name string) (ret int64, ok bool)

func (NBT) Int64Array

func (b NBT) Int64Array(name string) (ret []int64, ok bool)

func (NBT) Int8

func (b NBT) Int8(name string) (ret int8, ok bool)

func (NBT) List

func (b NBT) List(name string) (ret []NBT, ok bool)

func (NBT) NBT

func (b NBT) NBT(name string) (ret NBT, ok bool)

func (NBT) String

func (b NBT) String(name string) (ret string, ok bool)

func (NBT) Uint8

func (b NBT) Uint8(name string) (ret uint8, ok bool)

Jump to

Keyboard shortcuts

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