public class EventBus extends java.lang.Object implements IEventExceptionHandler, IEventBus
コンストラクタと説明 |
---|
EventBus(BusBuilder busBuilder) |
修飾子とタイプ | メソッドと説明 |
---|---|
<T extends GenericEvent<? extends F>,F> |
addGenericListener(java.lang.Class<F> genericClassFilter,
java.util.function.Consumer<T> consumer)
Add a consumer listener for a
GenericEvent subclass, filtered to only be called for the specified
filter Class . |
<T extends GenericEvent<? extends F>,F> |
addGenericListener(java.lang.Class<F> genericClassFilter,
EventPriority priority,
boolean receiveCancelled,
java.lang.Class<T> eventType,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and potentially cancelled events,
for a GenericEvent subclass, filtered to only be called for the specified
filter Class . |
<T extends GenericEvent<? extends F>,F> |
addGenericListener(java.lang.Class<F> genericClassFilter,
EventPriority priority,
boolean receiveCancelled,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and potentially cancelled events,
for a GenericEvent subclass, filtered to only be called for the specified
filter Class . |
<T extends GenericEvent<? extends F>,F> |
addGenericListener(java.lang.Class<F> genericClassFilter,
EventPriority priority,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and not receiving cancelled events,
for a GenericEvent subclass, filtered to only be called for the specified
filter Class . |
<T extends Event> |
addListener(java.util.function.Consumer<T> consumer)
Add a consumer listener with default
EventPriority.NORMAL and not recieving cancelled events. |
<T extends Event> |
addListener(EventPriority priority,
boolean receiveCancelled,
java.lang.Class<T> eventType,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and potentially cancelled events. |
<T extends Event> |
addListener(EventPriority priority,
boolean receiveCancelled,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and potentially cancelled events. |
<T extends Event> |
addListener(EventPriority priority,
java.util.function.Consumer<T> consumer)
Add a consumer listener with the specified
EventPriority and not receiving cancelled events. |
void |
handleException(IEventBus bus,
Event event,
IEventListener[] listeners,
int index,
java.lang.Throwable throwable)
Fired when a EventListener throws an exception for the specified event on the event bus.
|
boolean |
post(Event event)
Submit the event for dispatch to appropriate listeners
|
void |
register(java.lang.Object target)
Register an instance object or a Class, and add listeners for all
SubscribeEvent annotated methods
found there. |
void |
shutdown()
Shuts down this event bus.
|
void |
start() |
void |
unregister(java.lang.Object object)
Unregister the supplied listener from this EventBus.
|
public EventBus(BusBuilder busBuilder)
public void register(java.lang.Object target)
IEventBus
SubscribeEvent
annotated methods
found there.
Depending on what is passed as an argument, different listener creation behaviour is performed.
SubscribeEvent
and creates listeners for
each method found.SubscribeEvent
and creates listeners for
each method found.public <T extends Event> void addListener(java.util.function.Consumer<T> consumer)
IEventBus
EventPriority.NORMAL
and not recieving cancelled events.addListener
インタフェース内 IEventBus
T
- The Event
subclass to listen forconsumer
- Callback to invoke when a matching event is receivedpublic <T extends Event> void addListener(EventPriority priority, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and not receiving cancelled events.addListener
インタフェース内 IEventBus
T
- The Event
subclass to listen forpriority
- EventPriority
for this listenerconsumer
- Callback to invoke when a matching event is receivedpublic <T extends Event> void addListener(EventPriority priority, boolean receiveCancelled, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and potentially cancelled events.addListener
インタフェース内 IEventBus
T
- The Event
subclass to listen forpriority
- EventPriority
for this listenerreceiveCancelled
- Indicate if this listener should receive events that have been Cancelable
cancelledconsumer
- Callback to invoke when a matching event is receivedpublic <T extends Event> void addListener(EventPriority priority, boolean receiveCancelled, java.lang.Class<T> eventType, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and potentially cancelled events.
Use this method when one of the other methods fails to determine the concrete Event
subclass that is
intended to be subscribed to.addListener
インタフェース内 IEventBus
T
- The Event
subclass to listen forpriority
- EventPriority
for this listenerreceiveCancelled
- Indicate if this listener should receive events that have been Cancelable
cancelledeventType
- The concrete Event
subclass to subscribe toconsumer
- Callback to invoke when a matching event is receivedpublic <T extends GenericEvent<? extends F>,F> void addGenericListener(java.lang.Class<F> genericClassFilter, java.util.function.Consumer<T> consumer)
IEventBus
GenericEvent
subclass, filtered to only be called for the specified
filter Class
.addGenericListener
インタフェース内 IEventBus
T
- The GenericEvent
subclass to listen forF
- The Class
to filter the GenericEvent
forgenericClassFilter
- A Class
which the GenericEvent
should be filtered forconsumer
- Callback to invoke when a matching event is receivedpublic <T extends GenericEvent<? extends F>,F> void addGenericListener(java.lang.Class<F> genericClassFilter, EventPriority priority, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and not receiving cancelled events,
for a GenericEvent
subclass, filtered to only be called for the specified
filter Class
.addGenericListener
インタフェース内 IEventBus
T
- The GenericEvent
subclass to listen forF
- The Class
to filter the GenericEvent
forgenericClassFilter
- A Class
which the GenericEvent
should be filtered forpriority
- EventPriority
for this listenerconsumer
- Callback to invoke when a matching event is receivedpublic <T extends GenericEvent<? extends F>,F> void addGenericListener(java.lang.Class<F> genericClassFilter, EventPriority priority, boolean receiveCancelled, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and potentially cancelled events,
for a GenericEvent
subclass, filtered to only be called for the specified
filter Class
.addGenericListener
インタフェース内 IEventBus
T
- The GenericEvent
subclass to listen forF
- The Class
to filter the GenericEvent
forgenericClassFilter
- A Class
which the GenericEvent
should be filtered forpriority
- EventPriority
for this listenerreceiveCancelled
- Indicate if this listener should receive events that have been Cancelable
cancelledconsumer
- Callback to invoke when a matching event is receivedpublic <T extends GenericEvent<? extends F>,F> void addGenericListener(java.lang.Class<F> genericClassFilter, EventPriority priority, boolean receiveCancelled, java.lang.Class<T> eventType, java.util.function.Consumer<T> consumer)
IEventBus
EventPriority
and potentially cancelled events,
for a GenericEvent
subclass, filtered to only be called for the specified
filter Class
.
Use this method when one of the other methods fails to determine the concrete GenericEvent
subclass that is
intended to be subscribed to.addGenericListener
インタフェース内 IEventBus
T
- The GenericEvent
subclass to listen forF
- The Class
to filter the GenericEvent
forgenericClassFilter
- A Class
which the GenericEvent
should be filtered forpriority
- EventPriority
for this listenerreceiveCancelled
- Indicate if this listener should receive events that have been Cancelable
cancelledeventType
- The concrete GenericEvent
subclass to subscribe toconsumer
- Callback to invoke when a matching event is receivedpublic void unregister(java.lang.Object object)
IEventBus
unregister
インタフェース内 IEventBus
object
- The object, Class
or Consumer
to unsubscribe.public boolean post(Event event)
IEventBus
post
インタフェース内 IEventBus
event
- The event to dispatch to listenersCancelable
cancelledpublic void handleException(IEventBus bus, Event event, IEventListener[] listeners, int index, java.lang.Throwable throwable)
IEventExceptionHandler
handleException
インタフェース内 IEventExceptionHandler
bus
- The bus the event is being fired onevent
- The event that is being firedlisteners
- All listeners that are listening for this event, in orderindex
- Index for the current listener being fired.throwable
- The throwable being thrownpublic void shutdown()
IEventBus
IEventBus.post(Event)
will be a no op after this method has been invoked