Skip to content

Fix inventory lost when returning to original island#42

Merged
tastybento merged 5 commits intomasterfrom
develop
Mar 31, 2026
Merged

Fix inventory lost when returning to original island#42
tastybento merged 5 commits intomasterfrom
develop

Conversation

@tastybento
Copy link
Copy Markdown
Member

@tastybento tastybento commented Mar 31, 2026

Summary

  • Fixes edge case where a player's inventory is lost when returning to their original island after creating a second island
  • When transitioning from single-island to multi-island mode, the world-only storage key is now proactively upgraded to an island-specific key before any save/load occurs
  • Adds Store.upgradeWorldKeyToIsland() called from PlayerListener.onIslandEnter to handle the key transition
  • Removes debug logging from PlayerListener
  • Updates CLAUDE.md with current architecture details

Test plan

  • All 77 existing tests pass
  • New testUpgradeWorldKeyToIsland test verifies key upgrade clears world data and updates currentKey
  • New testFullScenarioSingleToMultipleIslands test covers the full bug scenario end-to-end
  • Manual test: single island → create second → teleport to new → return to original → verify inventory preserved

🤖 Generated with Claude Code

tastybento and others added 5 commits March 30, 2026 13:43
Players who own multiple islands now get separate inventories per island,
preventing cross-island resource cheating. Inventories switch when
entering an owned island's protection zone, teleporting between owned
islands, or respawning on a different owned island after death. Island
inventories stay consistent across Overworld/Nether/End dimensions.
Controlled by the new options.islands config toggle (default: true).
No behavior change for games without concurrent island ownership.

Also fixes pre-existing @AfterEach (JUnit 5) annotations in tests that
should have been @after (JUnit 4), and fixes advancements being stored
under raw world name instead of the normalized storage key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the single islands boolean with a nested config that lets admins
control which aspects are switched per-island independently. Each option
(inventory, health, food, advancements, gamemode, experience, ender-chest,
statistics) can be toggled separately under options.islands. Options
default to matching the original behavior (inventory and ender-chest on,
rest off). The world-level option must also be enabled for the island
sub-option to take effect.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add per-island inventory switching (#40)
Replace JUnit 4 + mockito-inline with JUnit 5 + MockBukkit + mockito-
junit-jupiter. Switch from spigot-api to paper-api (required by
MockBukkit). Add byte-buddy explicit version for broader Java support.
Delete custom ServerMocks utility, replaced by MockBukkit.mock().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…econd island

When a player transitions from single-island to multi-island mode, their
currentKey is a world-only key (e.g., "oneblock_world"). Previously, when
entering a new island, storeInventory saved to this world-only key, and
the backward-compat migration in getInventory incorrectly gave that data
to the new island instead of preserving it for the original island.

Add Store.upgradeWorldKeyToIsland() which proactively upgrades the
currentKey to an island-specific key before any save/load occurs. Called
from PlayerListener.onIslandEnter when a world-only key is detected, this
ensures storeInventory saves to the correct island-specific key and
prevents the migration from misassigning data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tastybento tastybento merged commit 97bf247 into master Mar 31, 2026
2 checks passed
@sonarqubecloud
Copy link
Copy Markdown

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