Skip to content

Prefix the magic block flag ID so it cannot collide with AOneBlock - #25

Merged
tastybento merged 1 commit into
developfrom
fix/magic-block-flag-id
Aug 10, 2026
Merged

Prefix the magic block flag ID so it cannot collide with AOneBlock#25
tastybento merged 1 commit into
developfrom
fix/magic-block-flag-id

Conversation

@tastybento

Copy link
Copy Markdown
Member

Fixes #24.

MAGIC_BLOCK is the ID AOneBlock uses too. FlagsManager.registerFlag() drops the second registration of an ID and returns false without 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_SAFETY renames 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:

  • Island flags are keyed by ID string and islands are per-world, so isAllowed() resolved correctly in both worlds.
  • SettingsTab only hides a flag when getGameModes() is non-empty; neither addon sets one, so it appeared in both panels.
  • The two definitions were identical — same icon, mode, type, COOP_RANK default.

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_BLOCKCHUNKBLOCK_MAGIC_BLOCK: flag ID, field, default-island-flags entry, and the protection.flags key 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. Addon already exposes a registerFlag() that returns the boolean; nothing was checking it, which is exactly why this went unnoticed for two releases.
  • ChunkBlockTest asserts by reflection that every Flag field on ChunkBlock carries the CHUNKBLOCK_ prefix, so a new flag cannot reintroduce this.

658 tests green.

⚠️ Breaking for admins — needs a release note

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_RANK under the new ID. The old MAGIC_BLOCK entry becomes an orphan in the island data and in config.yml's default-island-flags.

Admins should re-apply the setting, and re-set default-island-flags if they had customised it. Identical to what the 1.0.1 renames required.

🤖 Generated with Claude Code

https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp

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
@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit 86e738a into develop Aug 10, 2026
3 checks passed
@tastybento tastybento mentioned this pull request Aug 10, 2026
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.

MAGIC_BLOCK flag uses an unprefixed ID that AOneBlock also registers

1 participant