Package dev.polv.taleapi.event
Enum Class EventResult
- All Implemented Interfaces:
Serializable,Comparable<EventResult>,Constable
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 outcomeSUCCESS- Stop processing and indicate successCANCEL- 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionasFuture()Returns this result wrapped in a completedCompletableFuture.static CompletableFuture<EventResult>cancel()Returns a completed future withCANCEL.booleanstatic CompletableFuture<EventResult>pass()Returns a completed future withPASS.booleanstatic CompletableFuture<EventResult>success()Returns a completed future withSUCCESS.static EventResultReturns the enum constant of this class with the specified name.static EventResult[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PASS
Continue processing the event. The listener has no opinion on the outcome. -
SUCCESS
Stop processing and indicate the event was handled successfully. Subsequent listeners will not be called. -
CANCEL
Cancel the event. Subsequent listeners will not be called, and the action that triggered the event should be prevented.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
shouldStop
public boolean shouldStop()- Returns:
trueif this result stops further event processing
-
isCancelled
public boolean isCancelled()- Returns:
trueif this result indicates the event was cancelled
-
asFuture
Returns this result wrapped in a completedCompletableFuture.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
Returns a completed future withPASS.Convenience method for async event handlers that want to pass synchronously.
- Returns:
- a completed future containing PASS
-
success
Returns a completed future withSUCCESS.Convenience method for async event handlers that want to succeed synchronously.
- Returns:
- a completed future containing SUCCESS
-
cancel
Returns a completed future withCANCEL.Convenience method for async event handlers that want to cancel synchronously.
- Returns:
- a completed future containing CANCEL
-