Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #2279 on-island placeholder for nether and end #2280

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ public enum GameModePlaceholder {
* Returns whether this player is on his island and has a rank greater than VISITOR_RANK
* @since 1.13.0
*/
ON_ISLAND("on_island", (addon, user, island) -> String.valueOf(addon.getIslands().userIsOnIsland(addon.getOverWorld(), user))),
ON_ISLAND("on_island",
(addon, user,
island) -> String.valueOf(addon.getIslands().userIsOnIsland(addon.getOverWorld(), user)
|| addon.getIslands().userIsOnIsland(addon.getNetherWorld(), user)
|| addon.getIslands().userIsOnIsland(addon.getEndWorld(), user))),
/**
* Returns whether this player is an owner of their island
* @since 1.14.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Optional;
Expand Down Expand Up @@ -168,6 +169,40 @@ public void testGetReplacerPlayer() {
assertEquals("0", GameModePlaceholder.RESETS_LEFT.getReplacer().onReplace(addon, user, island));
}

/**
* Test method for {@link world.bentobox.bentobox.lists.GameModePlaceholder#getReplacer()}.
*/
@Test
public void testGetReplacerPlayerOnIsland() {
@Nullable
World netherWorld = mock(World.class);
when(addon.getNetherWorld()).thenReturn(netherWorld);
@Nullable
World endWorld = mock(World.class);
when(addon.getEndWorld()).thenReturn(endWorld);
// Not on island
when(im.userIsOnIsland(world, user)).thenReturn(false);
when(im.userIsOnIsland(netherWorld, user)).thenReturn(false);
when(im.userIsOnIsland(endWorld, user)).thenReturn(false);
assertEquals("false", GameModePlaceholder.ON_ISLAND.getReplacer().onReplace(addon, user, island));
// Put player on island
when(im.userIsOnIsland(world, user)).thenReturn(true);
when(im.userIsOnIsland(netherWorld, user)).thenReturn(false);
when(im.userIsOnIsland(endWorld, user)).thenReturn(false);
assertEquals("true", GameModePlaceholder.ON_ISLAND.getReplacer().onReplace(addon, user, island));
// Nether
when(im.userIsOnIsland(world, user)).thenReturn(false);
when(im.userIsOnIsland(netherWorld, user)).thenReturn(true);
when(im.userIsOnIsland(endWorld, user)).thenReturn(false);
assertEquals("true", GameModePlaceholder.ON_ISLAND.getReplacer().onReplace(addon, user, island));
// End
when(im.userIsOnIsland(world, user)).thenReturn(false);
when(im.userIsOnIsland(netherWorld, user)).thenReturn(false);
when(im.userIsOnIsland(endWorld, user)).thenReturn(true);
assertEquals("true", GameModePlaceholder.ON_ISLAND.getReplacer().onReplace(addon, user, island));

}

/**
* Test method for {@link world.bentobox.bentobox.lists.GameModePlaceholder#getReplacer()}.
*/
Expand Down