Class PlayerStartDiggingEvent

java.lang.Object
net.minestom.server.event.player.PlayerStartDiggingEvent
All Implemented Interfaces:
Event, BlockEvent, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent

public class PlayerStartDiggingEvent extends Object implements PlayerInstanceEvent, BlockEvent, CancellableEvent
Called when a Player start digging a block, can be used to forbid the Player from mining it.

Be aware that cancelling this event does not necessary prevent the player from breaking the block (could be because of high latency or a modified client) so cancelling PlayerBlockBreakEvent is also necessary. Could be fixed in future Minestom version.

  • Constructor Details

    • PlayerStartDiggingEvent

      public PlayerStartDiggingEvent(@NotNull @NotNull Player player, @NotNull @NotNull Block block, @NotNull @NotNull BlockVec blockPosition, @NotNull @NotNull BlockFace blockFace)
  • Method Details

    • getBlock

      @NotNull public @NotNull Block getBlock()
      Gets the block which is being dug.
      Specified by:
      getBlock in interface BlockEvent
      Returns:
      the block
    • getBlockPosition

      @NotNull public @NotNull BlockVec getBlockPosition()
      Gets the block position.
      Specified by:
      getBlockPosition in interface BlockEvent
      Returns:
      the block position
    • getBlockFace

      @NotNull public @NotNull BlockFace getBlockFace()
      Gets the face you are digging
      Returns:
      the block face
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: CancellableEvent
      Gets if the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: CancellableEvent
      Marks the Event as cancelled or not.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise
    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player