Annotation Interface SubscribeEvent


@Retention(RUNTIME) @Target(METHOD) public @interface SubscribeEvent
Marks a method as an event listener for the custom EventBus system.

Methods annotated with this will be automatically registered by EventBus#register(Object) and invoked when relevant events are posted.

The method must have exactly one parameter which extends Event.

Example:

@SubscribeEvent
public void onCustomEvent(MyCustomEvent event) {
    // handle event
}

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether the event handler should be called for cancelled events.
    org.bukkit.event.EventPriority
    Defines the priority at which the event listener should be called.
  • Element Details

    • priority

      org.bukkit.event.EventPriority priority
      Defines the priority at which the event listener should be called.

      This affects the order in which listeners receive events. Listeners with higher priority are called later.

      Returns:
      the priority for the event handler
      Default:
      NORMAL
    • ignoreCancelled

      boolean ignoreCancelled
      Whether the event handler should be called for cancelled events.
      Returns:
      true to ignore cancelled events (default), false to receive them anyway
      Default:
      true