From 84606b89b51b790efee58a803ba9a87c0f1145c6 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 11 Jun 2012 00:07:22 +0100 Subject: Make /whois throw an error if no matching players are found. --- Essentials/src/com/earth2me/essentials/commands/Commandpay.java | 2 +- Essentials/src/com/earth2me/essentials/commands/Commandwhois.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java index 01e1fcffb..4a2ac4dde 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java @@ -42,7 +42,7 @@ public class Commandpay extends EssentialsCommand foundUser = true; } - if (foundUser == false) + if (!foundUser) { throw new NoSuchFieldException(_("playerNotFound")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 6c7919163..f7a8ffd6b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -38,6 +38,7 @@ public class Commandwhois extends EssentialsCommand } final String whois = args[0].toLowerCase(Locale.ENGLISH); final int prefixLength = Util.stripFormat(ess.getSettings().getNicknamePrefix()).length(); + Boolean foundUser = false; for (Player onlinePlayer : server.getOnlinePlayers()) { final User user = ess.getUser(onlinePlayer); @@ -52,6 +53,7 @@ public class Commandwhois extends EssentialsCommand { continue; } + foundUser = true; sender.sendMessage(""); user.setDisplayNick(); sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName())); @@ -81,5 +83,9 @@ public class Commandwhois extends EssentialsCommand sender.sendMessage(_("whoisGeoLocation", location)); } } + if (!foundUser) + { + throw new NoSuchFieldException(_("playerNotFound")); + } } } -- cgit v1.2.3