Interface EventBus


public interface EventBus
The LuckPerms event bus.

Used to subscribe (or "listen") to LuckPerms events.

  • Method Details

    • subscribe

      <T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler)
      Registers a new subscription to the given event.

      The returned EventSubscription instance encapsulates the subscription state. It has methods which can be used to terminate the subscription, or view stats about the nature of the subscription.

      Type Parameters:
      T - the event class
      Parameters:
      eventClass - the event class
      handler - the event handler
      Returns:
      an event handler instance representing this subscription
    • subscribe

      <T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler)
      Registers a new subscription to the given event.

      The returned EventSubscription instance encapsulates the subscription state. It has methods which can be used to terminate the subscription, or view stats about the nature of the subscription.

      Unlike subscribe(Class, Consumer), this method accepts an additional parameter for plugin. This object must be a "plugin" instance on the platform, and is used to automatically unregister the subscription when the corresponding plugin is disabled.

      Type Parameters:
      T - the event class
      Parameters:
      plugin - a plugin instance to bind the subscription to.
      eventClass - the event class
      handler - the event handler
      Returns:
      an event handler instance representing this subscription
    • getSubscriptions

      <T extends LuckPermsEvent> @NonNull @Unmodifiable Set<EventSubscription<T>> getSubscriptions(@NonNull Class<T> eventClass)
      Gets a set of all registered handlers for a given event.
      Type Parameters:
      T - the event class
      Parameters:
      eventClass - the event to find handlers for
      Returns:
      an immutable set of event handlers