From fcb0b084d9428077af27efe818efe1f2c74e8993 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 12:21:47 -0700 Subject: [PATCH] Add permissions for plot list filters. Closes #262 --- .../plot/commands/list.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 26974a642..55f099a5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -112,6 +113,10 @@ public class list extends SubCommand { if (plr == null) { break; } + if (!Permissions.hasPermission(plr, "plots.list.mine")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine"); + return false; + } plots = PlotSquared.getPlots(plr); break; } @@ -119,6 +124,10 @@ public class list extends SubCommand { if (plr == null) { break; } + if (!Permissions.hasPermission(plr, "plots.list.shared")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared"); + return false; + } plots = new ArrayList(); for (Plot plot : PlotSquared.getPlots()) { if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) { @@ -128,14 +137,30 @@ public class list extends SubCommand { break; } case "world": { + if (!Permissions.hasPermission(plr, "plots.list.world")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); + return false; + } + if (!Permissions.hasPermission(plr, "plots.list.world." + world)) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world); + return false; + } plots = PlotSquared.getPlots(world).values(); break; } case "all": { + if (!Permissions.hasPermission(plr, "plots.list.all")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all"); + return false; + } plots = PlotSquared.getPlots(); break; } case "forsale": { + if (!Permissions.hasPermission(plr, "plots.list.forsale")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale"); + return false; + } if (PlotSquared.economy == null) { break; } @@ -149,6 +174,10 @@ public class list extends SubCommand { break; } case "unowned": { + if (!Permissions.hasPermission(plr, "plots.list.unowned")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned"); + return false; + } plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { if (plot.owner == null) { @@ -158,6 +187,10 @@ public class list extends SubCommand { break; } case "unknown": { + if (!Permissions.hasPermission(plr, "plots.list.unknown")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown"); + return false; + } plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { if (plot.owner == null) { @@ -171,11 +204,23 @@ public class list extends SubCommand { } default: { if (PlotSquared.isPlotWorld(args[0])) { + if (!Permissions.hasPermission(plr, "plots.list.world")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); + return false; + } + if (!Permissions.hasPermission(plr, "plots.list.world." + args[0])) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]); + return false; + } plots = PlotSquared.getPlots(args[0]).values(); break; } UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { + if (!Permissions.hasPermission(plr, "plots.list.player")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player"); + return false; + } plots = PlotSquared.getPlots(uuid); break; }