1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-18 20:41:37 +02:00

3 char min length on /pay and /msg

Make /whois throw an error if no matching players are found.
This commit is contained in:
ementalo
2012-06-18 12:13:58 +01:00
parent 93246f020f
commit 933d648ef6
3 changed files with 10 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ public class Commandmsg extends EssentialsCommand
@Override @Override
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty()) if (args.length < 2 || args[0].trim().length() < 3 || args[1].trim().isEmpty())
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }

View File

@@ -16,14 +16,14 @@ public class Commandpay extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (args[0] == "") if (args[0].trim().length() < 3)
{ {
throw new NotEnoughArgumentsException("You need to specify a player to pay."); throw new NotEnoughArgumentsException("You need to specify a player to pay.");
} }
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", "")); double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
Boolean foundUser = false; boolean foundUser = false;
for (Player p : server.matchPlayer(args[0])) for (Player p : server.matchPlayer(args[0]))
{ {
IUser u = ess.getUser(p); IUser u = ess.getUser(p);
@@ -36,7 +36,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

@@ -40,6 +40,7 @@ public class Commandwhois extends EssentialsCommand
ISettings settings = ess.getSettings(); ISettings settings = ess.getSettings();
settings.acquireReadLock(); settings.acquireReadLock();
final int prefixLength = Util.stripColor(settings.getData().getChat().getNicknamePrefix()).length(); final int prefixLength = Util.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
boolean foundPlayer = false;
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
@Cleanup @Cleanup
@@ -57,6 +58,7 @@ public class Commandwhois extends EssentialsCommand
{ {
continue; continue;
} }
foundPlayer = true;
sender.sendMessage(""); sender.sendMessage("");
user.setDisplayNick(); user.setDisplayNick();
sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName())); sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName()));
@@ -82,6 +84,10 @@ public class Commandwhois extends EssentialsCommand
{ {
sender.sendMessage(_("whoisGeoLocation", location)); sender.sendMessage(_("whoisGeoLocation", location));
} }
if (!foundPlayer)
{
throw new NoSuchFieldException(_("playerNotFound"));
}
} }
} }
} }