Interface IEventListener<T extends Event>

Type Parameters:
T - A generic type representing the kind of event that this listener accepts

public interface IEventListener<T extends Event>
An event listener that can listen to Event objects being fired once they have been registered into the IEventHandler using IEventHandler.registerListener(Class, IEventListener).
  • Method Summary

    Modifier and Type
    Method
    Description
    listen(EventResult result, T event)
    This method is called whenever the event that this listener listens to is fired.
  • Method Details

    • listen

      EventResult listen(EventResult result, T event)
      This method is called whenever the event that this listener listens to is fired. It receivs the result of the event, which is EventResult.DEFAULT by default, but which can be changed by other listeners that are in the queue before this one returning a different EventResult in their listen method. Generally, if you don't change the event result, yourself, you should always return the result parameter that you are given rather than just EventResult.DEFAULT.

      Returning EventResult.CANCELLED will cancel any event's listening process, meaning the queue of listeners will be cleared so that listeners later in the queue will not listen to this event.

      Parameters:
      result - The event result of the previous listener. This should be passed on if the event's result should not be changed
      event - The actual event instance that can be checked or modified. Generally speaking, if an event has parameters that are non-final, they can be changed by the event listener to change the outcome of the event.
      Returns:
      The result passed into this method if unchanged, else the corresponding event result