Class BlockDestroyEvent

All Implemented Interfaces:
Cancellable

public class BlockDestroyEvent extends BlockExpEvent implements Cancellable
Fired anytime the server intends to 'destroy' a block through some triggering reason. This does not fire anytime a block is set to air, but only with more direct triggers such as physics updates, pistons, Entities changing blocks, commands set to "Destroy".

This event is associated with the game playing a sound effect at the block in question, when something can be described as "intend to destroy what is there",

Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.

  • Constructor Details

  • Method Details

    • getEffectBlock

      @NotNull public @NotNull BlockData getEffectBlock()
      Get the effect that will be played when the block is broken.
      Returns:
      block break effect
    • setEffectBlock

      public void setEffectBlock(@NotNull @NotNull BlockData effectBlock)
      Sets the effect that will be played when the block is broken. Note: playEffect() must be true in order for this effect to be played.
      Parameters:
      effectBlock - block effect
    • getNewState

      @NotNull public @NotNull BlockData getNewState()
      Returns:
      The new state of this block (Air, or a Fluid type)
    • willDrop

      public boolean willDrop()
      Returns:
      If the server is going to drop the block in question with this destroy event
    • setWillDrop

      public void setWillDrop(boolean willDrop)
      Parameters:
      willDrop - If the server is going to drop the block in question with this destroy event
    • playEffect

      public boolean playEffect()
      Returns:
      If the server is going to play the sound effect for this destruction
    • setPlayEffect

      public void setPlayEffect(boolean playEffect)
      Parameters:
      playEffect - If the server should play the sound effect for this destruction
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      If the event is cancelled, meaning the block will not be destroyed
    • setCancelled

      public void setCancelled(boolean cancel)
      If the event is cancelled, the block will remain in its previous state.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Overrides:
      getHandlers in class BlockExpEvent
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()