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 Details

    • registerListener

      <T extends Event> void registerListener(Class<T> type, IEventListener<T> listener)
      Registers an IEventListener that will listen to a certain kind of event. Doing this will cause the listener's IEventListener.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 for
      listener - The listener
      See Also:
    • unregisterListener

      <T extends Event> void unregisterListener(Class<T> type, IEventListener<T> listener)
      Unregisters an IEventListener from listening to a certain kind of event.
      Type Parameters:
      T - A generic type representing the event
      Parameters:
      type - The type of event to unregister from
      listener - The listener to unregister
    • unregisterAllListeners

      void unregisterAllListeners(Class<? extends Event> type)
      Unregisters all IEventListener objects that are listening to a certain kind of event.
      Parameters:
      type - The type of event to unregister all listeners of
    • fireEvent

      EventResult fireEvent(Event event)
      Fires an event, making all of the registered listeners listen to it and, in the end, return an EventResult representing if the event was EventResult.MODIFIED or EventResult.CANCELLED. Firing events is only needed if you add your own implementations of the Event class.
      Parameters:
      event - The event to fire
      Returns:
      The result
      See Also: