Package org.teleight.teleightbots.event
Interface EventListener<T extends Event>
- Type Parameters:
T- The type of event that this EventListener is designed to handle.
public sealed interface EventListener<T extends Event>
Represents a listener for handling events of a specific type.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceEventListener.Builder<T extends Event>Builder interface for constructingEventListenerinstances.static enumEnumeration of possible results from running an event. -
Method Summary
Modifier and TypeMethodDescriptionReturns the class type of the event that thisEventListeneris designed to handle.static <T extends Event>
@NotNull EventListener<T> Creates a newEventListenerinstance with the specified event type and handler.static <T extends Event>
@NotNull EventListener.Builder<T> Creates a new Builder for constructing anEventListener.@NotNull EventListener.ResultExecutes the event handler with the given event.
-
Method Details
-
ofBuilder
@NotNull static <T extends Event> @NotNull EventListener.Builder<T> ofBuilder(@NotNull @NotNull Class<T> eventType) Creates a new Builder for constructing anEventListener.- Parameters:
eventType- The class type of the event that the EventListener will handle.- Returns:
- A new Builder instance configured for the specified event type.
-
of
@NotNull static <T extends Event> @NotNull EventListener<T> of(@NotNull @NotNull Class<T> eventType, @NotNull @NotNull Consumer<T> listener) Creates a newEventListenerinstance with the specified event type and handler.- Parameters:
eventType- The class type of the event that the EventListener will handle.listener- TheConsumerthat will process events of the specified type.- Returns:
- A new EventListener instance configured with the provided event type and handler.
-
eventType
Returns the class type of the event that thisEventListeneris designed to handle.- Returns:
- The
Classobject representing the type of event this listener is for.
-
run
Executes the event handler with the given event.- Parameters:
event- The event to be handled by the listener.- Returns:
- The result of processing the event, as defined by the
EventListener.Resultenumeration.
-