diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-10-14 13:04:00 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-10-14 13:04:00 +0100 |
commit | a25be26c12f81ea532de699fe52a760ba94b03c0 (patch) | |
tree | 181536f4abf70d6bf95b7efacc3d0639eee273bf | |
parent | 209efb3ac9b9ad9500a469508c16951455536e03 (diff) | |
download | Essentials-a25be26c12f81ea532de699fe52a760ba94b03c0.tar Essentials-a25be26c12f81ea532de699fe52a760ba94b03c0.tar.gz Essentials-a25be26c12f81ea532de699fe52a760ba94b03c0.tar.lz Essentials-a25be26c12f81ea532de699fe52a760ba94b03c0.tar.xz Essentials-a25be26c12f81ea532de699fe52a760ba94b03c0.zip |
Allow kicking of hidden players
3 files changed, 27 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index 287a3cc62..c05c66ad0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -24,23 +24,29 @@ public class Commandkick extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final User user = getPlayer(server, args, 0); - if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt")) - { - throw new Exception(_("kickExempt")); + final User target = getPlayer(server, args, 0, true); + if (sender instanceof Player) { + User user = ess.getUser(sender); + if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) { + throw new PlayerNotFoundException(); + } + if (target.isAuthorized("essentials.kick.exempt")) + { + throw new Exception(_("kickExempt")); + } } final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault"); - user.kickPlayer(kickReason); + target.kickPlayer(kickReason); final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - server.getLogger().log(Level.INFO, _("playerKicked", senderName, user.getName(), kickReason)); + server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason)); for (Player onlinePlayer : server.getOnlinePlayers()) { User player = ess.getUser(onlinePlayer); if (player.isAuthorized("essentials.kick.notify")) { - onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason)); + onlinePlayer.sendMessage(_("playerKicked", senderName, target.getName(), kickReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index 6bc0649e9..5287016eb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -56,14 +56,14 @@ public abstract class EssentialsCommand implements IEssentialsCommand } if (args[pos].isEmpty()) { - throw new NoSuchFieldException(_("playerNotFound")); + throw new PlayerNotFoundException(); } final User user = ess.getUser(args[pos]); if (user != null) { if (!getOffline && (!user.isOnline() || user.isHidden())) { - throw new NoSuchFieldException(_("playerNotFound")); + throw new PlayerNotFoundException(); } return user; } @@ -85,7 +85,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand return userMatch; } } - throw new NoSuchFieldException(_("playerNotFound")); + throw new PlayerNotFoundException(); } @Override diff --git a/Essentials/src/com/earth2me/essentials/commands/PlayerNotFoundException.java b/Essentials/src/com/earth2me/essentials/commands/PlayerNotFoundException.java new file mode 100644 index 000000000..c33e87522 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/PlayerNotFoundException.java @@ -0,0 +1,11 @@ +package com.earth2me.essentials.commands; + +import static com.earth2me.essentials.I18n._; + +public class PlayerNotFoundException extends NoSuchFieldException +{ + public PlayerNotFoundException() + { + super(_("playerNotFound")); + } +} |