From ce79588805c4796a3e8aa7bed63b8cc0445357cb Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 7 Feb 2021 10:05:29 -0800 Subject: [PATCH] Fixed admin switch command when inside another island. --- .../bentobox/api/commands/admin/AdminSwitchCommand.java | 2 ++ .../world/bentobox/bentobox/api/flags/FlagListener.java | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSwitchCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSwitchCommand.java index 6e0814373..c1b5cd39d 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSwitchCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSwitchCommand.java @@ -13,6 +13,8 @@ import world.bentobox.bentobox.api.user.User; */ public class AdminSwitchCommand extends ConfirmableCommand { + public static final String META_TAG = "AdminCommandSwitch"; + /** * Switches bypass on and off * @param parent - admin command diff --git a/src/main/java/world/bentobox/bentobox/api/flags/FlagListener.java b/src/main/java/world/bentobox/bentobox/api/flags/FlagListener.java index 38c956ac3..20b27b4fc 100644 --- a/src/main/java/world/bentobox/bentobox/api/flags/FlagListener.java +++ b/src/main/java/world/bentobox/bentobox/api/flags/FlagListener.java @@ -13,6 +13,7 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.api.commands.admin.AdminSwitchCommand; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.metadata.MetaDataValue; import world.bentobox.bentobox.api.user.User; @@ -153,7 +154,7 @@ public abstract class FlagListener implements Listener { // Protection flag // Ops or "bypass everywhere" moderators can do anything unless they have switched it off - if (!user.getMetaData("AdminCommandSwitch").map(MetaDataValue::asBoolean).orElse(false) + if (!user.getMetaData(AdminSwitchCommand.META_TAG).map(MetaDataValue::asBoolean).orElse(false) && (user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + "mod.bypassprotect") || user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + "mod.bypass." + flag.getID() + ".everywhere"))) { if (user.isOp()) { @@ -183,7 +184,8 @@ public abstract class FlagListener implements Listener { if (island.get().isAllowed(user, flag)) { report(user, e, loc, flag, Why.RANK_ALLOWED); return true; - } else if (user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + "mod.bypass." + flag.getID() + ".island")) { + } else if (!user.getMetaData(AdminSwitchCommand.META_TAG).map(MetaDataValue::asBoolean).orElse(false) + && (user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + "mod.bypass." + flag.getID() + ".island"))) { report(user, e, loc, flag, Why.BYPASS_ISLAND); return true; }