fix: buckets bypassing Disable-Other-Break - #66
Open
MrNickax wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Disable-Other-Break: truedoes 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
PlayerBucketFillEventand removes the source block directly — noBlockBreakEventis ever fired.RegenerationListeneronly listens toBlockBreakEvent,PlayerInteractEvent(trampling) andPlayerHarvestBlockEvent, so the bucket path never reachesRegenerationEventHandlerand none of the protection checks run.Reproduce
Use-Regions: true,Disable-Other-Break: true.WATER.block-break: allow(so WorldGuard does not deny it itself).Fix
RegenerationEventType.BUCKET_FILL.RegenerationListenernow handlesPlayerBucketFillEventand routes it throughRegenerationEventHandlerlike any other break, so bypass, data check, world/region scope,blockregen.region/blockregen.blockpermissions andDisable-Other-Breakall apply.checkProtectiontreatsBUCKET_FILLlikeBLOCK_BREAKfor WorldGuard and Residence, so those plugins keep handling the blocks they protect.Disable-Other-BreakinSettings.yml.Notes
PlayerBucketFillEventandgetBlockClicked()exist across every supported API version, so this needed no version module.Disable-Other-Breakisfalse, outside enabled worlds/regions, and for players with bypass.PlayerBucketEmptyEvent(placing liquids) is intentionally left alone — that is placing, not breaking.