Make /realname throw an error if no matches were found

This commit is contained in:
KHobbits 2012-09-11 00:53:32 +01:00
parent 24cdc37987
commit 5611acf12c

View file

@ -24,6 +24,7 @@ public class Commandrealname extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final String whois = args[0].toLowerCase(Locale.ENGLISH);
boolean foundUser = false;
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User u = ess.getUser(onlinePlayer);
@ -39,7 +40,12 @@ public class Commandrealname extends EssentialsCommand
{
continue;
}
foundUser = true;
sender.sendMessage(u.getDisplayName() + " " + _("is") + " " + u.getName());
}
if (!foundUser)
{
throw new NoSuchFieldException(_("playerNotFound"));
}
}
}