Skip to content

Fix my_island_* placeholders resolving to team island when player is visiting as member#519

Draft
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-my-island-lifetime-count
Draft

Fix my_island_* placeholders resolving to team island when player is visiting as member#519
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-my-island-lifetime-count

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

With disallow-team-member-islands: false, all my_island_* placeholders (phase, count, lifetime, etc.) incorrectly returned data for whichever island the player was standing on, rather than the island they own.

Root cause: getUsersIsland() called getIslands(world, user) (returns all associated islands, including team ones) and only swapped i when exactly 1 owned island was found. With 0 owned islands, the fallback silently returned the non-owned i — the team island.

Fix — AOneBlockPlaceholders.java

  • Replace the getIslands() + stream().filter(owner == uuid) fallback with getOwnedIslands(world, user), a dedicated BentoBox API that returns only islands the user owns:
// Before — falls back to team island when ownedIslands.size() != 1
List<Island> ownedIslands = addon.getIslands().getIslands(addon.getOverWorld(), user).stream()
        .filter(is -> user.getUniqueId().equals(is.getOwner())).toList();
if (ownedIslands.size() == 1) {
    i = ownedIslands.getFirst();
}
return Optional.ofNullable(i); // bug: i may still be the team island

// After — explicitly owner-only, no fallback to team island
return addon.getIslands().getOwnedIslands(addon.getOverWorld(), user).stream().findFirst();

Tests — PlaceholdersManagerTest.java

  • Added testGetLifetime and testGetLifetimeByLocation
  • Added testGetLifetimeTeamMember: player whose primary island (via getIsland) is a team island they're visiting still gets their own island's lifetime count via getOwnedIslands

…members

When a player is a team member on another island (with disallow-team-member-islands: false),
all my_island_* placeholders were falling back to the team island's data instead of the
player's owned island. This was caused by getUsersIsland() returning the non-owned island
when the fallback path found 0 or 2+ owned islands via getIslands().

Fix: Replace the getIslands()+filter pattern with getOwnedIslands() which explicitly
returns only islands owned by the user, never team islands.

Add tests for getLifetime(), getLifetimeByLocation(), and the team member scenario.

Agent-Logs-Url: https://github.com/BentoBoxWorld/AOneBlock/sessions/9af3761e-c776-489c-95f0-54e58e03b85e

Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix %aoneblock_my_island_lifetime_count% to return player's own island count Fix my_island_* placeholders resolving to team island when player is visiting as member May 5, 2026
Copilot AI requested a review from tastybento May 5, 2026 15:16
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.

%aoneblock_my_island_lifetime_count% returns visited island's count when player is a team member elsewhere

2 participants