Class EventWithCancelReason

java.lang.Object
de.craftsblock.craftscore.event.Event
de.craftsblock.craftscore.event.CancellableEvent
de.craftsblock.craftsnet.events.EventWithCancelReason
All Implemented Interfaces:
de.craftsblock.craftscore.event.Cancellable
Direct Known Subclasses:
ClientConnectEvent, RouteRequestEvent, ShareRequestEvent

public abstract class EventWithCancelReason extends de.craftsblock.craftscore.event.CancellableEvent
An abstract class extending CancellableEvent, providing the ability to set and retrieve a custom cancellation reason. It can be used by listeners to communicate why an event was canceled.
Since:
3.1.0-SNAPSHOT
See Also:
  • CancellableEvent
  • Constructor Details

    • EventWithCancelReason

      public EventWithCancelReason()
  • Method Details

    • setCancelReason

      public void setCancelReason(String cancelReason)
      Sets a custom cancel reason which is printed to the console
      Parameters:
      cancelReason - The cancel reason which is printed to the console
    • getCancelReason

      public String getCancelReason()
      Gets the custom cancel reason which was set by one of the listeners.
      Returns:
      The cancel reason
    • hasCancelReason

      public boolean hasCancelReason()
      Checks and returns whether a custom cancel reason was set by one of the listeners.
      Returns:
      true if a custom cancel reason was set, false otherwise.