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.
  • Method Details

    • ofBuilder

      @NotNull static <T extends Event> @NotNull EventListener.Builder<T> ofBuilder(@NotNull @NotNull Class<T> eventType)
      Creates a new Builder for constructing an EventListener.
      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 new EventListener instance with the specified event type and handler.
      Parameters:
      eventType - The class type of the event that the EventListener will handle.
      listener - The Consumer that will process events of the specified type.
      Returns:
      A new EventListener instance configured with the provided event type and handler.
    • eventType

      @NotNull @NotNull Class<T> eventType()
      Returns the class type of the event that this EventListener is designed to handle.
      Returns:
      The Class object representing the type of event this listener is for.
    • run

      @NotNull @NotNull EventListener.Result run(@NotNull T event)
      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.Result enumeration.