Package de.ellpeck.rockbottom.api.event
Interface IEventHandler
public interface IEventHandler
The class for handling and firing different
Event objects that can be
used by mods to hook into the game's and other mods' functionalities. You can
receive an instance of this class by using RockBottomAPI.getEventHandler().
You can find a list of events that are fired in the normal game in the
impl sub-package.-
Method Summary
Modifier and TypeMethodDescriptionFires an event, making all of the registered listeners listen to it and, in the end, return anEventResultrepresenting if the event wasEventResult.MODIFIEDorEventResult.CANCELLED.<T extends Event>
voidregisterListener(Class<T> type, IEventListener<T> listener) Registers anIEventListenerthat will listen to a certain kind of event.voidunregisterAllListeners(Class<? extends Event> type) Unregisters allIEventListenerobjects that are listening to a certain kind of event.<T extends Event>
voidunregisterListener(Class<T> type, IEventListener<T> listener) Unregisters anIEventListenerfrom listening to a certain kind of event.
-
Method Details
-
registerListener
Registers anIEventListenerthat will listen to a certain kind of event. Doing this will cause the listener'sIEventListener.listen(EventResult, Event)method to be called whenever the event is fired.- Type Parameters:
T- A generic type representing the event that is listened to- Parameters:
type- The type of event to listen forlistener- The listener- See Also:
-
unregisterListener
Unregisters anIEventListenerfrom listening to a certain kind of event.- Type Parameters:
T- A generic type representing the event- Parameters:
type- The type of event to unregister fromlistener- The listener to unregister
-
unregisterAllListeners
Unregisters allIEventListenerobjects that are listening to a certain kind of event.- Parameters:
type- The type of event to unregister all listeners of
-
fireEvent
Fires an event, making all of the registered listeners listen to it and, in the end, return anEventResultrepresenting if the event wasEventResult.MODIFIEDorEventResult.CANCELLED. Firing events is only needed if you add your own implementations of theEventclass.- Parameters:
event- The event to fire- Returns:
- The result
- See Also:
-