From f2b0fa43dc3b223fef3353bfa80e4ee329d62fa1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 14 Jul 2015 03:42:02 +1000 Subject: [PATCH] Permission for merging with friends --- .../com/intellectualcrafters/plot/commands/Merge.java | 4 ++++ .../com/intellectualcrafters/plot/util/Permissions.java | 8 +++++++- PlotSquared/src/main/resources/plugin.yml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index ea89f5ca3..e8d8d2feb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -159,6 +159,10 @@ public class Merge extends SubCommand { multiUUID.add(u2); } if (multiMerge) { + if (!Permissions.hasPermission(plr, Permissions.MERGE_OTHER)) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, Permissions.MERGE_OTHER); + return false; + } for (final UUID uuid : multiUUID) { PlotPlayer accepter = UUIDHandler.getPlayer(uuid); CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 26c7c9f88..9eac3173b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -17,7 +17,9 @@ public enum Permissions { // BREAK BREAK_OTHER("plots.admin.break.other", "break"), BREAK_ROAD("plots.admin.break.road", "break"), - BREAK_UNOWNED("plots.admin.break.unowned", "break"); + BREAK_UNOWNED("plots.admin.break.unowned", "break"), + // MERGE + MERGE_OTHER("plots.merge.other", "merge"); public String s; public String cat; @@ -26,6 +28,10 @@ public enum Permissions { this.s = perm; this.cat = cat; } + + public static boolean hasPermission(final PlotPlayer player, final Permissions perm) { + return hasPermission(player, perm.s); + } public static boolean hasPermission(final PlotPlayer player, final String perm) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { diff --git a/PlotSquared/src/main/resources/plugin.yml b/PlotSquared/src/main/resources/plugin.yml index 8b5f9d3a3..37969fb2b 100644 --- a/PlotSquared/src/main/resources/plugin.yml +++ b/PlotSquared/src/main/resources/plugin.yml @@ -112,6 +112,7 @@ permissions: plots.set.biome: true plots.set.home: true plots.merge: true + plots.merge.other: true plots.unlink: true plots.denied: true plots.add: true