From b14b7102b9c789729b44bfc78f45cdc1a7f9043f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:34:05 +1100 Subject: [PATCH] perms --- .../plot/commands/CommandPermission.java | 2 +- .../plot/commands/FlagCmd.java | 18 +++++++++--------- .../plot/commands/MainCommand.java | 2 +- .../plot/listeners/PlayerEvents.java | 17 +++++++++-------- .../plot/listeners/WorldEditListener.java | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java index 7f84e6d75..3b6c827ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -47,6 +47,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final PlotPlayer player) { - return BukkitMain.hasPermission(player, this.permission); + return Permissions.hasPermission(BukkitUtil.getPlayer(player), this.permission); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 6c7ccc50c..1111822c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -65,13 +65,13 @@ public class FlagCmd extends SubCommand { sendMessage(player, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { + if (!plot.hasRights(player) && !Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag.other")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { - if (!BukkitMain.hasPermission(player, "plots.set.flag")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.info"); return false; } @@ -94,7 +94,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented."); } case "set": { - if (!BukkitMain.hasPermission(player, "plots.set.flag")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag"); return false; } @@ -107,7 +107,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -128,7 +128,7 @@ public class FlagCmd extends SubCommand { return true; } case "remove": { - if (!BukkitMain.hasPermission(player, "plots.flag.remove")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.remove")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.remove"); return false; } @@ -141,7 +141,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -166,7 +166,7 @@ public class FlagCmd extends SubCommand { return true; } case "add": { - if (!BukkitMain.hasPermission(player, "plots.flag.add")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.add")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.add"); return false; } @@ -179,7 +179,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -206,7 +206,7 @@ public class FlagCmd extends SubCommand { return true; } case "list": { - if (!BukkitMain.hasPermission(player, "plots.flag.list")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.list")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.list"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 947a8fbd8..8be6cf67d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -110,7 +110,7 @@ public class MainCommand { } public boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { - if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), PlotSquared.MAIN_PERMISSION)) { return no_permission(player, PlotSquared.MAIN_PERMISSION); } if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 1cb3e9cf2..128ec376e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -101,6 +101,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -198,7 +199,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot.denied.size() > 0) { final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { - if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.entry.denied")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; @@ -262,7 +263,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.unowned"); @@ -526,7 +527,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.unowned"); @@ -539,7 +540,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.other")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.other"); @@ -548,7 +549,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (BukkitMain.hasPermission(player, "plots.admin.interact.road")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.road")) { return; } if (isPlotArea(loc)) { @@ -1077,7 +1078,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -1090,7 +1091,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((place != null) && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.other")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; @@ -1098,7 +1099,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.road")) { if (isPlotArea(loc)) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 453f6b144..6eb7107c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -85,7 +85,7 @@ public class WorldEditListener implements Listener { if (!world.equals(player.getWorld().getName())) { return; } - if (BukkitMain.hasPermission(player, "plots.worldedit.bypass")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.worldedit.bypass")) { return; } PWE.setNoMask(player);