From 38a4a859e431a71b2ea94d93f143f9a2d670f3d1 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 24 Dec 2013 22:47:17 -0600 Subject: [PATCH] Implement not being able to jail people who can't be jailed. --- .../com/graywolf336/jail/command/commands/JailCommand.java | 7 +++++++ src/main/java/com/graywolf336/jail/enums/LangString.java | 2 ++ src/main/resources/en.yml | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java index 90a6561..3b00c8a 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java +++ b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java @@ -93,6 +93,13 @@ public class JailCommand implements Command { Prisoner pris = new Prisoner(params.player(), params.muted(), time); Player p = jm.getPlugin().getServer().getPlayer(params.player()); + //If the player instance is not null and the player has the permission + //'jail.cantbejailed' then don't allow this to happen + if(p != null && p.hasPermission("jail.cantbejailed")) { + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEJAILED)); + return true; + } + //call the event PrisonerJailedEvent event = new PrisonerJailedEvent(j, pris, p, p == null, sender.getName()); jm.getPlugin().getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/com/graywolf336/jail/enums/LangString.java b/src/main/java/com/graywolf336/jail/enums/LangString.java index 8357f59..8368ad3 100644 --- a/src/main/java/com/graywolf336/jail/enums/LangString.java +++ b/src/main/java/com/graywolf336/jail/enums/LangString.java @@ -5,6 +5,8 @@ public enum LangString { BROADCASTMESSAGEFOREVER, /** The message sent when we broadcast/log the message for any time above -1. */ BROADCASTMESSAGEFORMINUTES, + /** The message sent when trying to jail someone who can't be jailed by permission. */ + CANTBEJAILED, /** The message sent when players are jailed without a reason. */ JAILED, /** The message sent when players are jailed with a reason. */ diff --git a/src/main/resources/en.yml b/src/main/resources/en.yml index 7ea3f53..64250bd 100644 --- a/src/main/resources/en.yml +++ b/src/main/resources/en.yml @@ -3,4 +3,5 @@ language: jailedwithreason: "&cYou have been jailed for: %0%" unjailed: "&2You have been released! Please respect the server rules." broadcastmessageforever: "&9%0% has been jailed forever." - broadcastmessageforminutes: "&9%0% has been jailed for %1% minutes." \ No newline at end of file + broadcastmessageforminutes: "&9%0% has been jailed for %1% minutes." + cantbejailed: "&cThat player can't be jailed, due to permissions." \ No newline at end of file