Skip to content

Custom ​

com.jsmacrosce.jsmacros.core.event.impl.EventCustom

Since1.2.8Cancellable per instance

A named event with key-value arguments. Call registerEvent() before subscribing; dispatch also reaches eligible ANYTHING listeners. Set cancelable before dispatch to let listeners cancel this instance; check isCanceled() after dispatch returns. Set joinable before dispatch to let trigger() wait for listeners that asked to be awaited.

Constructors ​

new EventCustom ​

new EventCustom(Core<?, ?> runner, String eventName)#

Parameters:

  • runner: core that supplies this event's runtime context
  • eventName: name used to dispatch this event

Fields ​

cancelable ​

cancelable: boolean#
Whether this event permits cancellation; defaults to false.

eventName ​

eventName: String#
Name used as this custom event's dispatch and subscription-registration key. Changing it does not register the new name; call registerEvent() separately.

joinable ​

joinable: boolean#
Whether trigger() may wait for listeners that requested joined handling; defaults to false. Set it on the instance that calls trigger(); instances created for the same name do not share it. Setting cancelable also permits joining. The wait ends when a joined listener releases its event lock, normally on callback return.

Methods ​

cancellable ​

cancellable(): boolean#
Whether this event currently permits cancellation.
Returns: the current value of cancelable; calling cancel() marks this instance cancelled when permitted.

getBoolean ​

getBoolean(String name): BooleanSince1.2.8#
Returns the argument if it is a boolean; otherwise returns null.

Parameters:

  • name: argument key
Returns: the value, or null if absent or not a boolean

getDouble ​

getDouble(String name): DoubleSince1.2.8#
Returns the argument if it is a double; otherwise returns null.

Parameters:

  • name: argument key
Returns: the value, or null if absent or not a double

getInt ​

getInt(String name): IntegerSince1.2.8#
Returns the argument if it is an integer; otherwise returns null.

Parameters:

  • name: argument key
Returns: the value, or null if absent or not an integer

getObject ​

getObject(String name): ObjectSince1.2.8#
Returns the argument value, or null if absent.

Parameters:

  • name: argument key
Returns: the value, or null if absent

getString ​

getString(String name): StringSince1.2.8#
Returns the argument if it is a string; otherwise returns null.

Parameters:

  • name: argument key
Returns: the value, or null if absent or not a string

getType ​

getType(String name): StringSince1.2.8#
Returns the stored argument's type label, or null when the key is absent.

Parameters:

  • name: argument key
Returns: Int, String, Double, Boolean, or Object; null if absent

getUnderlyingMap ​

getUnderlyingMap(): Map<String, Object>Since1.6.4#
Returns: the live map backing this event; changes to it change the event's arguments

joinable ​

joinable(): boolean#
Whether this event permits joining, based on its current joinable or cancelable flag.
Returns: true if either flag is true; this does not guarantee every listener is joined.

putBoolean ​

putBoolean(String name, boolean b): booleanSince1.2.8#
Stores a boolean argument.

Parameters:

  • name: argument key
  • b: value to store
Returns: the stored boolean value

putDouble ​

putDouble(String name, double d): doubleSince1.2.8#
Stores a double argument.

Parameters:

  • name: argument key
  • d: value to store
Returns: the stored double value

putInt ​

putInt(String name, int i): intSince1.2.8#
Stores an integer argument.

Parameters:

  • name: argument key
  • i: value to store
Returns: the stored integer value

putObject ​

putObject(String name, Object o): ObjectSince1.2.8#
Stores an object argument. Guest-language objects cause an AssertionError.

Parameters:

  • name: argument key
  • o: value to store
Returns: the stored object

putString ​

putString(String name, String str): StringSince1.2.8#
Stores a string argument.

Parameters:

  • name: argument key
  • str: value to store
Returns: the stored string value

registerEvent ​

registerEvent(): voidSince1.3.0#
Registers this event's name so it can be subscribed to and shown in the GUI.

trigger ​

trigger(): voidSince1.2.8#
Dispatches this event to listeners registered under its name and eligible ANYTHING listeners. If joinable() is true, waits for listeners that requested joined handling; cancellable events wait without that request. The wait ends when each joined listener releases its event lock, normally on callback return.

triggerAsync ​

triggerAsync(MethodWrapper<Object, Object, Object, ?> callback): voidSince1.9.0#
Dispatches the event on a thread-pool task and returns without waiting. callback runs after dispatch returns; that does not mean every listener has finished unless dispatch joined it.

Parameters:

  • callback: callback to run after dispatch returns