Class BlockBreakListener

java.lang.Object
com.ranull.graves.listener.BlockBreakListener
All Implemented Interfaces:
org.bukkit.event.Listener

public class BlockBreakListener extends Object implements org.bukkit.event.Listener
Listens for BlockBreakEvent to handle interactions with grave blocks and prevent block breaking within a specified radius of a grave.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Graves
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new BlockBreakListener with the specified Graves plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    finalizeGraveBreak(org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave)
    Finalizes the process of breaking a grave by closing the grave, playing effects, and running commands.
    private void
    handleAutoLoot(org.bukkit.event.block.BlockBreakEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave, GraveBreakEvent graveBreakEvent)
    Handles the auto-loot process when breaking a grave.
    private void
    handleGraveBreak(org.bukkit.event.block.BlockBreakEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave)
    Handles the process of breaking a grave.
    private boolean
    Checks if breaking the grave is allowed based on the configuration.
    void
    onBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
    Handles BlockBreakEvent to manage interactions with grave blocks when a block is broken.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plugin

      private final Graves plugin
  • Constructor Details

    • BlockBreakListener

      public BlockBreakListener(Graves plugin)
      Constructs a new BlockBreakListener with the specified Graves plugin.
      Parameters:
      plugin - The Graves plugin instance.
  • Method Details

    • onBlockBreak

      public void onBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
      Handles BlockBreakEvent to manage interactions with grave blocks when a block is broken. Checks if the broken block is associated with a grave. If so, verifies if breaking the grave is allowed and if the player has permission to do so. If not a grave block, it checks if the block is within a 15-block radius of any grave and cancels the event if so.
      Parameters:
      event - The BlockBreakEvent to handle.
    • isGraveBreakAllowed

      private boolean isGraveBreakAllowed(Grave grave)
      Checks if breaking the grave is allowed based on the configuration.
      Parameters:
      grave - The grave to check.
      Returns:
      True if breaking the grave is allowed, false otherwise.
    • handleGraveBreak

      private void handleGraveBreak(org.bukkit.event.block.BlockBreakEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave)
      Handles the process of breaking a grave.
      Parameters:
      event - The BlockBreakEvent.
      player - The player breaking the block.
      block - The block being broken.
      grave - The grave associated with the block.
    • handleAutoLoot

      private void handleAutoLoot(org.bukkit.event.block.BlockBreakEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave, GraveBreakEvent graveBreakEvent)
      Handles the auto-loot process when breaking a grave.
      Parameters:
      event - The BlockBreakEvent.
      player - The player breaking the block.
      block - The block being broken.
      grave - The grave associated with the block.
      graveBreakEvent - The GraveBreakEvent.
    • finalizeGraveBreak

      private void finalizeGraveBreak(org.bukkit.entity.Player player, org.bukkit.block.Block block, Grave grave)
      Finalizes the process of breaking a grave by closing the grave, playing effects, and running commands.
      Parameters:
      player - The player breaking the block.
      block - The block being broken.
      grave - The grave associated with the block.