Skip to content

RecvMessage ​

com.jsmacrosce.jsmacros.client.api.event.impl.EventRecvMessage

Since1.2.7Cancellable

Fired before a message is added to the chat HUD. Cancelling skips the HUD's entire addMessage call, including its chat-log output and queue updates.

js
JsMacros.on("RecvMessage", JavaWrapper.methodToJava(function (event) {
  if (event.messageType === "Chat Error") {
    // Hide the chat-validation error message.  
    event.cancel();  
    return;  
  }
  Chat.log(`[${event.messageType}] ${event.text.getString()}`);  
}))

Constructors ​

new EventRecvMessage ​

new EventRecvMessage(Component message, MessageSignature signature, GuiMessageTag indicator)#
Initializes the event with the supplied message, signature bytes, and chat-log tag; this constructor does not add or dispatch a HUD message. The message is wrapped with TextHelper.wrap(Component), which returns null for a null component despite the non-null annotation on text. The signature byte array is retained, not copied.

Parameters:

  • message: raw message content, or null
  • signature: raw signature, or null; its byte array is retained
  • indicator: HUD tag, or null; its log tag is stored as messageType

Fields ​

messageType ​

messageType: StringSince1.8.2#
Minecraft chat-log tag for the message, or null when no tag was supplied. JsMacros sets this to "Modified" when a listener changes text.

signature ​

signature: byte[]Since1.8.2#
Raw message-signature bytes, or null when no signature was supplied. Present signatures contain 256 bytes.

text ​

Message content to be added to the HUD. Replacing it changes the displayed and logged content and marks the line with a "Modified" messageType; assigning null instead causes the HUD message to be skipped.

Methods ​

toString ​

toString(): String#
Formats a diagnostic string from the event name and the current values of text, signature, and messageType. Its shape is eventName:{"text": "textValue", "signature": boolean, "messageType": "tagValue"}; the text and tag are inserted using ordinary string formatting, not JSON escaping. The signature value is true only when the current signature array is non-null and non-empty; it does not verify the signature.
Returns: diagnostic string containing the current field values