Interface LifecycleEventManager<O extends LifecycleEventOwner>

Type Parameters:
O - the owning type, Plugin or BootstrapContext

@Experimental @NullMarked @NonExtendable public interface LifecycleEventManager<O extends LifecycleEventOwner>
Manages a plugin's lifecycle events. Can be obtained from Plugin or BootstrapContext.
  • Method Details

    • registerEventHandler

      default <E extends LifecycleEvent> void registerEventHandler(LifecycleEventType<? super O,? extends E,?> eventType, LifecycleEventHandler<? super E> eventHandler)
      Registers an event handler for a specific event type.

      This is shorthand for creating a new LifecycleEventHandlerConfiguration and just passing in the LifecycleEventHandler.

      
       LifecycleEventHandler<RegistrarEvent<Commands>> handler = new Handler();
       manager.registerEventHandler(LifecycleEvents.COMMANDS, handler);
       
      is equivalent to
      
       LifecycleEventHandler<RegistrarEvent<Commands>> handler = new Handler();
       manager.registerEventHandler(LifecycleEvents.COMMANDS.newHandler(handler));
       
      Type Parameters:
      E - the type of the event object
      Parameters:
      eventType - the event type to listen to
      eventHandler - the handler for that event
    • registerEventHandler

      void registerEventHandler(LifecycleEventHandlerConfiguration<? super O> handlerConfiguration)
      Registers an event handler configuration.

      Configurations are created via LifecycleEventType.newHandler(LifecycleEventHandler). Event types may have different configurations options available on the builder-like object returned by LifecycleEventType.newHandler(LifecycleEventHandler).

      Parameters:
      handlerConfiguration - the handler configuration to register