Package de.ellpeck.rockbottom.api.event
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 TypeMethodDescriptionlisten(EventResult result, T event) This method is called whenever the event that this listener listens to is fired.
-
Method Details
-
listen
This method is called whenever the event that this listener listens to is fired. It receivs the result of the event, which isEventResult.DEFAULTby default, but which can be changed by other listeners that are in the queue before this one returning a differentEventResultin theirlistenmethod. Generally, if you don't change the event result, yourself, you should always return the result parameter that you are given rather than justEventResult.DEFAULT.Returning
EventResult.CANCELLEDwill 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 changedevent- The actual event instance that can be checked or modified. Generally speaking, if an event has parameters that arenon-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
-