Class CancellableTownyEvent

java.lang.Object
org.bukkit.event.Event
com.palmergames.bukkit.towny.event.CancellableTownyEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable
Direct Known Subclasses:
NationAcceptAllyRequestEvent, NationDenyAllyRequestEvent, NationKingChangeEvent, NationPreAddAllyEvent, NationPreAddEnemyEvent, NationPreAddTownEvent, NationPreInviteTownEvent, NationPreMergeEvent, NationPreRemoveEnemyEvent, NationPreRenameEvent, NationPreTownKickEvent, NationPreTownLeaveEvent, NationPreTransactionEvent, NationRankAddEvent, NationRankRemoveEvent, NationRemoveAllyEvent, NationSanctionTownAddEvent, NationSanctionTownRemoveEvent, NationSetSpawnEvent, NationToggleEvent, PlotPreChangeTypeEvent, PlotPreClearEvent, PlotToggleEvent, PlotTrustAddEvent, PlotTrustRemoveEvent, PreDeleteNationEvent, PreDeleteTownEvent, PreNewNationEvent, PreNewTownEvent, PreTownPaysNationTaxEvent, ResidentPreJailEvent, ResidentToggleModeEvent, SpawnEvent, TownAddAlliedTownEvent, TownAddEnemiedTownEvent, TownAddResidentRankEvent, TownBlockPermissionChangeEvent, TownCedePlotEvent, TownIsTownOverClaimedEvent, TownKickEvent, TownLeaveEvent, TownMayorChangeEvent, TownOutlawAddEvent, TownOutlawRemoveEvent, TownPaysNationConqueredTaxEvent, TownPreAddResidentEvent, TownPreClaimEvent, TownPreInvitePlayerEvent, TownPreMergeEvent, TownPreReclaimEvent, TownPreRenameEvent, TownPreRuinedEvent, TownPreSetHomeBlockEvent, TownPreTransactionEvent, TownPreUnclaimCmdEvent, TownPreUnclaimEvent, TownRemoveAlliedTownEvent, TownRemoveEnemiedTownEvent, TownRemoveResidentRankEvent, TownSetOutpostSpawnEvent, TownSetSpawnEvent, TownToggleEvent, TownTrustAddEvent, TownTrustRemoveEvent, TownTrustTownAddEvent, TownTrustTownRemoveEvent, TownyActionEvent, TownyPreTransactionEvent

public abstract class CancellableTownyEvent extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
A class extended by Towny Events which are Cancellable and which contain a cancelMessage.

Having a getCancelMessage() available to us allows us to throw a CancelledEventException which can use the cancelMessage in feedback messaging or logging.

Used primarily in the ConfirmationBuilder.setCancellableEvent(CancellableTownyEvent) and BukkitTools.ifCancelledThenThrow(CancellableTownyEvent) code.

Since:
0.98.4.0.
Author:
LlmDL
  • Constructor Details

    • CancellableTownyEvent

      public CancellableTownyEvent()
  • Method Details

    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      true if this event is cancelled.
    • setCancelled

      public void setCancelled(boolean cancelled)
      Sets the event to be cancelled or not.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancelled - true will cancel the event.
    • getCancelMessage

      @NotNull public @NotNull String getCancelMessage()
      Returns:
      cancelMessage a String which will be displayed to the player/sender informing them that the action they commited is being denied, if cancelMessage is blank then no message will be displayed.
    • setCancelMessage

      public void setCancelMessage(@NotNull @NotNull String msg)
      Sets the cancellation message which will display to the player. Set to "" to display nothing.
      Parameters:
      msg - cancelMessage to display as feedback.