Protection checks not correctly taking into account std Nether and End

https://github.com/BentoBoxWorld/bentobox/issues/331

The isIslandNether(), isNether(), etc. methods need to check the
environment of the world.
This commit is contained in:
tastybento 2018-11-10 11:45:18 -08:00
parent 3b36ab8814
commit 37aa2e06f9
3 changed files with 12 additions and 13 deletions

View File

@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
@ -148,10 +148,7 @@ public abstract class FlagListener implements Listener {
*/ */
public boolean checkIsland(Event e, Location loc, Flag flag, boolean silent) { public boolean checkIsland(Event e, Location loc, Flag flag, boolean silent) {
// If this is not an Island World or a standard Nether or End, skip // If this is not an Island World or a standard Nether or End, skip
if (!plugin.getIWM().inWorld(loc) if (!plugin.getIWM().inWorld(loc)) {
|| (plugin.getIWM().isNether(loc.getWorld()) && !plugin.getIWM().isNetherIslands(loc.getWorld()))
|| (plugin.getIWM().isEnd(loc.getWorld()) && !plugin.getIWM().isEndIslands(loc.getWorld()))
) {
report(user, e, loc, flag, Why.UNPROTECTED_WORLD); report(user, e, loc, flag, Why.UNPROTECTED_WORLD);
return true; return true;
} }

View File

@ -13,8 +13,8 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.BlockIterator; import org.bukkit.util.BlockIterator;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
/** /**

View File

@ -82,7 +82,9 @@ public class IslandWorldManager {
* @return true if in a world or false if not * @return true if in a world or false if not
*/ */
public boolean inWorld(World world) { public boolean inWorld(World world) {
return worlds.containsKey(Util.getWorld(world)); return ((world.getEnvironment().equals(Environment.NETHER) && isIslandNether(world))
|| (world.getEnvironment().equals(Environment.THE_END) && isIslandEnd(world))
|| (world.getEnvironment().equals(Environment.NORMAL)) && worlds.containsKey(world));
} }
/** /**
@ -302,7 +304,7 @@ public class IslandWorldManager {
*/ */
public boolean isNether(World world) { public boolean isNether(World world) {
World w = Util.getWorld(world); World w = Util.getWorld(world);
return worldSettings.containsKey(w) && worldSettings.get(w).isNetherGenerate(); return world.getEnvironment().equals(Environment.NETHER) && worldSettings.containsKey(w) && worldSettings.get(w).isNetherGenerate();
} }
/** /**
@ -314,7 +316,7 @@ public class IslandWorldManager {
*/ */
public boolean isIslandNether(World world) { public boolean isIslandNether(World world) {
World w = Util.getWorld(world); World w = Util.getWorld(world);
return worldSettings.containsKey(w) && worldSettings.get(w).isNetherGenerate() return world.getEnvironment().equals(Environment.NETHER) && worldSettings.containsKey(w) && worldSettings.get(w).isNetherGenerate()
&& worldSettings.get(w).isNetherIslands(); && worldSettings.get(w).isNetherIslands();
} }
@ -327,7 +329,7 @@ public class IslandWorldManager {
*/ */
public boolean isEnd(World world) { public boolean isEnd(World world) {
World w = Util.getWorld(world); World w = Util.getWorld(world);
return worldSettings.containsKey(w) && worldSettings.get(w).isEndGenerate(); return world.getEnvironment().equals(Environment.THE_END) && worldSettings.containsKey(w) && worldSettings.get(w).isEndGenerate();
} }
/** /**
@ -339,7 +341,7 @@ public class IslandWorldManager {
*/ */
public boolean isIslandEnd(World world) { public boolean isIslandEnd(World world) {
World w = Util.getWorld(world); World w = Util.getWorld(world);
return worldSettings.containsKey(w) && worldSettings.get(w).isEndGenerate() return world.getEnvironment().equals(Environment.THE_END) && worldSettings.containsKey(w) && worldSettings.get(w).isEndGenerate()
&& worldSettings.get(w).isEndIslands(); && worldSettings.get(w).isEndIslands();
} }