-
Notifications
You must be signed in to change notification settings - Fork 2
How to create an event
Nurio Fernández edited this page Sep 3, 2020
·
1 revision
With the ReflectedEventHandler library, events are class instances.
You can create an event just by creating a normal java bean. The unique difference is that you need to extends me.nurio.events.handler.Event
.
That class will mark the bean as an event, and allow the EventManager to identify it as an event.
class MessageSendEvent extends Event {
private User sender;
private String message;
public MessageSendEvent(User sender, String message) {
this.sender = sender;
this.message = message;
}
public User getSender() {
return sender;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
This event will allow event listeners to change message, get the sender but not modify who has sent the message.