Package com.ranull.graves.listener
Class PlayerBucketListener
java.lang.Object
com.ranull.graves.listener.PlayerBucketListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling PlayerBucketEmptyEvent and PlayerBucketFillEvent
to prevent buckets from being emptied or filled on grave blocks.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPlayerBucketListener
(Graves plugin) Constructs a PlayerBucketListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate org.bukkit.block.Block
getTargetBlock
(org.bukkit.event.player.PlayerBucketEmptyEvent event) Gets the block that the player is interacting with when emptying the bucket.private boolean
isGraveBlock
(org.bukkit.block.Block block) Checks if the block is part of a grave.void
onPlayerBucketEmpty
(org.bukkit.event.player.PlayerBucketEmptyEvent event) Handles the PlayerBucketEmptyEvent to prevent emptying buckets on grave blocks.void
onPlayerBucketFill
(org.bukkit.event.player.PlayerBucketFillEvent event) Handles the PlayerBucketFillEvent to prevent filling buckets on grave blocks.private void
preventBucketUsage
(org.bukkit.event.Event event, org.bukkit.block.Block block) Prevents the bucket from being emptied or filled on the grave block by cancelling the event and updating the block's state.
-
Field Details
-
plugin
-
-
Constructor Details
-
PlayerBucketListener
Constructs a PlayerBucketListener with the specified Graves plugin.- Parameters:
plugin
- The Graves plugin instance.
-
-
Method Details
-
onPlayerBucketEmpty
public void onPlayerBucketEmpty(org.bukkit.event.player.PlayerBucketEmptyEvent event) Handles the PlayerBucketEmptyEvent to prevent emptying buckets on grave blocks. If the block being interacted with is part of a grave, the event is cancelled and the block's state is updated to reflect the prevention of the bucket emptying.- Parameters:
event
- The PlayerBucketEmptyEvent to handle.
-
onPlayerBucketFill
public void onPlayerBucketFill(org.bukkit.event.player.PlayerBucketFillEvent event) Handles the PlayerBucketFillEvent to prevent filling buckets on grave blocks. If the block being interacted with is part of a grave, the event is cancelled and the block's state is updated to reflect the prevention of the bucket filling.- Parameters:
event
- The PlayerBucketFillEvent to handle.
-
getTargetBlock
private org.bukkit.block.Block getTargetBlock(org.bukkit.event.player.PlayerBucketEmptyEvent event) Gets the block that the player is interacting with when emptying the bucket.- Parameters:
event
- The PlayerBucketEmptyEvent.- Returns:
- The block being interacted with.
-
isGraveBlock
private boolean isGraveBlock(org.bukkit.block.Block block) Checks if the block is part of a grave.- Parameters:
block
- The block to check.- Returns:
- True if the block is part of a grave, false otherwise.
-
preventBucketUsage
private void preventBucketUsage(org.bukkit.event.Event event, org.bukkit.block.Block block) Prevents the bucket from being emptied or filled on the grave block by cancelling the event and updating the block's state.- Parameters:
event
- The event to cancel.block
- The block being interacted with.
-