Class EventManager

java.lang.Object
net.lucypoulton.squirtgun.platform.event.EventManager

public class EventManager extends Object
Manages the execution of events and listeners.
  • Constructor Details

    • EventManager

      public EventManager(Platform platform)
  • Method Details

    • register

      public void register(EventListener listener)
      Registers all of a listener's handlers.
      Parameters:
      listener - the listener to register
    • register

      public void register(EventHandler<?> handler)
      Registers an event handler.
      Parameters:
      handler - the handler to register
    • unregister

      public void unregister(EventHandler<?> handler)
      Unregisters an event handler.
      Parameters:
      handler - the handler to unregister
    • dispatch

      public <T extends Event> Event.Result dispatch(T event)
      Dispatches an event, calling all event handlers in the corresponding order. If the event is cancellable, then Event.Result.FAILURE will 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.