Package com.ranull.graves.listener
Class BlockBreakListener
java.lang.Object
com.ranull.graves.listener.BlockBreakListener
- All Implemented Interfaces:
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 -
Constructor Summary
ConstructorsConstructorDescriptionBlockBreakListener
(Graves plugin) Constructs a new BlockBreakListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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
isGraveBreakAllowed
(Grave grave) 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.
-
Field Details
-
plugin
-
-
Constructor Details
-
BlockBreakListener
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
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.
-