BaseEventRegistry
com.jsmacrosce.jsmacros.core.event.BaseEventRegistry
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
Fields
cancellableEvents
Names registered with the cancellable flag. This metadata does not control BaseEvent.cancel(), which checks the event instance.
events
filterableEvents
Registered event names mapped to their declared filterer classes, when an event annotation specifies one.
joinableEvents
oldEvents
Methods
addEvent
Registers a name without joinable or cancellable registry flags.
Parameters:
eventName: the name to register.
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.
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.
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
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
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
Returns the live listener map used by dispatch; changes to it affect dispatch.
Returns: the live map of event name to its listeners.
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
Returns the macro triggers represented by registered BaseListener listeners, not runtime script listeners.
Returns: the triggers represented by registered macro listeners.
removeListener
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
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.