Skip to content

SendMessage ​

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

Since1.2.7Cancellable

Fires for text submitted through the chat screen, before the game normalizes it. Cancelling prevents sending and chat-history insertion. A changed, nonempty value is sent directly without normalization or history insertion; null or an empty replacement is not sent. A leading / selects command submission, with the slash removed.

js
JsMacros.on("SendMessage", JavaWrapper.methodToJava(function (event) {
 if (event.message === null) {
   return;  
 }
 if (event.message === "/hello") {
   // swallow it, nothing is sent and nothing is added to the history
   event.cancel();  
   return;  
 }
 // rewrite it, the client sends this instead of what was typed
 event.message = `say ${event.message}`;  
}))

Constructors ​

new EventSendMessage ​

new EventSendMessage(String message)#
Initializes the event with the supplied message; construction does not dispatch the event.

Parameters:

  • message: initial message text, stored verbatim

Fields ​

message ​

message: String#
The raw text submitted in the chat screen. A changed, nonempty value is sent without normalization or history insertion; a leading / selects command submission, with the slash removed. null, an empty string, or cancelling the event prevents sending.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and current message text. The message is not escaped, so this representation is not JSON.
Returns: event name and current message text in the form %s:{"message": "%s"}