Enum Class EventResult

java.lang.Object
java.lang.Enum<EventResult>
net.ixdarklord.coolcatcore.api.event.v2.core.EventResult
All Implemented Interfaces:
Serializable, Comparable<EventResult>, Constable

public enum EventResult extends Enum<EventResult>
A result that can be returned from an event, either allowing the event to continue processing or to cancel the implementation resulting in vanilla behavior being disrupted.

Can be either used with a combination of PASS and INTERRUPT, or alternatively if three states are required with PASS, ALLOW and DENY.

For both purposes INTERRUPT and ALLOW can be used interchangeably.

Very similar to vanilla's InteractionResult.

Implementation is also remotely similar to EventResult.java from Architectury API.

  • Enum Constant Details

    • PASS

      public static final EventResult PASS
      Allows the event to continue processing. It will be passed to both other event implementations and will not prevent vanilla behavior from running.
    • INTERRUPT

      public static final EventResult INTERRUPT
      Prevents the event from processing any further and disrupts vanilla behavior, similar to cancelling an event on Forge.

      Unprocessed callbacks will be skipped if cancelled.

    • ALLOW

      public static final EventResult ALLOW
      Interrupts the event just like INTERRUPT. Useful for event implementations that require three states for their cancellation result.
    • DENY

      public static final EventResult DENY
      Interrupts the event just like INTERRUPT. Useful for event implementations that require three states for their cancellation result.
  • 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
    • getAsBoolean

      public boolean getAsBoolean()
      Returns the value for ALLOW and DENY states.

      Will throw an exception for a passing result.

      Returns:
      value for ALLOW and DENY states
    • isInterrupt

      public boolean isInterrupt()
      Returns:
      does this result prevent the vanilla behavior from running
    • isPass

      public boolean isPass()
      Returns:
      does this result allow for events to continue processing and for vanilla behavior to apply
    • pass

      public static EventResult pass()
      Returns:
      PASS
    • interrupt

      public static EventResult interrupt()
      Returns:
      INTERRUPT
    • allow

      public static EventResult allow()
      Returns:
      ALLOW
    • deny

      public static EventResult deny()
      Returns:
      DENY