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 Type
    Method
    Description
    fire(E event)
    Fire an event and return a future that completes when all handlers have processed it.
    <E> E
    fireSync(E event)
    Fire an event synchronously, blocking until all handlers have processed it.
    <E> void
    register(Object plugin, Class<E> eventClass, EventHandler<E> handler)
    Register a single event handler.
    <E> void
    register(Object plugin, Class<E> eventClass, EventPriority priority, EventHandler<E> handler)
    Register a single event handler with a specific priority.
    void
    register(Object plugin, Object listener)
    Register an event listener object.
    void
    unregister(Object listener)
    Unregister a specific listener object.
    void
    Unregister all listeners registered by a plugin.
  • Method Details

    • register

      void register(@Nonnull Object plugin, @Nonnull Object listener)
      Register an event listener object. All methods annotated with Subscribe will be registered as listeners.
      Parameters:
      plugin - the plugin registering the listener
      listener - the listener object
    • 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 handler
      eventClass - the event class to listen for
      handler - 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 handler
      eventClass - the event class to listen for
      priority - the priority of this handler
      handler - the handler to call when the event fires
    • unregister

      void unregister(@Nonnull Object listener)
      Unregister a specific listener object.
      Parameters:
      listener - the listener to unregister
    • unregisterAll

      void unregisterAll(@Nonnull Object plugin)
      Unregister all listeners registered by a plugin.
      Parameters:
      plugin - the plugin whose listeners should be unregistered
    • fire

      @Nonnull <E> CompletableFuture<E> fire(@Nonnull E event)
      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