Package net.minestom.server.event
Interface ListenerHandle<E extends Event>
- Type Parameters:
E
- the event type
Represents a key to a listenable event, retrievable from
EventNode.getHandle(Class)
.
Useful to avoid map lookups.
It is recommended to store instances of this class in static final
fields.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls the given event.boolean
Gets if any listener has been registered for the given handle.
-
Method Details
-
call
Calls the given event. Will try to fast exit the execution when possible ifhasListener()
returnfalse
.Anonymous and subclasses are not supported, events must have the exact type
E
.- Parameters:
event
- the event to call
-
hasListener
boolean hasListener()Gets if any listener has been registered for the given handle. May trigger an update if the cached data is not correct.Useful if you are able to avoid expensive computation in the case where the event is unused. Be aware that
call(Event)
has similar optimization built-in.- Returns:
- true if the event has 1 or more listeners
-