mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Using /exp, show can't find player message, if no matching player is found.
This commit is contained in:
parent
edca2cbdff
commit
9f852b3a41
2 changed files with 30 additions and 23 deletions
|
@ -27,7 +27,7 @@ public class Commandexp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
|
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
|
||||||
{
|
{
|
||||||
expMatch(server, user, args[1], args[2]);
|
expMatch(server, user, args[1], args[2], false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ public class Commandexp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
|
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
|
||||||
{
|
{
|
||||||
expMatch(server, user, args[1], args[2]);
|
expMatch(server, user, args[1], args[2], true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -47,22 +47,18 @@ public class Commandexp extends EssentialsCommand
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String search = args[0].trim();
|
String match = args[0].trim();
|
||||||
if (args.length == 2)
|
if (args.length == 2)
|
||||||
{
|
{
|
||||||
search = args[1].trim();
|
match = args[1].trim();
|
||||||
}
|
}
|
||||||
if (search.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||||
{
|
{
|
||||||
showExp(user, user);
|
showExp(user, user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player matchPlayer : server.matchPlayer(search))
|
showMatch(server, user, match);
|
||||||
{
|
|
||||||
final User target = ess.getUser(matchPlayer);
|
|
||||||
showExp(user, target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,39 +72,50 @@ public class Commandexp extends EssentialsCommand
|
||||||
}
|
}
|
||||||
else if (args.length > 2 && args[0].equalsIgnoreCase("set"))
|
else if (args.length > 2 && args[0].equalsIgnoreCase("set"))
|
||||||
{
|
{
|
||||||
expMatch(server, sender, args[1], args[2]);
|
expMatch(server, sender, args[1], args[2], false);
|
||||||
}
|
}
|
||||||
else if (args.length > 2 && args[0].equalsIgnoreCase("give"))
|
else if (args.length > 2 && args[0].equalsIgnoreCase("give"))
|
||||||
{
|
{
|
||||||
expMatch(server, sender, args[1], args[2]);
|
expMatch(server, sender, args[1], args[2], true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String search = args[0].trim();
|
String match = args[0].trim();
|
||||||
if (args.length == 2)
|
if (args.length == 2)
|
||||||
{
|
{
|
||||||
search = args[1].trim();
|
match = args[1].trim();
|
||||||
}
|
|
||||||
for (Player matchPlayer : server.matchPlayer(search))
|
|
||||||
{
|
|
||||||
final User target = ess.getUser(matchPlayer);
|
|
||||||
showExp(sender, target);
|
|
||||||
}
|
}
|
||||||
|
showMatch(server, sender, match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expMatch(final Server server, final CommandSender sender, final String match, final String toggle) throws NoSuchFieldException
|
private void showMatch(final Server server, final CommandSender sender, final String match) throws NotEnoughArgumentsException
|
||||||
|
{
|
||||||
|
boolean foundUser = false;
|
||||||
|
for (Player matchPlayer : server.matchPlayer(match))
|
||||||
|
{
|
||||||
|
foundUser = true;
|
||||||
|
final User target = ess.getUser(matchPlayer);
|
||||||
|
showExp(sender, target);
|
||||||
|
}
|
||||||
|
if (!foundUser)
|
||||||
|
{
|
||||||
|
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void expMatch(final Server server, final CommandSender sender, final String match, final String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||||
{
|
{
|
||||||
boolean foundUser = false;
|
boolean foundUser = false;
|
||||||
for (Player matchPlayer : server.matchPlayer(match))
|
for (Player matchPlayer : server.matchPlayer(match))
|
||||||
{
|
{
|
||||||
final User target = ess.getUser(matchPlayer);
|
final User target = ess.getUser(matchPlayer);
|
||||||
setExp(sender, target, toggle, true);
|
setExp(sender, target, amount, toggle);
|
||||||
foundUser = true;
|
foundUser = true;
|
||||||
}
|
}
|
||||||
if (!foundUser)
|
if (!foundUser)
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(_("playerNotFound"));
|
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Commandpay extends EssentialsCommand
|
||||||
|
|
||||||
if (!foundUser)
|
if (!foundUser)
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(_("playerNotFound"));
|
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue