mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-18 04:21:31 +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:
@@ -17,7 +17,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
@@ -16,14 +16,14 @@ public class Commandpay extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0] == "")
|
||||
if (args[0].trim().length() < 3)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
|
||||
}
|
||||
|
||||
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
|
||||
|
||||
Boolean foundUser = false;
|
||||
boolean foundUser = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
IUser u = ess.getUser(p);
|
||||
@@ -36,7 +36,7 @@ public class Commandpay extends EssentialsCommand
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
if (foundUser == false)
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final int prefixLength = Util.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
|
||||
boolean foundPlayer = false;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
@Cleanup
|
||||
@@ -57,6 +58,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foundPlayer = true;
|
||||
sender.sendMessage("");
|
||||
user.setDisplayNick();
|
||||
sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName()));
|
||||
@@ -82,6 +84,10 @@ public class Commandwhois extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("whoisGeoLocation", location));
|
||||
}
|
||||
if (!foundPlayer)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user