Interface LifecycleEventManager<O extends LifecycleEventOwner>
- Type Parameters:
O
- the owning type,Plugin
orBootstrapContext
Manages a plugin's lifecycle events. Can be obtained
from
Plugin
or BootstrapContext
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
registerEventHandler
(@NotNull LifecycleEventHandlerConfiguration<? super O> handlerConfiguration) Registers an event handler configuration.default <E extends LifecycleEvent>
voidregisterEventHandler
(@NotNull LifecycleEventType<? super O, ? extends E, ?> eventType, @NotNull LifecycleEventHandler<? super E> eventHandler) Registers an event handler for a specific event type.
-
Method Details
-
registerEventHandler
default <E extends LifecycleEvent> void registerEventHandler(@NotNull @NotNull LifecycleEventType<? super O, ? extends E, ?> eventType, @NotNull @NotNull 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 theLifecycleEventHandler
.
is equivalent toLifecycleEventHandler<RegistrarEvent<Commands>> handler = new Handler(); manager.registerEventHandler(LifecycleEvents.COMMANDS, handler);
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 toeventHandler
- the handler for that event
-
registerEventHandler
void registerEventHandler(@NotNull @NotNull 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 byLifecycleEventType.newHandler(LifecycleEventHandler)
.- Parameters:
handlerConfiguration
- the handler configuration to register
-