Interface EventManager
public interface EventManager
Manages event registration and dispatching for the proxy.
Example usage:
// Register a listener
eventManager.register(plugin, new MyListener());
// Unregister all listeners for a plugin
eventManager.unregisterAll(plugin);
// Fire an event
eventManager.fire(new MyEvent()).thenAccept(event -> {
// Event has been processed by all listeners
});
-
Method Summary
Modifier and TypeMethodDescription<E> CompletableFuture<E> fire(E event) Fire an event and return a future that completes when all handlers have processed it.<E> EfireSync(E event) Fire an event synchronously, blocking until all handlers have processed it.<E> voidregister(Object plugin, Class<E> eventClass, EventHandler<E> handler) Register a single event handler.<E> voidregister(Object plugin, Class<E> eventClass, EventPriority priority, EventHandler<E> handler) Register a single event handler with a specific priority.voidRegister an event listener object.voidunregister(Object listener) Unregister a specific listener object.voidunregisterAll(Object plugin) Unregister all listeners registered by a plugin.
-
Method Details
-
register
-
register
<E> void register(@Nonnull Object plugin, @Nonnull Class<E> eventClass, @Nonnull EventHandler<E> handler) Register a single event handler.- Type Parameters:
E- the event type- Parameters:
plugin- the plugin registering the handlereventClass- the event class to listen forhandler- the handler to call when the event fires
-
register
<E> void register(@Nonnull Object plugin, @Nonnull Class<E> eventClass, @Nonnull EventPriority priority, @Nonnull EventHandler<E> handler) Register a single event handler with a specific priority.- Type Parameters:
E- the event type- Parameters:
plugin- the plugin registering the handlereventClass- the event class to listen forpriority- the priority of this handlerhandler- the handler to call when the event fires
-
unregister
Unregister a specific listener object.- Parameters:
listener- the listener to unregister
-
unregisterAll
Unregister all listeners registered by a plugin.- Parameters:
plugin- the plugin whose listeners should be unregistered
-
fire
Fire an event and return a future that completes when all handlers have processed it.- Type Parameters:
E- the event type- Parameters:
event- the event to fire- Returns:
- a future that completes with the event after all handlers have processed it
-
fireSync
@Nonnull <E> E fireSync(@Nonnull E event) Fire an event synchronously, blocking until all handlers have processed it. Use this only when you know all handlers will complete synchronously.- Type Parameters:
E- the event type- Parameters:
event- the event to fire- Returns:
- the event after all handlers have processed it
-