Package net.luckperms.api.event
Interface EventBus
public interface EventBus
The LuckPerms event bus.
Used to subscribe (or "listen") to LuckPerms events.
-
Method Summary
Modifier and TypeMethodDescription<T extends LuckPermsEvent>
@NonNull @Unmodifiable Set<EventSubscription<T>>getSubscriptions(@NonNull Class<T> eventClass) Gets a set of all registered handlers for a given event.<T extends LuckPermsEvent>
@NonNull EventSubscription<T>Registers a new subscription to the given event.<T extends LuckPermsEvent>
@NonNull EventSubscription<T>Registers a new subscription to the given event.
-
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
EventSubscriptioninstance 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 classhandler- 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
EventSubscriptioninstance 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 forplugin. This object must be a "plugin" instance on the platform, and is used to automaticallyunregisterthe 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 classhandler- 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
-