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.Event;
import org.bukkit.event.Listener;
import org.bukkit.metadata.MetadataValue;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
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) {
// If this is not an Island World or a standard Nether or End, skip
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()))
) {
if (!plugin.getIWM().inWorld(loc)) {
report(user, e, loc, flag, Why.UNPROTECTED_WORLD);
return true;
}
@ -180,7 +177,7 @@ public abstract class FlagListener implements Listener {
}
// Ops or "bypass everywhere" moderators can do anything
if (user.isOp() || user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + ".mod.bypass." + flag.getID() + ".everywhere")) {
if (user.isOp() || user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + ".mod.bypass." + flag.getID() + ".everywhere")) {
if (user.isOp()) {
report(user, e, loc, flag, Why.OP);
} else {
@ -203,7 +200,7 @@ public abstract class FlagListener implements Listener {
report(user, e, loc, flag, Why.BYPASS_ISLAND);
user = null;
return true;
}
}
report(user, e, loc, flag, Why.NOT_ALLOWED_ON_ISLAND);
noGo(e, flag, silent);
// Clear the user for the next time

View File

@ -13,8 +13,8 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.player.PlayerInteractEvent;
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.FlagListener;
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
*/
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) {
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) {
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();
}
@ -327,7 +329,7 @@ public class IslandWorldManager {
*/
public boolean isEnd(World 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) {
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();
}