mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
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:
parent
3a34133d1a
commit
61a5b692ec
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user