Skip to content

Service ​

com.jsmacrosce.jsmacros.core.service.EventService

Since1.6.4Not cancellable

Event payload for a running service, including shared arguments and stop callbacks.

Constructors ​

new EventService ​

new EventService(Core<?, ?> runner, String name)#
Initializes this event with its service runner and name; this does not start or register the service.

Parameters:

  • runner: core associated with this event
  • name: service name

Fields ​

postStopListener ​

postStopListener: MethodWrapper<Object, Object, Object, ?>Since1.9.1#
Callback run after event listeners and registered resources are removed when the service stops.

serviceName ​

serviceName: Stringread-only#
Immutable service name supplied at construction.

stopListener ​

stopListener: MethodWrapper<Object, Object, Object, ?>#
Callback run before event listeners and registered resources are removed when the service stops.

Methods ​

decrementAndGetInt ​

decrementAndGetInt(String name): IntegerSince1.6.5#
Decrements the integer value and returns the result; returns null without changing the map if it is absent or not an integer.

Parameters:

  • name: key to decrement
Returns: the value after decrement, or null

getAndDecrementInt ​

getAndDecrementInt(String name): IntegerSince1.6.5#
Decrements the integer value and returns its previous value; returns null without changing the map if it is absent or not an integer.

Parameters:

  • name: key to read and decrement
Returns: the value before decrement, or null

getAndIncrementInt ​

getAndIncrementInt(String name): IntegerSince1.6.5#
Increments the integer value and returns its previous value; returns null without changing the map if it is absent or not an integer.

Parameters:

  • name: key to read and increment
Returns: the value before increment, or null

getBoolean ​

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

Parameters:

  • name: key to read
Returns: the boolean value, or null

getDouble ​

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

Parameters:

  • name: key to read
Returns: the double value, or null

getInt ​

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

Parameters:

  • name: key to read
Returns: the integer value, or null

getObject ​

getObject(String name): ObjectSince1.6.5#
Returns the value stored for this key, or null if absent.

Parameters:

  • name: key to read
Returns: the stored value, or null

getRaw ​

getRaw(): Map<String, Object>#
Returns the live argument map; direct mutations bypass putObject(String, Object)'s guest-object check.
Returns: live shared argument map

getString ​

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

Parameters:

  • name: key to read
Returns: the string value, or null

getType ​

getType(String name): StringSince1.6.5#
Returns the stored value's type label, or null if the key is absent.

Parameters:

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

incrementAndGetInt ​

incrementAndGetInt(String name): IntegerSince1.6.5#
Increments the integer value and returns the result; returns null without changing the map if it is absent or not an integer.

Parameters:

  • name: key to increment
Returns: the value after increment, or null

putBoolean ​

putBoolean(String name, boolean b): booleanSince1.6.5#
Stores a boolean in this service event's shared argument map.

Parameters:

  • name: map key
  • b: value to store
Returns: the same value stored in the map

putDouble ​

putDouble(String name, double d): doubleSince1.6.5#
Stores a double in this service event's shared argument map.

Parameters:

  • name: map key
  • d: value to store
Returns: the same value stored in the map

putInt ​

putInt(String name, int i): intSince1.6.5#
Stores an integer in this service event's shared argument map.

Parameters:

  • name: map key
  • i: value to store
Returns: the same value stored in the map

putObject ​

putObject(String name, Object o): ObjectSince1.6.5#
Stores an object in this service event's shared argument map. Guest-language objects are rejected.

Parameters:

  • name: map key
  • o: value to store
Returns: the same value stored in the map

putString ​

putString(String name, String str): StringSince1.6.5#
Stores a string in this service event's shared argument map.

Parameters:

  • name: map key
  • str: value to store
Returns: the same value stored in the map

remove ​

remove(String key): voidSince1.6.5#
Removes a key from this service event's shared argument map.

Parameters:

  • key: key to remove

toggleBoolean ​

toggleBoolean(String name): BooleanSince1.6.5#
Toggles the boolean value and returns the result; returns null without changing the map if it is absent or not a boolean.

Parameters:

  • name: key to toggle
Returns: the value after toggling, or null

toString ​

toString(): String#
Returns a diagnostic representation containing the service name.
Returns: diagnostic service-name text

unregisterOnStop ​

unregisterOnStop(boolean offEvents, Registrable<?>... list): voidSince1.9.1#
Configures cleanup performed when the service stops; each call replaces the previous configuration. Cleanup runs between stopListener and postStopListener.

Parameters:

  • offEvents: whether to remove every listener registered by the service, rather than only listeners owned by its script context
  • list: resources to unregister; an empty list disables resource cleanup