Documentation
¶
Index ¶
- Constants
- Variables
- func AppendPacketLength(buffer *buf.Buffer, l int)
- func PutVarInt(bs []byte, n int32) (numWrite int)
- func ReadInt(buffer *buf.Buffer) (int, error)
- func ReadInt16(buffer *buf.Buffer) (int16, error)
- func ReadInt32(buffer *buf.Buffer) (int32, error)
- func ReadInt64(buffer *buf.Buffer) (int64, error)
- func ReadInt8(buffer *buf.Buffer) (int8, error)
- func ReadString(buffer *buf.Buffer) (string, error)
- func ReadUint16(buffer *buf.Buffer) (uint16, error)
- func ReadUint32(buffer *buf.Buffer) (uint32, error)
- func ReadUint64(buffer *buf.Buffer) (uint64, error)
- func ReadVarIntFrom(r io.Reader) (i int32, n int64, err error)
- func Scan(buffer *buf.Buffer, item ...any) (err error)
- func VarIntLen(n int32) int
- func WriteToPacket(buffer *buf.Buffer, item ...any) (err error)
- type Conn
- type Message
- type VarInt
Constants ¶
const ( Chat = iota System GameInfo SayCommand MsgCommand TeamMsgCommand EmoteCommand TellrawCommand )
const ( Black = "black" DarkBlue = "dark_blue" DarkGreen = "dark_green" DarkAqua = "dark_aqua" DarkRed = "dark_red" DarkPurple = "dark_purple" Gold = "gold" Gray = "gray" DarkGray = "dark_gray" Blue = "blue" Green = "green" Aqua = "aqua" Red = "red" LightPurple = "light_purple" Yellow = "yellow" White = "white" )
Colors
const ( BooleanTrue = 0x01 BooleanFalse = 0x00 )
const MaxVarIntLen = 5
Variables ¶
var ErrVarIntTooBig = errors.New("VarInt is too big")
Functions ¶
func AppendPacketLength ¶
func PutVarInt ¶
PutVarInt encodes a Minecraft variable-length format int32 into bs and returns the number of bytes written. If the buffer is too small, PutVarInt will panic.
Types ¶
type Conn ¶
func StreamConn ¶
func (Conn) ReadLimitedPacket ¶
ReadLimitedPacket likes ReadPacket, but limits the maximum number of packet content bytes to read to maxLen.
func (Conn) ReadPacket ¶
ReadPacket reads a full packet to buffer.
func (Conn) WritePacket ¶
WritePacket appends packet length to packet head, and writes to Conn. Then reset the buffer to MaxVarIntLen. Note that the given buffer should have at least 5 bytes front headroom space.
func (Conn) WriteVectorizedPacket ¶
WriteVectorizedPacket appends the sum of length of packets to the buffer head, and writes all the packets to Conn. Then reset the buffer to MaxVarIntLen. This function would attempt to write packets using writev syscall to optimize performance, if the platform is available. Note that the given buffer should have at least 5 bytes front headroom space.
type Message ¶
type Message struct { Text string `json:"text"` Bold bool `json:"bold,omitempty"` // 粗体 Italic bool `json:"italic,omitempty"` // 斜体 UnderLined bool `json:"underlined,omitempty"` // 下划线 StrikeThrough bool `json:"strikethrough,omitempty"` // 删除线 Obfuscated bool `json:"obfuscated,omitempty"` // 随机 // Font of the message, could be one of minecraft:uniform, minecraft:alt or minecraft:default // This option is only valid on 1.16+, otherwise the property is ignored. Font string `json:"font,omitempty"` // 字体 Color string `json:"color,omitempty"` // 颜色 // Insertion contains text to insert. Only used for messages in chat. // When shift is held, clicking the component inserts the given text // into the chat box at the cursor (potentially replacing selected text). Insertion string `json:"insertion,omitempty"` Translate string `json:"translate,omitempty"` With []Message `json:"with,omitempty"` Extra []Message `json:"extra,omitempty"` }
Message is a message sent by other
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
UnmarshalJSON decode json to Message