The JeakBot framework is built around events. Events can be fired by anyone and received by any compatible registered listener.
They are used to establish a loose flow of data from event emitters to listeners.
Listeners are instances of classes that have at least one matching method annotated with
A listener method has the following signature:
void <name>(<? extends IEvent> event);
Voidreturn type (no return value)
- One argument of type
IEventor a subinterface
When a listener is registered, these methods will be the ones receiving the event.
To register a listener, call
IEventService#registerListener(Object listener) from anywhere in your code.
You can register multiple listeners by using the convenience method
Plugin instances are automatically registered as a listener!
The event service decides what methods will be called based on their parameter type.
If the event type is compatible with the parameter type (as defined by
Class#isAssignableFrom), the method will be called.
That means that a
IPreConnectEvent will be received by listeners on
IPreConnectEvent as-well as listeners on
IBotStateEvent (as they are less specific and compatible) and so on.
Updated about 4 years ago