Documentation ¶
Index ¶
- Constants
- type ArgumentSignature
- type ArgumentSignatures
- type Builder
- type ChatAcknowledgement
- type ComponentHolder
- func FromComponent(comp component.Component) *ComponentHolder
- func FromComponentProtocol(comp component.Component, protocol proto.Protocol) *ComponentHolder
- func ReadComponentHolder(rd io.Reader, protocol proto.Protocol) (*ComponentHolder, error)
- func ReadComponentHolderNP(rd io.Reader, protocol proto.Protocol) (ComponentHolder, error)
- func (c *ComponentHolder) AsBinaryTag() (util.BinaryTag, error)
- func (c *ComponentHolder) AsComponent() (component.Component, error)
- func (c *ComponentHolder) AsComponentOrNil() component.Component
- func (c *ComponentHolder) AsJson() (json.RawMessage, error)
- func (c *ComponentHolder) AsJsonOrNil() json.RawMessage
- func (c *ComponentHolder) Write(wr io.Writer, protocol proto.Protocol) error
- type KeyedPlayerChat
- type KeyedPlayerCommand
- type LastSeenMessages
- type LegacyChat
- type MessageType
- type RemoteChatSession
- type SessionPlayerChat
- type SessionPlayerCommand
- type SystemChat
- type UnsignedPlayerCommand
Constants ¶
const MaxPreviousMessageCount = 5
const (
MaxServerBoundMessageLength = 256
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgumentSignature ¶
func (*ArgumentSignature) Decode ¶
func (a *ArgumentSignature) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*ArgumentSignature) Encode ¶
func (a *ArgumentSignature) Encode(c *proto.PacketContext, wr io.Writer) error
type ArgumentSignatures ¶
type ArgumentSignatures struct {
Entries []ArgumentSignature
}
func (*ArgumentSignatures) Decode ¶
func (a *ArgumentSignatures) Decode(c *proto.PacketContext, rd io.Reader) error
func (*ArgumentSignatures) Encode ¶
func (a *ArgumentSignatures) Encode(c *proto.PacketContext, wr io.Writer) error
type Builder ¶
type Builder struct { // Protocol is the protocol version of the message. // If not set, defaults to supporting older clients. Protocol proto.Protocol // Component is the component to send to the client. // If nil, Message is used instead. Component component.Component Message string // Only used if Component is nil // Type is the position the message is going to be sent. // If not set, defaults to ChatMessageType. Type MessageType // Sender is the UUID of the player who sent the message. // If zero (uuid.Nil), the message is sent by the server. Sender uuid.UUID // Timestamp is the time the message was sent. Timestamp time.Time // LastSeenMessages is the last seen messages state of the player. LastSeenMessages LastSeenMessages }
Builder is a builder for protocol aware chat messages.
type ChatAcknowledgement ¶ added in v0.35.0
type ChatAcknowledgement struct {
Offset int
}
func (*ChatAcknowledgement) Decode ¶ added in v0.35.0
func (c *ChatAcknowledgement) Decode(_ *proto.PacketContext, rd io.Reader) (err error)
func (*ChatAcknowledgement) Encode ¶ added in v0.35.0
func (c *ChatAcknowledgement) Encode(_ *proto.PacketContext, wr io.Writer) error
type ComponentHolder ¶ added in v0.35.0
type ComponentHolder struct { Protocol proto.Protocol Component component.Component JSON json.RawMessage BinaryTag nbt.RawMessage }
ComponentHolder holds a chat component that can be represented in different formats.
func FromComponent ¶ added in v0.35.0
func FromComponent(comp component.Component) *ComponentHolder
func FromComponentProtocol ¶ added in v0.35.0
func FromComponentProtocol(comp component.Component, protocol proto.Protocol) *ComponentHolder
func ReadComponentHolder ¶ added in v0.35.0
ReadComponentHolder reads a ComponentHolder from the provided reader.
func ReadComponentHolderNP ¶ added in v0.35.0
ReadComponentHolderNP reads a ComponentHolder from the provided reader.
func (*ComponentHolder) AsBinaryTag ¶ added in v0.35.0
func (c *ComponentHolder) AsBinaryTag() (util.BinaryTag, error)
func (*ComponentHolder) AsComponent ¶ added in v0.35.0
func (c *ComponentHolder) AsComponent() (component.Component, error)
AsComponent returns the component as a component.Component.
func (*ComponentHolder) AsComponentOrNil ¶ added in v0.35.0
func (c *ComponentHolder) AsComponentOrNil() component.Component
func (*ComponentHolder) AsJson ¶ added in v0.35.0
func (c *ComponentHolder) AsJson() (json.RawMessage, error)
AsJson returns the component as a JSON raw message.
func (*ComponentHolder) AsJsonOrNil ¶ added in v0.35.0
func (c *ComponentHolder) AsJsonOrNil() json.RawMessage
type KeyedPlayerChat ¶
type KeyedPlayerChat struct { Message string SignedPreview bool Unsigned bool Expiry time.Time // may be zero if no salt or signature specified Signature []byte Salt []byte PreviousMessages []*crypto.SignaturePair LastMessage *crypto.SignaturePair }
func (*KeyedPlayerChat) Decode ¶
func (p *KeyedPlayerChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*KeyedPlayerChat) Encode ¶
func (p *KeyedPlayerChat) Encode(c *proto.PacketContext, wr io.Writer) error
type KeyedPlayerCommand ¶
type KeyedPlayerCommand struct { Unsigned bool Command string Timestamp time.Time Salt int64 SignedPreview bool // purely for pass through for 1.19 -> 1.19.2 - this will never be implemented Arguments map[string][]byte PreviousMessages []*crypto.SignaturePair LastMessage *crypto.SignaturePair }
func NewKeyedPlayerCommand ¶
func NewKeyedPlayerCommand(command string, arguments []string, timestamp time.Time) *KeyedPlayerCommand
NewKeyedPlayerCommand returns a new KeyedPlayerCommand packet based on a command and list of arguments.
func (*KeyedPlayerCommand) Decode ¶
func (p *KeyedPlayerCommand) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*KeyedPlayerCommand) Encode ¶
func (p *KeyedPlayerCommand) Encode(c *proto.PacketContext, wr io.Writer) error
type LastSeenMessages ¶
func (*LastSeenMessages) Decode ¶
func (l *LastSeenMessages) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*LastSeenMessages) Empty ¶
func (l *LastSeenMessages) Empty() bool
func (*LastSeenMessages) Encode ¶
func (l *LastSeenMessages) Encode(c *proto.PacketContext, wr io.Writer) error
type LegacyChat ¶
type LegacyChat struct { Message string Type MessageType Sender uuid.UUID // 1.16+, and can be empty UUID, all zeros }
func (*LegacyChat) Decode ¶
func (ch *LegacyChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*LegacyChat) Encode ¶
func (ch *LegacyChat) Encode(c *proto.PacketContext, wr io.Writer) error
type MessageType ¶
type MessageType byte
MessageType is the position a chat message is going to be sent.
const ( // ChatMessageType lets the chat message appear in the client's HUD. // These messages can be filtered out by the client's settings. ChatMessageType MessageType = iota // SystemMessageType lets the chat message appear in the client's HUD and can't be dismissed. SystemMessageType // GameInfoMessageType lets the chat message appear above the player's main HUD. // This text format doesn't support many component features, such as hover events. GameInfoMessageType )
type RemoteChatSession ¶
type RemoteChatSession struct { ID uuid.UUID // may be zero Key crypto.IdentifiedKey }
RemoteChatSession represents a remote chat session that is used to send messages.
func (*RemoteChatSession) Decode ¶
func (r *RemoteChatSession) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*RemoteChatSession) Encode ¶
func (r *RemoteChatSession) Encode(c *proto.PacketContext, wr io.Writer) error
func (*RemoteChatSession) IdentifiedKey ¶
func (r *RemoteChatSession) IdentifiedKey() crypto.IdentifiedKey
func (*RemoteChatSession) SessionID ¶
func (r *RemoteChatSession) SessionID() uuid.UUID
type SessionPlayerChat ¶
type SessionPlayerChat struct { Message string Timestamp time.Time Salt int64 Signed bool Signature []byte LastSeenMessages LastSeenMessages }
func (*SessionPlayerChat) Decode ¶
func (p *SessionPlayerChat) Decode(c *proto.PacketContext, rd io.Reader) error
func (*SessionPlayerChat) Encode ¶
func (p *SessionPlayerChat) Encode(c *proto.PacketContext, wr io.Writer) error
type SessionPlayerCommand ¶
type SessionPlayerCommand struct { Command string Timestamp time.Time Salt int64 ArgumentSignatures ArgumentSignatures LastSeenMessages LastSeenMessages }
func (*SessionPlayerCommand) Decode ¶
func (s *SessionPlayerCommand) Decode(c *proto.PacketContext, rd io.Reader) error
func (*SessionPlayerCommand) Encode ¶
func (s *SessionPlayerCommand) Encode(c *proto.PacketContext, wr io.Writer) error
func (*SessionPlayerCommand) Signed ¶
func (s *SessionPlayerCommand) Signed() bool
type SystemChat ¶
type SystemChat struct { Component *ComponentHolder Type MessageType }
func (*SystemChat) Decode ¶
func (p *SystemChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*SystemChat) Encode ¶
func (p *SystemChat) Encode(c *proto.PacketContext, wr io.Writer) error
type UnsignedPlayerCommand ¶ added in v0.37.0
type UnsignedPlayerCommand struct {
SessionPlayerCommand
}
func (*UnsignedPlayerCommand) Decode ¶ added in v0.37.0
func (u *UnsignedPlayerCommand) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*UnsignedPlayerCommand) Encode ¶ added in v0.37.0
func (u *UnsignedPlayerCommand) Encode(c *proto.PacketContext, wr io.Writer) error
func (*UnsignedPlayerCommand) Signed ¶ added in v0.37.0
func (u *UnsignedPlayerCommand) Signed() bool
Signed always returns false as it is unsigned.