Annotation Interface Subscribe


@Retention(RUNTIME) @Target(METHOD) public @interface Subscribe
An annotation that indicates that this method can be used to listen for an event from the proxy.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether the handler must be called asynchronously.
    Deprecated.
    specify the order using priority() instead
    short
    The priority of this event handler.
  • Element Details

    • order

      Deprecated.
      specify the order using priority() instead
      The order events will be posted to this listener.
      Returns:
      the order
      Default:
      NORMAL
    • priority

      short priority
      The priority of this event handler. Priorities are used to determine the order in which event handlers are called. The higher the priority, the earlier the event handler will be called.

      Note that due to compatibility constraints, you must specify PostOrder.CUSTOM in order to use this field.

      Returns:
      the priority
      Default:
      -32768
    • async

      boolean async
      Whether the handler must be called asynchronously. By default, all event handlers are called asynchronously.

      For performance (for instance, if you use EventTask.withContinuation(java.util.function.Consumer<com.velocitypowered.api.event.Continuation>)), you can optionally specify false. This option will become false by default in a future release of Velocity.

      If this is true, the method is guaranteed to be executed asynchronously. Otherwise, the handler may be executed on the current thread or asynchronously. This still means you must consider thread-safety in your event listeners as the "current thread" can and will be different each time.

      Note that if any method handler targeting an event type is marked with true, then every handler targeting that event type will be executed asynchronously.

      Returns:
      Requires async
      Default:
      true