mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-13 19:01:28 +01:00
parent
90a53e9fd8
commit
5d3821094c
@ -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
|
||||
|
@ -6,6 +6,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
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;
|
||||
@ -168,6 +169,40 @@ public class GameModePlaceholderTest {
|
||||
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()}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user