fix: cancel denied magic-block break early to stop Jobs reward exploit (#534)#535
Merged
Merged
Conversation
#534) Jobs Reborn awards block-break rewards from a BlockBreakEvent handler at EventPriority.HIGHEST with ignoreCancelled=true. AOneBlock also only checked the MAGIC_BLOCK protection flag (and cancelled the break) at HIGHEST. Within a single priority slot, Bukkit fires handlers in plugin-registration order, which is nondeterministic. When Jobs ran before AOneBlock, it paid out before the break was cancelled; since the magic block respawns on a cancelled break, a player lacking the MAGIC_BLOCK flag could mine it endlessly for infinite rewards. Add a dedicated onBlockBreakDeny handler at EventPriority.LOWEST that runs the MAGIC_BLOCK flag check (which cancels the event on denial). Cancelling at LOWEST is strictly before any later ignoreCancelled=true handler, so reward plugins are skipped for denied breaks. Full magic-block processing stays at HIGHEST, and allowed breaks are unaffected. Bump version to 1.25.2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nxjWg93etdoy6U6nhTXRX
…d S8924) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nxjWg93etdoy6U6nhTXRX
|
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
Fixes #534 — Jobs Reborn awards infinite rewards when a player mines the magic block on an island where the
MAGIC_BLOCKflag denies them, despite general block-breaking being allowed.Root cause
An event-priority race:
JobsPaymentListener) pays out from itsBlockBreakEventhandler at@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true).BlockListener.onBlockBreak) also ran atHIGHEST, ignoreCancelled = true, and only there did it callcheckIsland(...MAGIC_BLOCK), whose deny path cancels the break.ignoreCancelled = truemeans "skip me if the event is already cancelled." Within a single priority slot, Bukkit fires handlers in plugin-registration order, which is nondeterministic across setups. When Jobs'HIGHESThandler ran before AOneBlock's, the event wasn't cancelled yet, so Jobs paid the reward. AOneBlock then cancelled the break — and since the magic block respawns on a cancelled break, a player lacking theMAGIC_BLOCKflag could mine it endlessly for infinite Jobs money.Fix
Add a dedicated early-deny handler that performs the
MAGIC_BLOCKflag check atEventPriority.LOWEST:Cancelling at
LOWESTis strictly before any laterignoreCancelled = truehandler, so Jobs'HIGHESThandler is guaranteed to be skipped for a denied break — no reward is granted. Full magic-block processing stays atHIGHEST(other protection plugins still get their say for legitimate breaks), and allowed breaks are unaffected.Caveat
This closes the exploit for plugins that respect cancellation (Jobs does, via
ignoreCancelled = true). A plugin that pays out atLOWESTor ignores cancellation entirely couldn't be stopped this way, but Jobs specifically is now handled.Tests
Added 5 regression tests to
BlockListenerTest2:LOWEST/ignoreCancelled = true(the crux of the fix)Full
BlockListener*/BlockProtectsuites: 65 tests, 0 failures.Version
Bumped to 1.25.2 (bug-fix release).
🤖 Generated with Claude Code