Class EventManager
java.lang.Object
net.lucypoulton.squirtgun.platform.event.EventManager
Manages the execution of events and listeners.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Event>
Event.Resultdispatch(T event) Dispatches an event, calling all event handlers in the corresponding order.voidregister(EventHandler<?> handler) Registers an event handler.voidregister(EventListener listener) Registers all of a listener's handlers.voidunregister(EventHandler<?> handler) Unregisters an event handler.
-
Constructor Details
-
EventManager
-
-
Method Details
-
register
Registers all of a listener's handlers.- Parameters:
listener- the listener to register
-
register
Registers an event handler.- Parameters:
handler- the handler to register
-
unregister
Unregisters an event handler.- Parameters:
handler- the handler to unregister
-
dispatch
Dispatches an event, calling all event handlers in the corresponding order. If the event is cancellable, thenEvent.Result.FAILUREwill be returned if it is cancelled.- Parameters:
event- the event object to dispatch.- Returns:
- a result indicating whether the event was cancelled.
If the event is not cancellable, then
Event.Result.SUCCESS.
-