Add permissions for plot list filters. Closes #262

This commit is contained in:
Byteflux 2015-04-14 12:21:47 -07:00
parent e93634622c
commit fcb0b084d9

View File

@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
@ -112,6 +113,10 @@ public class list extends SubCommand {
if (plr == null) { if (plr == null) {
break; break;
} }
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
return false;
}
plots = PlotSquared.getPlots(plr); plots = PlotSquared.getPlots(plr);
break; break;
} }
@ -119,6 +124,10 @@ public class list extends SubCommand {
if (plr == null) { if (plr == null) {
break; break;
} }
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
return false;
}
plots = new ArrayList<Plot>(); plots = new ArrayList<Plot>();
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {
if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) { if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) {
@ -128,14 +137,30 @@ public class list extends SubCommand {
break; break;
} }
case "world": { 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(); plots = PlotSquared.getPlots(world).values();
break; break;
} }
case "all": { case "all": {
if (!Permissions.hasPermission(plr, "plots.list.all")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
return false;
}
plots = PlotSquared.getPlots(); plots = PlotSquared.getPlots();
break; break;
} }
case "forsale": { case "forsale": {
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
return false;
}
if (PlotSquared.economy == null) { if (PlotSquared.economy == null) {
break; break;
} }
@ -149,6 +174,10 @@ public class list extends SubCommand {
break; break;
} }
case "unowned": { case "unowned": {
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
return false;
}
plots = new HashSet<>(); plots = new HashSet<>();
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {
if (plot.owner == null) { if (plot.owner == null) {
@ -158,6 +187,10 @@ public class list extends SubCommand {
break; break;
} }
case "unknown": { case "unknown": {
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
return false;
}
plots = new HashSet<>(); plots = new HashSet<>();
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {
if (plot.owner == null) { if (plot.owner == null) {
@ -171,11 +204,23 @@ public class list extends SubCommand {
} }
default: { default: {
if (PlotSquared.isPlotWorld(args[0])) { 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(); plots = PlotSquared.getPlots(args[0]).values();
break; break;
} }
UUID uuid = UUIDHandler.getUUID(args[0]); UUID uuid = UUIDHandler.getUUID(args[0]);
if (uuid != null) { 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); plots = PlotSquared.getPlots(uuid);
break; break;
} }