From f1c16df63b4632f61fadcb37a31e2d6d2f22a972 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 4 Apr 2013 22:20:19 +0200 Subject: [PATCH] Added new permission node for party teleportation. `mcmmo.commands.ptp.send` This permission node will be check before sending a teleport request (or teleporting the sender if no request is required), this allows admins to grant certain groups of users permissions to accept incoming party teleport request without being able to send ptp requests themselves. Closes #927 --- .../gmail/nossr50/commands/party/teleport/PtpCommand.java | 6 ++++++ src/main/java/com/gmail/nossr50/util/Permissions.java | 1 + src/main/resources/plugin.yml | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index f5a3adc85..4bcc5bd3d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -54,6 +55,11 @@ public class PtpCommand implements CommandExecutor { return ptpAcceptCommand.onCommand(sender, command, label, args); } + if (!Permissions.partyTeleportSend(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + sendTeleportRequest(sender, player, args[0]); return true; diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index e8922acbd..2c57cf7ae 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -217,6 +217,7 @@ public final class Permissions { public static boolean friendlyFire(Permissible permissible) { return permissible.hasPermission("mcmmo.party.friendlyfire"); } /* TELEPORT */ + public static boolean partyTeleportSend(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.send"); } public static boolean partyTeleportAccept(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.accept"); } public static boolean partyTeleportAcceptAll(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.acceptall"); } public static boolean partyTeleportToggle(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.toggle"); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f48691813..fa835aed3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -954,12 +954,15 @@ permissions: description: Implies access to all mcmmo.commands.ptp permissions. children: mcmmo.commands.ptp: true + mcmmo.commands.ptp.send: true mcmmo.commands.ptp.accept: true mcmmo.commands.ptp.acceptall: true mcmmo.commands.ptp.toggle: true mcmmo.commands.ptp.world.all: true mcmmo.commands.ptp: description: Allows access to the ptp command + mcmmo.commands.ptp.send: + description: Allows access to the ptp command mcmmo.commands.ptp.accept: description: Allows access to the ptp accept command mcmmo.commands.ptp.acceptall: