Class EventListener.Builder<T extends Event>

java.lang.Object
net.minestom.server.event.EventListener.Builder<T>
Enclosing interface:
EventListener<T extends Event>

public static class EventListener.Builder<T extends Event> extends Object
  • Constructor Details

    • Builder

      protected Builder(Class<T> eventType)
  • Method Details

    • filter

      @Contract("_ -> this") @NotNull public EventListener.Builder<T> filter(Predicate<T> filter)
      Adds a filter to the executor of this listener. The executor will only be called if this condition passes on the given event.
    • ignoreCancelled

      @Contract("_ -> this") @NotNull public EventListener.Builder<T> ignoreCancelled(boolean ignoreCancelled)
      Specifies if the handler should still be called if CancellableEvent.isCancelled() returns true.

      Default is set to true.

      Parameters:
      ignoreCancelled - True to stop processing the event when cancelled
    • expireCount

      @Contract("_ -> this") @NotNull public EventListener.Builder<T> expireCount(int expireCount)
      Removes this listener after it has been executed the given number of times.
      Parameters:
      expireCount - The number of times to execute
    • expireWhen

      @Contract("_ -> this") @NotNull public EventListener.Builder<T> expireWhen(Predicate<T> expireWhen)
      Expires this listener when it passes the given condition. The expiration will happen before the event is executed.
      Parameters:
      expireWhen - The condition to test
    • handler

      @Contract("_ -> this") @NotNull public EventListener.Builder<T> handler(Consumer<T> handler)
      Sets the handler for this event listener. This will be executed if the listener passes all conditions.
    • build

      @Contract(value="-> new", pure=true) @NotNull public @NotNull EventListener<T> build()