Prefix the magic block flag ID so it cannot collide with AOneBlock - #25
Merged
Conversation
MAGIC_BLOCK is the ID AOneBlock uses too, and BentoBox's flags manager drops the second registration of an ID without a word — so with both gamemodes installed, whichever loaded second was quietly running on the other addon's flag definition. Nothing misbehaved yet only because the two definitions are identical and neither sets a game mode on the builder; both are coincidences. This is the same bug class as the CHUNKBLOCK_* renames in 1.0.1, missed then. Renamed to CHUNKBLOCK_MAGIC_BLOCK in the flag, the field, default-island-flags and all 18 locale files, so translations follow the key. registerFlagOrWarn() now logs when the flags manager refuses a flag, for all five flags rather than just this one — the failure was invisible, which is why it went unnoticed for two releases. Addon already has a registerFlag() that returns the boolean; it just was not being checked. ChunkBlockTest asserts by reflection that every Flag field carries the prefix, so a new flag cannot reintroduce this. Fixes #24
|
Merged
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 #24.
MAGIC_BLOCKis the ID AOneBlock uses too.FlagsManager.registerFlag()drops the second registration of an ID and returnsfalsewithout logging, so with both gamemodes installed whichever loaded second was quietly running on the other addon's flag definition.Same bug class as the
CHUNKBLOCK_BOSSBAR/CHUNKBLOCK_ACTIONBAR/CHUNKBLOCK_START_SAFETYrenames in 1.0.1 — this one was missed in that pass.Why nothing was visibly broken
Tested on a server running both addons and saw no symptom, which is worth recording because it is luck rather than design:
isAllowed()resolved correctly in both worlds.SettingsTabonly hides a flag whengetGameModes()is non-empty; neither addon sets one, so it appeared in both panels.COOP_RANKdefault.Change any one of those and the loser silently gets the wrong definition, with an admin's GUI change appearing to do nothing.
Changes
MAGIC_BLOCK→CHUNKBLOCK_MAGIC_BLOCK: flag ID, field,default-island-flagsentry, and theprotection.flagskey in all 18 locale files, so existing translations follow the rename rather than being orphaned.registerFlagOrWarn()logs when the flags manager refuses a flag — applied to all five flags, not just this one.Addonalready exposes aregisterFlag()that returns the boolean; nothing was checking it, which is exactly why this went unnoticed for two releases.ChunkBlockTestasserts by reflection that everyFlagfield onChunkBlockcarries theCHUNKBLOCK_prefix, so a new flag cannot reintroduce this.658 tests green.
Island flag settings are stored under the flag ID, so any island that changed Magic Block Protection away from the default will silently revert to
COOP_RANKunder the new ID. The oldMAGIC_BLOCKentry becomes an orphan in the island data and inconfig.yml'sdefault-island-flags.Admins should re-apply the setting, and re-set
default-island-flagsif they had customised it. Identical to what the 1.0.1 renames required.🤖 Generated with Claude Code
https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp