Enum Class EventResult

java.lang.Object
java.lang.Enum<EventResult>
dev.polv.taleapi.event.EventResult
All Implemented Interfaces:
Serializable, Comparable<EventResult>, Constable

public enum EventResult extends Enum<EventResult>
Represents the result of an event callback execution.

Used to control event flow and cancellation behavior.

  • PASS - Continue to the next listener, no opinion on the outcome
  • SUCCESS - Stop processing and indicate success
  • CANCEL - Stop processing and cancel the event

Async Events

For async events that return CompletableFuture<EventResult>, use the convenience methods pass(), success(), and cancel() to return completed futures for synchronous handlers.

  • Enum Constant Details

    • PASS

      public static final EventResult PASS
      Continue processing the event. The listener has no opinion on the outcome.
    • SUCCESS

      public static final EventResult SUCCESS
      Stop processing and indicate the event was handled successfully. Subsequent listeners will not be called.
    • CANCEL

      public static final EventResult CANCEL
      Cancel the event. Subsequent listeners will not be called, and the action that triggered the event should be prevented.
  • Method Details

    • values

      public static EventResult[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EventResult valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • shouldStop

      public boolean shouldStop()
      Returns:
      true if this result stops further event processing
    • isCancelled

      public boolean isCancelled()
      Returns:
      true if this result indicates the event was cancelled
    • asFuture

      public CompletableFuture<EventResult> asFuture()
      Returns this result wrapped in a completed CompletableFuture.

      This is useful for async event callbacks that need to return a future but are doing synchronous processing.

      Returns:
      a completed future containing this result
    • pass

      public static CompletableFuture<EventResult> pass()
      Returns a completed future with PASS.

      Convenience method for async event handlers that want to pass synchronously.

      Returns:
      a completed future containing PASS
    • success

      public static CompletableFuture<EventResult> success()
      Returns a completed future with SUCCESS.

      Convenience method for async event handlers that want to succeed synchronously.

      Returns:
      a completed future containing SUCCESS
    • cancel

      public static CompletableFuture<EventResult> cancel()
      Returns a completed future with CANCEL.

      Convenience method for async event handlers that want to cancel synchronously.

      Returns:
      a completed future containing CANCEL