BaseEvent
com.jsmacrosce.jsmacros.core.event.BaseEvent
Base class for event payloads dispatched to registered listeners. By default, the runtime class's Event annotation supplies its name and cancellable/joinable flags; without an annotation, the simple class name is used and both flags are false. Subclasses may override these methods, as EventCustom does.
Dispatch waits for a listener only when that listener requests joined handling and the event permits joining. A joined listener may cancel or change the event while its event lock is held.
A listener that did not request joined handling receives a read-only delivery: dispatch does not wait for it, so the game may already have read the event by the time its callback runs. It cannot cancel or change the event. Call canModify() to check the current delivery before attempting a change.
const listener = JsMacros.on("SendMessage", true, JavaWrapper.methodToJava(event => {
if (event.getMessage() === "/hello") {
// Cancel before the message is sent or added to chat history.
event.cancel();
}
// Remove a one-shot listener using the handle returned by on().
JsMacros.off(listener);
}));Constructors
new BaseEvent
Fields
runner
Methods
cancel
cancel(): void#cancellable
cancellable(): boolean#@Event defaults to false.true if the event declares itself cancellable.canModify
true for a joined listener while its event lock is still held, for the raising thread during dispatch, and for a custom event's creator between dispatches. It is false for a non-joined listener, after the event lock is released, and for built-in events after dispatch returns.true if the current delivery may cancel or change the eventgetEventName
SendMessage, or the runtime class's simple name when no annotation is present.isCanceled
joinable
joinable(): boolean#true if the event is cancellable or declares itself joinable.trigger
trigger(): void#