Schnittstelle Cancellable

Alle bekannten Implementierungsklassen:
AddAdminEvent, ExplosionEvent, InputEvent, ItemTransformEvent, NpcAddClothesEvent, NpcAddSaddleBagEvent, NpcAddSaddleEvent, NpcDamageEvent, NpcDeathEvent, NpcHitNpcEvent, NpcRemoveClothesEvent, NpcRemoveSaddleBagEvent, NpcRemoveSaddleEvent, NpcSpawnEvent, NpcTransformEvent, PlantGrowthEvent, PlayerBanEvent, PlayerChangeBlockPositionEvent, PlayerChangeConstructionColorEvent, PlayerChangeGameModeEvent, PlayerChangeObjectColorEvent, PlayerChangeObjectInfoEvent, PlayerChangeObjectStatusEvent, PlayerChangePositionEvent, PlayerChatEvent, PlayerCommandEvent, PlayerConnectEvent, PlayerConstructionEvent, PlayerConsumeItemEvent, PlayerCraftItemEvent, PlayerCreateAreaEvent, PlayerCreateBlueprintEvent, PlayerCreativePlaceVegetationEvent, PlayerCreativeRemoveConstructionEvent, PlayerCreativeRemoveObjectEvent, PlayerCreativeRemoveVegetationEvent, PlayerCreativeTerrainEditEvent, PlayerDamageEvent, PlayerDeathEvent, PlayerDestroyConstructionEvent, PlayerDestroyObjectEvent, PlayerDestroyTerrainEvent, PlayerDestroyVegetationEvent, PlayerDismountNpcEvent, PlayerDrinkWaterEvent, PlayerDropItemEvent, PlayerDropItemFromStorageEvent, PlayerEditConstructionEvent, PlayerElementInteractionEvent, PlayerEnterAreaEvent, PlayerEnterChunkEvent, PlayerEnterSectorEvent, PlayerEnterVehicleEvent, PlayerEnterWorldPartEvent, PlayerExitVehicleEvent, PlayerGameObjectInteractionEvent, PlayerHitConstructionEvent, PlayerHitItemEvent, PlayerHitNpcEvent, PlayerHitObjectEvent, PlayerHitPlayerEvent, PlayerHitTerrainEvent, PlayerHitVegetationEvent, PlayerHitWaterEvent, PlayerInventoryAddItemEvent, PlayerInventoryItemEditEvent, PlayerInventoryMoveItemEvent, PlayerInventoryToStorageEvent, PlayerKickEvent, PlayerLeaveAreaEvent, PlayerLocationTickerEvent, PlayerMountNpcEvent, PlayerNpcInteractionEvent, PlayerNpcInventoryAccessEvent, PlayerObjectEvent, PlayerObjectInteractionEvent, PlayerPermissionGroupChangeEvent, PlayerPickupItemEvent, PlayerPlaceBlueprintEvent, PlayerPlaceConstructionEvent, PlayerPlaceGrassEvent, PlayerPlaceObjectEvent, PlayerPlaceTerrainEvent, PlayerPlaceVegetationEvent, PlayerPlaceWaterEvent, PlayerPlayerInteractionEvent, PlayerPrivateMessageEvent, PlayerProcessItemEvent, PlayerRemoveConstructionEvent, PlayerRemoveGrassEvent, PlayerRemoveObjectEvent, PlayerRemoveVegetationEvent, PlayerRemoveWaterEvent, PlayerRespawnEvent, PlayerSetSignTextEvent, PlayerStartFishingEvent, PlayerStartFlyingEvent, PlayerStopFlyingEvent, PlayerStorageAccessEvent, PlayerStorageMoveItemEvent, PlayerStorageToInventoryEvent, PlayerTeleportEvent, PlayerToggleInventoryEvent, PlayerUpdateStatusEvent, PlayerVegetationEvent, PlayerWeaponFireEvent, PlayerWeaponReloadEvent, PlayerWorldEditEvent, ProjectileFireEvent, ProjectileHitEvent, RemoveAdminEvent, ShutdownEvent, SkipNightEvent, WeatherChangeEvent

public interface Cancellable
Events that implement this interface are cancellable, i.e they can be cancelled by a plugin. Cancelling an event usually means that it will no longer be executed. Other event listeners will still receive the event, but the game won't process the action anymore. For example, when cancelling the event that the player gets damage (PlayerDamageEvent), the player actually won't get damage.

An event is considered cancelled if the setCancelled(boolean) method was called with a true parameter. Please note that another event listener may revert this again by calling the method with a false parameter.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    boolean
    Determines if the event is cancelled.
    void
    setCancelled(boolean cancel)
    Cancels this event.
  • Methodendetails

    • isCancelled

      boolean isCancelled()
      Determines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.

      Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.
      Gibt zurück:
      true if the event is cancelled, or false if not.
    • setCancelled

      void setCancelled(boolean cancel)
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Parameter:
      cancel - set to true if you want to cancel this event.
      Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
      1//Listener class
      2public class PlayerListener implements Listener{
      3 @EventMethod
      4 public void onEnterArea(PlayerEnterAreaEvent evt){
      5 //Now the player will not be able to enter the area, i.e.
      6 //he will be teleported back to his old position (outside the area)
      7 evt.setCancelled(true);
      8 }
      9}