Package me.neznamy.tab.api.event
Interface EventBus
public interface EventBus
The event bus. This is used to register event listeners/handlers for
handling events that may be fired by TAB.
-
Method Summary
Modifier and TypeMethodDescription<E extends TabEvent>
voidregister(Class<E> type, EventHandler<E> handler) Registers the given handler to this event bus.voidScans the given listener for any method that is annotated withSubscribeand registers it as a listener to this event bus.voidunregister(Object listener) Scans the given listener for any method that is annotated withSubscribeand unregisters it from this event bus.<E extends TabEvent>
voidunregister(EventHandler<E> handler) Unregisters the given handler from this event bus.
-
Method Details
-
register
Scans the given listener for any method that is annotated withSubscribeand registers it as a listener to this event bus. All methods in this class that are annotated withSubscribemust meet the following criteria:- It must be public.
- It must not be abstract.
- It must have exactly one parameter.
- Its single parameter must be an event.
- Parameters:
listener- the listener to register- Throws:
RuntimeException- if a method does not meet the criteria
-
register
Registers the given handler to this event bus.- Type Parameters:
E- the type of the event- Parameters:
type- the class type of the eventhandler- the handler to register
-
unregister
Scans the given listener for any method that is annotated withSubscribeand unregisters it from this event bus.- Parameters:
listener- the listener to unregister
-
unregister
Unregisters the given handler from this event bus.- Type Parameters:
E- the type of the event- Parameters:
handler- the handler to unregister
-