Package net.orbyfied.j8.event
Class EventBus
java.lang.Object
net.orbyfied.j8.event.EventBus
- Direct Known Subclasses:
ComplexEventBus
The main event system class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBakes the event; prepares it.Gets all registered listeners.getAllRegistered(Class<? extends EventListener> klass) Gets all registered listeners for the specified class.getPipelineFor(Class<?> event) Retrieves the pipeline of an event for this event bus from either the cache, theBusEvent.getPipeline(EventBus)method or thedefaultPipelineFactory.getPipelineOrNull(Class<?> event) getRegistered(Class<? extends EventListener> klass) Gets the latest registered listener with the specified class.booleanisRegistered(Class<? extends EventListener> listener) Checks if the supplied class was registered already.booleanisRegistered(EventListener listener) Checks if the listeners class was registered already.post(E event) Posts an event to the event bus.<E> EventBusPosts an event to the event bus through the pipeline supplied by the supplied class.<E> voidpostUnsafe(Class fclass, E event) Posts an event to the event bus through the pipeline supplied by the supplied class.protected <E> voidpushSafe(E event, PipelineAccess<E> acc) Safely pushes an event down the given pipeline access.register(EventListener listener) Registers a listener instance by creating aRegisteredListenerand adding it to the registrations in this event bus.unregister(RegisteredListener listener) Unregisters a registered listener.unregisterAll(Class<? extends EventListener> klass) Unregisters all registered listeners of the specified type.unregisterLast(Class<? extends EventListener> klass) Unregisters the last listener of the specified type.unregisterLast(EventListener listener) Unregisters the last listener of the listeners type.
-
Constructor Details
-
EventBus
public EventBus()
-
-
Method Details
-
register
Registers a listener instance by creating aRegisteredListenerand adding it to the registrations in this event bus.- Parameters:
listener- The listener instance.- Returns:
- The new
RegisteredListenerinstance.
-
isRegistered
Checks if the listeners class was registered already.- Parameters:
listener- The listener object.- Returns:
- True/false.
-
isRegistered
Checks if the supplied class was registered already.- Parameters:
listener- The listener object.- Returns:
- True/false.
-
getRegistered
Gets the latest registered listener with the specified class.- Parameters:
klass- The class.- Returns:
- The last registered listener.
-
getAllRegistered
Gets all registered listeners for the specified class.- Parameters:
klass- The class.- Returns:
- An unmodifiable list of listeners.
-
getAllRegistered
Gets all registered listeners.- Returns:
- An unmodifiable list of listeners.
-
unregister
Unregisters a registered listener.- Parameters:
listener- The registered listener.- Returns:
- This.
-
unregisterLast
Unregisters the last listener of the listeners type.- Parameters:
listener- The listener.- Returns:
- This.
-
unregisterLast
Unregisters the last listener of the specified type.- Parameters:
klass- The listener class.- Returns:
- This.
-
unregisterAll
Unregisters all registered listeners of the specified type.- Parameters:
klass- The type.- Returns:
- This.
-
bake
Bakes the event; prepares it. Pre-caches the pipeline for an event. This can significantly improve performance on the first call.- Parameters:
event- The event type.- Returns:
- This.
-
post
Posts an event to the event bus. Uses the events class as the pipeline provider.- Parameters:
event- The event.- Returns:
- This.
-
postUnsafe
Posts an event to the event bus through the pipeline supplied by the supplied class. NOTE: Doesn't call any events, and does not catch any errors.- Parameters:
fclass- The pipeline provider class.event- The event.
-
post
Posts an event to the event bus through the pipeline supplied by the supplied class. Calls all functional event services before posting.- Parameters:
fclass- The pipeline provider class.event- The event.- Returns:
- This.
-
pushSafe
Safely pushes an event down the given pipeline access.- Type Parameters:
E- The event type.- Parameters:
event- The event instance.acc- The pipeline access.
-
getPipelineFor
Retrieves the pipeline of an event for this event bus from either the cache, theBusEvent.getPipeline(EventBus)method or thedefaultPipelineFactory.- Parameters:
event- The event class.- Returns:
- The pipeline or null if the event type is invalid or an error occurred.
-
getPipelineOrNull
-
withDefaultPipelineFactory
-