SendMessage
com.jsmacrosce.jsmacros.client.api.event.impl.EventSendMessage
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", true, JavaWrapper.methodToJava(function (event) {
if (event.getMessage() === null) {
return;
}
if (event.getMessage() === "/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.setMessage(`say ${event.getMessage()}`);
}))Constructors
new EventSendMessage
Fields
message
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.Deprecated: Removal in 3.0.0: Use getMessage() and setMessage(String) instead.
Methods
getMessage
setMessage
Replaces the text that will be sent. 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.Parameters:
message: replacement text, ornullto prevent sending