Added test case for getSafeHomeLocationNoIsland() for player with no

island.

https://github.com/BentoBoxWorld/BentoBox/pull/1651
This commit is contained in:
tastybento 2021-01-20 16:01:06 -08:00
parent 737ad16ff6
commit 1eee225def
2 changed files with 14 additions and 3 deletions

View File

@ -625,8 +625,8 @@ public class IslandsManager {
}
// Home location either isn't safe, or does not exist so try the island
// location
if (plugin.getIslands().inTeam(world, user.getUniqueId())) {
l = plugin.getIslands().getIslandLocation(world, user.getUniqueId());
if (inTeam(world, user.getUniqueId())) {
l = getIslandLocation(world, user.getUniqueId());
if (l != null && isSafeLocation(l)) {
plugin.getPlayers().setHomeLocation(user, l, number);
return l;
@ -639,7 +639,7 @@ public class IslandsManager {
}
}
} else {
l = plugin.getIslands().getIslandLocation(world, user.getUniqueId());
l = getIslandLocation(world, user.getUniqueId());
if (l != null && isSafeLocation(l)) {
plugin.getPlayers().setHomeLocation(user, l, number);
return l.clone().add(new Vector(0.5D,0,0.5D));

View File

@ -721,6 +721,17 @@ public class IslandsManagerTest {
when(iwm.inWorld(world)).thenReturn(false);
assertNull(im.getSafeHomeLocation(world, user, 0));
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(World, User, int)}.
*/
@Test
public void testGetSafeHomeLocationNoIsland() {
IslandsManager im = new IslandsManager(plugin);
when(pm.getHomeLocation(eq(world), eq(user), eq(0))).thenReturn(null);
assertNull(im.getSafeHomeLocation(world, user, 0));
verify(plugin).logWarning(eq("null player has no island in world world!"));
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint(World)}.