class
Rosegold::ChatManager
- Rosegold::ChatManager
- Reference
- Object
Overview
Manages chat message signing, salt generation, and acknowledgment tracking according to the Minecraft 1.21.8 protocol requirements.
Defined in:
rosegold/chat_manager.crConstant Summary
-
MAX_LAST_SEEN_MESSAGES =
20 -
SIGNATURE_SIZE =
256
Constructors
Instance Method Summary
- #acknowledgment : Acknowledgment
-
#add_last_seen_signature(signature : Bytes)
Track a received signed chat message like vanilla's LastSeenMessagesTracker: a repeat of the previous signature is ignored, otherwise it takes the newest slot of the 20-entry window and counts toward the next acknowledgment offset.
-
#increment_message_count
Increment message count (used when receiving messages from server)
-
#public_key_bytes : Bytes | Nil
Get public key bytes for server authentication (if needed)
-
#reset_session
Reset chat session (useful for reconnections)
-
#send_chat(message : String, session : Client::PlaySession | Nil = nil, authorized : -> Bool | Nil = nil) : Bool
Send chat message or command, automatically determining the correct method based on the message content and protocol version.
-
#send_command(command : String, session : Client::PlaySession | Nil = nil, authorized : -> Bool | Nil = nil) : Bool
Send a command with proper signing.
-
#send_message(message : String, session : Client::PlaySession | Nil = nil, authorized : -> Bool | Nil = nil) : Bool
Send a regular chat message with proper signing and acknowledgment.
-
#try_send_command(command : String, & : -> Bool) : SendResult
Single-attempt slash command through the native ChatCommand packet, with the same Busy/Refused/Sent contract as
#try_send_message. -
#try_send_message(message : String, & : -> Bool) : SendResult
Single-attempt chat send for callers that must not queue stale text.
Constructor Detail
Instance Method Detail
Track a received signed chat message like vanilla's LastSeenMessagesTracker: a repeat of the previous signature is ignored, otherwise it takes the newest slot of the 20-entry window and counts toward the next acknowledgment offset. Every tracked message is treated as shown.
Send chat message or command, automatically determining the correct method based on the message content and protocol version. With session, it is written only while that PLAY session is still current, and with authorized only while it approves under the write lock.
Send a command with proper signing. With session, it is written only while that PLAY session is still current, and with authorized only while it approves under the write lock.
Send a regular chat message with proper signing and acknowledgment. With session, it is written only while that PLAY session is still current, and with authorized only while it approves under the write lock.
Single-attempt slash command through the native ChatCommand packet, with the
same Busy/Refused/Sent contract as #try_send_message. command is the full
typed text including its leading '/'. Runs with the bot's own server
permissions; the server decides whether the command is allowed. Delivery
after a raised failure is unknown and must not be retried.
Single-attempt chat send for callers that must not queue stale text. Returns
Busy when another writer is active and Refused when the text is invalid or
guard (run under the write lock) declines; signing state advances only on
Sent. Raises NotConnected or an IO error without retrying, so delivery after
a failure is unknown.