Skip to content

fix: buckets bypassing Disable-Other-Break - #66

Open
MrNickax wants to merge 1 commit into
Wertik:masterfrom
MrNickax:fix/bucket-fill-disable-other-break
Open

fix: buckets bypassing Disable-Other-Break#66
MrNickax wants to merge 1 commit into
Wertik:masterfrom
MrNickax:fix/bucket-fill-disable-other-break

Conversation

@MrNickax

Copy link
Copy Markdown

Problem

Disable-Other-Break: true does not protect liquids. Players can still drain water and lava out of protected worlds/regions by picking the source block up with a bucket.

Picking up a liquid fires PlayerBucketFillEvent and removes the source block directly — no BlockBreakEvent is ever fired. RegenerationListener only listens to BlockBreakEvent, PlayerInteractEvent (trampling) and PlayerHarvestBlockEvent, so the bucket path never reaches RegenerationEventHandler and none of the protection checks run.

Reproduce

  1. Use-Regions: true, Disable-Other-Break: true.
  2. Create a BlockRegen region containing water, with no preset configured for WATER.
  3. Overlap it with a WorldGuard region that has block-break: allow (so WorldGuard does not deny it itself).
  4. Break a stone block inside the region → correctly denied.
  5. Right-click the water with an empty bucket → the source block is removed.

Fix

  • New RegenerationEventType.BUCKET_FILL.
  • RegenerationListener now handles PlayerBucketFillEvent and routes it through RegenerationEventHandler like any other break, so bypass, data check, world/region scope, blockregen.region / blockregen.block permissions and Disable-Other-Break all apply.
  • checkProtection treats BUCKET_FILL like BLOCK_BREAK for WorldGuard and Residence, so those plugins keep handling the blocks they protect.
  • Bucket fills are protected but never regenerated: the server clears the source block after the event, which would fight with a regeneration process. When a preset does exist for the liquid, the handler returns early and leaves the fill to vanilla.
  • Documented the liquid case on Disable-Other-Break in Settings.yml.

Notes

  • PlayerBucketFillEvent and getBlockClicked() exist across every supported API version, so this needed no version module.
  • Behaviour is unchanged when Disable-Other-Break is false, outside enabled worlds/regions, and for players with bypass.
  • PlayerBucketEmptyEvent (placing liquids) is intentionally left alone — that is placing, not breaking.

Picking up a liquid with a bucket removes the source block through
PlayerBucketFillEvent, which never fires a BlockBreakEvent. BlockRegen
only listened to block breaks, so water and lava could be drained out of
protected worlds/regions even with Disable-Other-Break set to true.

Route PlayerBucketFillEvent through the regeneration event handler with a
new BUCKET_FILL event type. Bucket fills are protected the same way block
breaks are (WorldGuard and Residence checks included), but blocks removed
this way are never regenerated - the server clears the source block after
the event, which would fight with the regeneration process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant