Annotation Interface Subscribe
Marks a method as an event handler.
The method must have exactly one parameter, which is the event type to handle. The method can be public, protected, or package-private.
public class MyListener {
@Subscribe
public void onPlayerConnect(PlayerConnectEvent event) {
// Handle event
}
@Subscribe(priority = EventPriority.EARLY)
public void onPacket(PacketEvent event) {
// Handle packet early
}
}
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether this handler should receive cancelled events.The priority of this event handler.
-
Element Details
-
priority
EventPriority priorityThe priority of this event handler. Handlers with lower priority values are called first.- Returns:
- the handler priority
- Default:
NORMAL
-
ignoreCancelled
boolean ignoreCancelledWhether this handler should receive cancelled events.- Returns:
- true to receive cancelled events
- Default:
false
-