Skip to content

BaseEventRegistry ​

com.jsmacrosce.jsmacros.core.event.BaseEventRegistry

Since1.2.7

Registry of event names, listeners, and dispatch metadata. Event classes are registered from their Event annotations; bare names can also be registered. Dispatch uses event-instance cancellability and joinability, with joinableEvents supplying joinability for named events. cancellableEvents is registration metadata and does not control BaseEvent.cancel(). Script listeners and profile macro triggers are represented by distinct listener types.

Constructors ​

new BaseEventRegistry ​

new BaseEventRegistry(Core runner)#
Creates a registry associated with the given core. Registration is performed separately.

Parameters:

  • runner: the core this registry belongs to.

Fields ​

cancellableEvents ​

cancellableEvents: Set<String>read-only#
Names registered with the cancellable flag. This metadata does not control BaseEvent.cancel(), which checks the event instance.

events ​

events: Set<String>read-only#
All registered event names, whether joinable or not.

filterableEvents ​

filterableEvents: Map<String, Class<? extends EventFilterer>>read-only#
Registered event names mapped to their declared filterer classes, when an event annotation specifies one.

joinableEvents ​

joinableEvents: Set<String>read-only#
Names treated as joinable by named-event dispatch. Registering a cancellable annotated event or bare name also marks its name joinable.

oldEvents ​

oldEvents: Map<String, String>read-only#
Aliases mapped to current event names, including registered event classes' simple names and any old names. The client registry uses these aliases when loading profile triggers; script subscriptions are not remapped.

Methods ​

addEvent ​

addEvent(String eventName): voidSince1.0.2#
Registers a name without joinable or cancellable registry flags.

Parameters:

  • eventName: the name to register.
addEvent(String eventName, boolean joinable): void#
Registers a bare event name and optionally marks it joinable. This does not mark it cancellable.

Parameters:

  • eventName: the name to register.
  • joinable: whether to mark the name joinable.
addEvent(String eventName, boolean joinable, boolean cancellable): void#
Registers a bare event name with joinable and cancellable flags. A cancellable name is also marked joinable.

Parameters:

  • eventName: the name to register.
  • joinable: whether to mark the name joinable.
  • cancellable: whether to mark the name cancellable; this also marks it joinable.
addEvent(Class<? extends BaseEvent> clazz): void#
Registers the name and flags from an event class's Event annotation. Its old name and simple class name map to the current name; declared filterers are recorded as well. Throws RuntimeException if the class has no Event annotation.

Parameters:

  • clazz: the event class to register.

addListener ​

addListener(String event, IEventListener listener): voidSince1.2.3#
Adds a listener under an event name, preserving insertion order and ignoring duplicates within that name. This method does not check whether the name is registered.

Parameters:

  • event: the name to associate with the listener.
  • listener: the listener to add.

addScriptTrigger ​

addScriptTrigger(ScriptTrigger rawmacro): voidSince1.2.9#
Registers a profile macro trigger as a listener. Implementations determine how triggers are converted; the client implementation remaps old event names and recognizes legacy Joined-prefixed event names.

Parameters:

  • rawmacro: the trigger to register, taken from the profile as it was saved.

clearMacros ​

clearMacros(): void#
Removes non-script listeners from the registry, leaving script listeners registered.

getListeners ​

getListeners(): Map<String, Set<IEventListener>>Since1.2.3#
Returns the live listener map used by dispatch; changes to it affect dispatch.
Returns: the live map of event name to its listeners.
getListeners(String key): Set<IEventListener>Since1.2.3#
Returns an immutable snapshot of listeners for a name. Looking up a missing name creates an empty entry in the registry.

Parameters:

  • key: the event name to look up.
Returns: an immutable snapshot of that name's listeners, empty if there are none.

getScriptTriggers ​

getScriptTriggers(): List<ScriptTrigger>Since1.2.9#
Returns the macro triggers represented by registered BaseListener listeners, not runtime script listeners.
Returns: the triggers represented by registered macro listeners.

removeListener ​

removeListener(String event, IEventListener listener): booleanSince1.2.3#
Removes a listener from one event name. If the name has no listener set, this creates an empty set for it.

Parameters:

  • event: the name the listener was filed under.
  • listener: the listener to take off.
Returns: true if the listener was registered under that name and has now been removed, false if it was not there to begin with.

removeScriptTrigger ​

removeScriptTrigger(ScriptTrigger rawmacro): booleanSince1.2.9#
Removes the listener associated with a macro trigger, if present. The implementation determines how triggers are matched to listeners.

Parameters:

  • rawmacro: the trigger to remove.
Returns: true if a listener for that trigger was registered and has now been removed, false if it was not there.