Class ModEventBus

java.lang.Object
net.minheur.potoflux.loader.mod.ModEventBus

public class ModEventBus extends Object
Bus for registering all listeners in potoflux.
Mods add theirs methods to the event listeners, so they can be executed on need.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <E> void
    addListener(Class<E> eventClass, Consumer<E> consumer)
    Adds a listener with an event class and a consumer of this event.
    This requires the registering mod to explicitly say which event is used.
    <E> void
    Only method references are supported (no lambda expressions).
    The listener method must take exactly one parameter.
    No inline listeners, as e -> handle(e) or e -> System.out.println()
    void
    post(IEvent event)
    This actually posts the events.
    When an event is posted, the param given to this method (the event) is then transferred to all method subscribing to the event.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModEventBus

      public ModEventBus()
  • Method Details

    • addListener

      public <E> void addListener(Class<E> eventClass, Consumer<E> consumer)
      Adds a listener with an event class and a consumer of this event.
      This requires the registering mod to explicitly say which event is used.
      Type Parameters:
      E - the type of event
      Parameters:
      eventClass - event used
      consumer - method to get called when the event is posted
    • addListener

      public <E> void addListener(EventListener<E> consumer)
      Only method references are supported (no lambda expressions).
      The listener method must take exactly one parameter.
      No inline listeners, as e -> handle(e) or e -> System.out.println()
      Type Parameters:
      E - the event linked
      Parameters:
      consumer - the consumer, in the form of this::onSomething, to invoke on the event post
    • post

      public void post(IEvent event)
      This actually posts the events.
      When an event is posted, the param given to this method (the event) is then transferred to all method subscribing to the event.
      Parameters:
      event - the posted event.