Skip to content

Fix TeamListener corrupting range on other game modes' islands#11

Merged
tastybento merged 1 commit into
developfrom
fix/teamlistener-corrupts-other-gamemode-islands
May 19, 2026
Merged

Fix TeamListener corrupting range on other game modes' islands#11
tastybento merged 1 commit into
developfrom
fix/teamlistener-corrupts-other-gamemode-islands

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

  • TeamListener.onTeamKick and onTeamLeave had inverted boolean logic — they invoked resize() whenever the affected island was not in StrangerRealms' world, so a /<gamemode> team kick or team leave on any island anywhere on the server would fire StrangerRealms' resize against the wrong addon's data.
  • resize() then called Island.setRange(stranger.islandDistance + stranger.memberBonus * (members - 1)) — with defaults 32 + 32*1 = 64 — directly mutating the range field of e.g. AOneBlock / BSkyBlock / Boxed islands.
  • On the next server restart, IslandsManager.loadIsland rejects those islands (range 64 != distance 400) and BentoBox panic-disables with Island distance mismatch.

Fix: invert the conditions in onTeamKick and onTeamLeave to early-return when the island isn't in StrangerRealms' world (matching the pattern already used in onTeamJoin), plus add a defensive guard at the top of resize() so any future listener bug can't reintroduce the same corruption.

Diagnostic trace

From a server running BentoBox 3.16.1 with diagnostic logging on Island.setProtectionRange:

[09:02:55] [Island ctor] world=oneblock_world range=400 protectionRange=50 addon=AOneBlock     ← island created correctly
[09:04:39] pmwq issued server command: /ob team kick test                                        ← TeamKickEvent fires
[09:04:39] [setProtectionRange] island=AOneBlock4449d5f0-… world=oneblock_world
           range=64 old=50 new=64
           by=world.bentobox.stranger.listeners.TeamListener.resize:99                           ← StrangerRealms corrupts the range

The same fingerprint reproduced for BSkyBlock and Boxed islands on the same server.

Test plan

  • mvn test -Dtest=TeamListenerTest — 3/3 green, covers:
    • onTeamKick on a non-StrangerRealms island never calls setRange/setProtectionRange
    • onTeamLeave on a non-StrangerRealms island never calls setRange/setProtectionRange
    • onTeamKick with memberBonus == 0 early-returns even in StrangerRealms' own world
  • Full suite (mvn test) — 173 tests pass

Companion work

A separate PR will land in BentoBox core to harden Island.setRange so it refuses to mutate the range of game modes that have isEnforceEqualRanges() == true to a value that doesn't match the configured distance-between-islands. That belt-and-suspenders fix means even if a third-party addon repeats this mistake in the future, it won't be able to corrupt the database.

Recovery for affected servers

Existing corrupted islands stored with range: 64 will still crash on load. Either:

  • Edit plugins/BentoBox/database/Island/*.json and set range back to the gamemode's configured distance-between-islands (e.g. 400 for AOneBlock / BSkyBlock, 320 for Boxed), or
  • Delete the offending island JSON files if losing them is acceptable.

🤖 Generated with Claude Code

onTeamKick and onTeamLeave had inverted boolean logic: they called
resize() whenever the kicked/leaving island was NOT in StrangerRealms'
own world, so any /<gamemode> team kick or leave on the server would
fire resize() on the wrong addon's island. resize() then called
Island.setRange() with StrangerRealms' configured distance (typically
64 with defaults: 32 + 32*(members-1)), overwriting the range field of
e.g. AOneBlock, BSkyBlock, Boxed islands. On the next server restart
IslandsManager.load() refused to load those islands because range no
longer matched the configured distance-between-islands and BentoBox
panic-disabled with "Island distance mismatch".

Invert the conditions to early-return when the island isn't in
StrangerRealms' world (matching the pattern already used in
onTeamJoin) and add a defensive guard at the top of resize() so any
future listener bug can't reintroduce the same corruption.

Includes a TeamListenerTest regression suite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tastybento tastybento merged commit 18b96d4 into develop May 19, 2026
1 check failed
@tastybento tastybento deleted the fix/teamlistener-corrupts-other-gamemode-islands branch May 19, 2026 14:44
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.

1 participant