Make /whois throw an error if no matching players are found.

This commit is contained in:
KHobbits 2012-06-11 00:07:22 +01:00
parent 77b0415c1b
commit 2e15de483d
2 changed files with 7 additions and 1 deletions

View File

@ -42,7 +42,7 @@ public class Commandpay extends EssentialsCommand
foundUser = true; foundUser = true;
} }
if (foundUser == false) if (!foundUser)
{ {
throw new NoSuchFieldException(_("playerNotFound")); throw new NoSuchFieldException(_("playerNotFound"));
} }

View File

@ -38,6 +38,7 @@ public class Commandwhois extends EssentialsCommand
} }
final String whois = args[0].toLowerCase(Locale.ENGLISH); final String whois = args[0].toLowerCase(Locale.ENGLISH);
final int prefixLength = Util.stripFormat(ess.getSettings().getNicknamePrefix()).length(); final int prefixLength = Util.stripFormat(ess.getSettings().getNicknamePrefix()).length();
Boolean foundUser = false;
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
final User user = ess.getUser(onlinePlayer); final User user = ess.getUser(onlinePlayer);
@ -52,6 +53,7 @@ public class Commandwhois extends EssentialsCommand
{ {
continue; continue;
} }
foundUser = true;
sender.sendMessage(""); sender.sendMessage("");
user.setDisplayNick(); user.setDisplayNick();
sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName())); sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName()));
@ -81,5 +83,9 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage(_("whoisGeoLocation", location)); sender.sendMessage(_("whoisGeoLocation", location));
} }
} }
if (!foundUser)
{
throw new NoSuchFieldException(_("playerNotFound"));
}
} }
} }