Package meteordevelopment.orbit
Class EventBus
java.lang.Object
meteordevelopment.orbit.EventBus
- All Implemented Interfaces:
IEventBus
Default implementation of
IEventBus.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisListening(Class<?> eventKlass) Returns whether at least one event listener is currently registered for this event type.<T> Tpost(T event) Posts an event to all subscribed event listeners.voidregisterLambdaFactory(String packagePrefix, LambdaListener.Factory factory) Registers a lambda factory to use with the specified package.voidFinds all correct (static only) methods withEventHandlerannotation and subscribes them.voidFinds all correct (static and non-static) methods withEventHandlerannotation and subscribes them.voidSubscribes the listener (both static and non-static).voidunsubscribe(Class<?> klass) Finds all correct (static only) methods withEventHandlerannotation and unsubscribes them.voidunsubscribe(Object object) Finds all correct (static and non-static) methods withEventHandlerannotation and unsubscribes them.voidunsubscribe(IListener listener) Unsubscribes the listener (both static and non-static).
-
Constructor Details
-
EventBus
public EventBus()
-
-
Method Details
-
registerLambdaFactory
Description copied from interface:IEventBusRegisters a lambda factory to use with the specified package.- Specified by:
registerLambdaFactoryin interfaceIEventBus- Parameters:
packagePrefix- Package prefix that this factory will be used for, eg "meteordevelopment.orbit"factory- The factory to use
-
isListening
Description copied from interface:IEventBusReturns whether at least one event listener is currently registered for this event type.- Specified by:
isListeningin interfaceIEventBus- Parameters:
eventKlass- The event type to check for registered listeners.- Returns:
- whether the event is being listened for
-
post
public <T> T post(T event) Description copied from interface:IEventBusPosts an event to all subscribed event listeners. -
post
Description copied from interface:IEventBusPosts a cancellable event to all subscribed event listeners. Stops after the event was cancelled. -
subscribe
Description copied from interface:IEventBusFinds all correct (static and non-static) methods withEventHandlerannotation and subscribes them. -
subscribe
Description copied from interface:IEventBusFinds all correct (static only) methods withEventHandlerannotation and subscribes them. -
subscribe
Description copied from interface:IEventBusSubscribes the listener (both static and non-static). -
unsubscribe
Description copied from interface:IEventBusFinds all correct (static and non-static) methods withEventHandlerannotation and unsubscribes them.- Specified by:
unsubscribein interfaceIEventBus- Parameters:
object- The object to scan for methods
-
unsubscribe
Description copied from interface:IEventBusFinds all correct (static only) methods withEventHandlerannotation and unsubscribes them.- Specified by:
unsubscribein interfaceIEventBus- Parameters:
klass- The class to scan for methods
-
unsubscribe
Description copied from interface:IEventBusUnsubscribes the listener (both static and non-static).- Specified by:
unsubscribein interfaceIEventBus- Parameters:
listener- Listener to unsubscribe
-