Class EventHandler<T extends SkoiceEvent>

java.lang.Object
net.clementraynaud.skoice.common.EventHandler<T>
Type Parameters:
T - the event type this handler is subscribed to

public class EventHandler<T extends SkoiceEvent> extends Object
Represents a subscription to a specific event type.

This class is returned when subscribing to an event via EventBus.subscribe(Class, java.util.function.Consumer). It allows you to unsubscribe from the event and check if the subscription is still active.

Example usage:

EventHandler<PlayerProximityConnectEvent> handler = eventBus.subscribe(
    PlayerProximityConnectEvent.class,
    event -> {
        // Handle event
    }
);

// Later, when you want to stop listening:
handler.unsubscribe();
See Also:
  • Method Details

    • unsubscribe

      public void unsubscribe()
      Unsubscribes this handler from the event bus.

      After calling this method, the handler will no longer receive events. This method is idempotent - calling it multiple times has no additional effect.

    • isActive

      public boolean isActive()
      Checks if this handler is still actively subscribed.
      Returns:
      true if this handler is active and will receive events, false if it has been unsubscribed