mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Fixed issue where standard Nether is protected.
Also applies to standard End. https://github.com/BentoBoxWorld/addon-bskyblock/issues/9
This commit is contained in:
parent
0f371f4800
commit
86d40ca126
@ -293,6 +293,13 @@ public class IslandsManager {
|
|||||||
* @return Optional Island object
|
* @return Optional Island object
|
||||||
*/
|
*/
|
||||||
public Optional<Island> getIslandAt(Location location) {
|
public Optional<Island> getIslandAt(Location location) {
|
||||||
|
// Do not return an island if there is no nether or end or islands in them
|
||||||
|
if ((location.getWorld().getEnvironment().equals(World.Environment.NETHER) &&
|
||||||
|
(!plugin.getIWM().isNetherGenerate(location.getWorld()) || !plugin.getIWM().isNetherIslands(location.getWorld())))
|
||||||
|
|| (location.getWorld().getEnvironment().equals(World.Environment.THE_END) &&
|
||||||
|
(!plugin.getIWM().isEndGenerate(location.getWorld()) || !plugin.getIWM().isEndIslands(location.getWorld())))) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
return Optional.ofNullable(islandCache.getIslandAt(location));
|
return Optional.ofNullable(islandCache.getIslandAt(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,10 +549,10 @@ public class IslandsManager {
|
|||||||
if (home == null) {
|
if (home == null) {
|
||||||
// Try to fix this teleport location and teleport the player if possible
|
// Try to fix this teleport location and teleport the player if possible
|
||||||
new SafeSpotTeleport.Builder(plugin)
|
new SafeSpotTeleport.Builder(plugin)
|
||||||
.entity(player)
|
.entity(player)
|
||||||
.island(plugin.getIslands().getIsland(world, user))
|
.island(plugin.getIslands().getIsland(world, user))
|
||||||
.homeNumber(number)
|
.homeNumber(number)
|
||||||
.build();
|
.build();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.teleport(home);
|
player.teleport(home);
|
||||||
|
@ -87,6 +87,7 @@ public class IslandsManagerTest {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// World
|
// World
|
||||||
world = mock(World.class);
|
world = mock(World.class);
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.NORMAL);
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
plugin = mock(BentoBox.class);
|
plugin = mock(BentoBox.class);
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
@ -168,6 +169,8 @@ public class IslandsManagerTest {
|
|||||||
when(islandCache.getIslandAt(Mockito.any(Location.class))).thenReturn(is);
|
when(islandCache.getIslandAt(Mockito.any(Location.class))).thenReturn(is);
|
||||||
optionalIsland = Optional.ofNullable(is);
|
optionalIsland = Optional.ofNullable(is);
|
||||||
|
|
||||||
|
// User location
|
||||||
|
when(user.getLocation()).thenReturn(location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,6 +479,107 @@ public class IslandsManagerTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationNether() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
|
||||||
|
when(iwm.isNetherGenerate(Mockito.any())).thenReturn(true);
|
||||||
|
when(iwm.isNetherIslands(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(optionalIsland, im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationNetherNoNether() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
|
||||||
|
when(iwm.isNetherGenerate(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(Optional.empty(), im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationNetherNoNetherIslands() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
|
||||||
|
when(iwm.isNetherGenerate(Mockito.any())).thenReturn(true);
|
||||||
|
when(iwm.isNetherIslands(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(Optional.empty(), im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationEnd() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.THE_END);
|
||||||
|
when(iwm.isEndGenerate(Mockito.any())).thenReturn(true);
|
||||||
|
when(iwm.isEndIslands(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(optionalIsland, im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationEndNoEnd() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.THE_END);
|
||||||
|
when(iwm.isEndGenerate(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(Optional.empty(), im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetIslandAtLocationEndNoEndIslands() throws Exception {
|
||||||
|
when(world.getEnvironment()).thenReturn(World.Environment.THE_END);
|
||||||
|
when(iwm.isEndGenerate(Mockito.any())).thenReturn(true);
|
||||||
|
when(iwm.isEndIslands(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
|
IslandsManager im = new IslandsManager(plugin);
|
||||||
|
im.setIslandCache(islandCache);
|
||||||
|
|
||||||
|
// In nether world, so answer should be empty
|
||||||
|
assertEquals(Optional.empty(), im.getIslandAt(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(World, UUID)}.
|
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(World, UUID)}.
|
||||||
*/
|
*/
|
||||||
@ -718,7 +822,7 @@ public class IslandsManagerTest {
|
|||||||
|
|
||||||
|
|
||||||
// User is on island is determined by whether the user's location is on
|
// User is on island is determined by whether the user's location is on
|
||||||
// an island that has them as a memebr (rank > 0)
|
// an island that has them as a member (rank > 0)
|
||||||
when(is.onIsland(Mockito.any())).thenReturn(true);
|
when(is.onIsland(Mockito.any())).thenReturn(true);
|
||||||
Map<UUID, Integer> members = new HashMap<>();
|
Map<UUID, Integer> members = new HashMap<>();
|
||||||
when(is.getMembers()).thenReturn(members);
|
when(is.getMembers()).thenReturn(members);
|
||||||
|
Loading…
Reference in New Issue
Block a user