diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 342579678..5a4f7b526 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -92,12 +92,7 @@ public class DebugExec extends SubCommand { File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js"); if (file.exists()) { init(); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - onCommand(ConsolePlayer.getConsole(), new String[] {"run", "start.js"}); - } - }, 1); + onCommand(ConsolePlayer.getConsole(), new String[] {"run", "start.js"}); } } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 3577401dc..dfe65e65f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.helpmenu.HelpMenu; @@ -141,7 +142,7 @@ public class MainCommand extends CommandManager { if (category != null && !command.getCategory().equals(category)) { continue; } - if (player != null && !player.hasPermission(command.getPermission())) { + if (player != null && !Permissions.hasPermission(player, command.getPermission())) { continue; } commands.add(command); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java index eda129d24..3a96124bd 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -71,34 +71,34 @@ public class list extends SubCommand { private String[] getArgumentList(PlotPlayer player) { List args = new ArrayList<>(); - if (EconHandler.manager != null && player.hasPermission("plots.list.forsale")) { + if (EconHandler.manager != null && Permissions.hasPermission(player, "plots.list.forsale")) { args.add("forsale"); } - if (player.hasPermission("plots.list.mine")) { + if (Permissions.hasPermission(player, "plots.list.mine")) { args.add("mine"); } - if (player.hasPermission("plots.list.shared")) { + if (Permissions.hasPermission(player, "plots.list.shared")) { args.add("shared"); } - if (player.hasPermission("plots.list.world")) { + if (Permissions.hasPermission(player, "plots.list.world")) { args.add("world"); } - if (player.hasPermission("plots.list.top")) { + if (Permissions.hasPermission(player, "plots.list.top")) { args.add("top"); } - if (player.hasPermission("plots.list..all")) { + if (Permissions.hasPermission(player, "plots.list..all")) { args.add("all"); } - if (player.hasPermission("plots.list.unowned")) { + if (Permissions.hasPermission(player, "plots.list.unowned")) { args.add("unowned"); } - if (player.hasPermission("plots.list.unknown")) { + if (Permissions.hasPermission(player, "plots.list.unknown")) { args.add("unknown"); } - if (player.hasPermission("plots.list.player")) { + if (Permissions.hasPermission(player, "plots.list.player")) { args.add(""); } - if (player.hasPermission("plots.list.world")) { + if (Permissions.hasPermission(player, "plots.list.world")) { args.add(""); } return args.toArray(new String[args.size()]); diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 457df3b78..a569ce21c 100644 --- a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; /** * Flag Manager Utility @@ -369,7 +370,7 @@ public class FlagManager { public static List getFlags(final PlotPlayer player) { final List returnFlags = new ArrayList<>(); for (final AbstractFlag flag : flags) { - if (player.hasPermission("plots.set.flag." + flag.getKey().toLowerCase())) { + if (Permissions.hasPermission(player, "plots.set.flag." + flag.getKey().toLowerCase())) { returnFlags.add(flag); } } diff --git a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 70110bbfa..2b0051fd4 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; public enum Permissions { // ADMIN ADMIN("plots.admin", "do-not-change"), + STAR("*", "do-not-change"), // BUILD BUILD_OTHER("plots.admin.build.other", "build"), BUILD_ROAD("plots.admin.build.road", "build"), @@ -35,17 +36,17 @@ public enum Permissions { public static boolean hasPermission(final PlotPlayer player, final String perm) { - if ((player == null) || player.hasPermission(ADMIN.s)) { + if ((player == null) || player.hasPermission(ADMIN.s) || player.hasPermission(STAR.s)) { return true; } - if (player.hasPermission(perm)) { + if (Permissions.hasPermission(player, perm)) { return true; } final String[] nodes = perm.split("\\."); final StringBuilder n = new StringBuilder(); for (int i = 0; i < (nodes.length - 1); i++) { n.append(nodes[i] + (".")); - if (player.hasPermission(n + "*")) { + if (player.hasPermission(n + STAR.s)) { return true; } } @@ -53,35 +54,24 @@ public enum Permissions { } public static boolean hasPermission(final PlotPlayer player, final String perm, boolean notify) { - if ((player == null) || player.hasPermission(ADMIN.s)) { - return true; - } - if (player.hasPermission(perm)) { - return true; - } - final String[] nodes = perm.split("\\."); - final StringBuilder n = new StringBuilder(); - for (int i = 0; i < (nodes.length - 1); i++) { - n.append(nodes[i] + (".")); - if (player.hasPermission(n + "*")) { - return true; + if (!hasPermission(player, perm)) { + if (notify) { + MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, perm); } + return false; } - if (notify) { - MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, perm); - } - return false; + return true; } public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { - if ((player == null) || player.hasPermission(ADMIN.s)) { + if ((player == null) || player.hasPermission(ADMIN.s) || player.hasPermission(STAR.s)) { return Integer.MAX_VALUE; } - if (player.hasPermission(stub + ".*")) { + if (Permissions.hasPermission(player, stub + ".*")) { return Integer.MAX_VALUE; } for (int i = range; i > 0; i--) { - if (player.hasPermission(stub + "." + i)) { + if (Permissions.hasPermission(player, stub + "." + i)) { return i; } } diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index b7b87a963..03f68f4d8 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -355,7 +355,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } Flag flag; - if (!player.hasPermission(PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS) && (flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) { + if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS) && (flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) { List v = (List) flag.getValue(); String msg = event.getMessage().toLowerCase().replaceFirst("/", ""); diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java index b805a2c21..02fd1ac99 100644 --- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java +++ b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java @@ -85,8 +85,10 @@ public class BukkitPlayer extends PlotPlayer { return true; } if (offline && EconHandler.manager != null) { + System.out.print("CHECKIGN VAULT!"); return EconHandler.manager.hasPermission(getName(), perm); } + System.out.print("CHECKING: " + perm + " -> " + player.hasPermission(perm)); return this.player.hasPermission(perm); } diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java index d04f5d680..43c374c38 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.commands.DebugUUID; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.plotsquared.general.commands.Command; @@ -63,7 +64,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { String label = cmd.getCommand(); if (!label.equalsIgnoreCase(best)) { if (label.startsWith(arg)) { - if (player.hasPermission(cmd.getPermission())) { + if (Permissions.hasPermission(player, cmd.getPermission())) { tabOptions.add(cmd.getCommand()); } else if (cmd.getAliases().size() > 0) { for (String alias : cmd.getAliases()) {