Remove unnecessary checks in IslandsManager and IslandWorldManager (#692)

Removed checks overlaps a lot. It is not necessary to check multiple time if island is nether and end island, as they will not change their status in runtime.
This commit is contained in:
BONNe 2019-05-23 04:55:22 +03:00 committed by Florian CUNY
parent 3a34133d1a
commit 61a5b692ec
2 changed files with 5 additions and 14 deletions

View File

@ -91,9 +91,8 @@ public class IslandWorldManager {
* @return true if in a world or false if not
*/
public boolean inWorld(@Nullable World world) {
return world != null && ((world.getEnvironment().equals(Environment.NETHER) && isIslandNether(world))
|| (world.getEnvironment().equals(Environment.THE_END) && isIslandEnd(world))
|| (world.getEnvironment().equals(Environment.NORMAL)) && gameModes.containsKey(world));
return world != null && gameModes.containsKey(world) &&
(world.getEnvironment().equals(Environment.NORMAL) || isIslandNether(world) || isIslandEnd(world));
}
/**

View File

@ -342,19 +342,11 @@ public class IslandsManager {
*/
public Optional<Island> getIslandAt(Location location) {
// If this is not an Island World or a standard Nether or End, skip
if (!plugin.getIWM().inWorld(location)
|| (plugin.getIWM().isNether(location.getWorld()) && !plugin.getIWM().isNetherIslands(location.getWorld()))
|| (plugin.getIWM().isEnd(location.getWorld()) && !plugin.getIWM().isEndIslands(location.getWorld()))
) {
return Optional.empty();
}
// 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())))) {
if (!plugin.getIWM().inWorld(location))
{
return Optional.empty();
}
return Optional.ofNullable(islandCache.getIslandAt(location));
}