fix: respect actionbar/bossbar config settings in BossBarListener#538
Merged
Conversation
The BossBarListener is registered into Bukkit by BentoBox's FlagsManager whenever the ONEBLOCK_BOSSBAR or ONEBLOCK_ACTIONBAR flag is registered. With actionbar: false and bossbar: true in config.yml, the listener was still active via the boss bar flag, and tryToShowActionBar only checked the island flag - which defaults to allowed even when unregistered - so the action bar showed despite being disabled. Guard both tryToShowActionBar and tryToShowBossBar with their config settings, and remove the explicit registerListener(bossBar) call in onEnable which duplicated the FlagsManager registration and caused the handlers to fire twice per event when both settings were enabled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012eC7vj7ghNGSNGpxqQazxm
|
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.



Fixes #537
Problem
Setting
actionbar: falsein config.yml did not stop the action bar from showing.Root cause
Both the
ONEBLOCK_BOSSBARandONEBLOCK_ACTIONBARflags declareBossBarListeneras their flag listener, and BentoBox'sFlagsManager.registerFlagregisters that listener into Bukkit. So withactionbar: falseandbossbar: true, the listener was still registered via the boss bar flag.tryToShowActionBaronly checked the island flag — andisland.isAllowed()returns the flag's default (true) even when the flag was never registered — so the action bar kept showing.The same problem existed in mirror form for the boss bar (
bossbar: false+actionbar: true).Fix
tryToShowActionBarandtryToShowBossBarwith their respective config settings.registerListener(bossBar)call inonEnable: it duplicated the FlagsManager registration, so when both settings were enabled the handlers fired twice per event. (Its&&condition was also why nothing else broke when one setting was disabled — the flag path registered the listener anyway.)Tests
New
BossBarListenerTestcovering config-disabled, flag-denied, and enabled paths for both bars (5 tests). Full suite passes: 518 tests, 0 failures.🤖 Generated with Claude Code
https://claude.ai/code/session_012eC7vj7ghNGSNGpxqQazxm