Package net.minheur.potoflux.loader.mod
Class ModEventBus
java.lang.Object
net.minheur.potoflux.loader.mod.ModEventBus
Bus for registering all listeners in potoflux.
Mods add theirs methods to the event listeners, so they can be executed on need.
Mods add theirs methods to the event listeners, so they can be executed on need.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E> voidaddListener(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> voidaddListener(EventListener<E> consumer) Only method references are supported (no lambda expressions).
The listener method must take exactly one parameter.
No inline listeners, ase -> handle(e)ore -> System.out.println()voidThis 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.
-
Constructor Details
-
ModEventBus
public ModEventBus()
-
-
Method Details
-
addListener
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 usedconsumer- method to get called when the event is posted
-
addListener
Only method references are supported (no lambda expressions).
The listener method must take exactly one parameter.
No inline listeners, ase -> handle(e)ore -> System.out.println()- Type Parameters:
E- the event linked- Parameters:
consumer- the consumer, in the form ofthis::onSomething, to invoke on the event post
-
post
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.
-