From bd2473f597293949c2d5a060edfbecb36785ee52 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 1 Dec 2019 12:03:30 +0100 Subject: [PATCH] Fixed COMMAND_RANKS flag still require the admin permission Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1050 It now uses the default permission behaviour. --- .../clicklisteners/CommandRankClickListener.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/clicklisteners/CommandRankClickListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/clicklisteners/CommandRankClickListener.java index b41081071..7b8e1eb08 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/clicklisteners/CommandRankClickListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/clicklisteners/CommandRankClickListener.java @@ -19,7 +19,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.managers.IslandWorldManager; +import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.managers.RanksManager; import world.bentobox.bentobox.util.Util; @@ -41,10 +41,14 @@ public class CommandRankClickListener implements ClickHandler { user.sendMessage("general.errors.wrong-world"); return true; } - IslandWorldManager iwm = plugin.getIWM(); - String reqPerm = iwm.getPermissionPrefix(Util.getWorld(user.getWorld())) + "admin.settings.COMMAND_RANKS"; - if (!user.hasPermission(reqPerm)) { - user.sendMessage("general.errors.no-permission", "[permission]", reqPerm); + + // Check if has permission + String prefix = plugin.getIWM().getPermissionPrefix(Util.getWorld(user.getWorld())); + String reqPerm = prefix + "settings." + Flags.COMMAND_RANKS.getID(); + String allPerms = prefix + "settings.*"; + if (!user.hasPermission(reqPerm) && !user.hasPermission(allPerms) + && !user.isOp() && !user.hasPermission(prefix + "admin.settings")) { + user.sendMessage("general.errors.no-permission", TextVariables.PERMISSION, reqPerm); user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F); return true; }