mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-27 03:28:30 +01:00
Make /exp accept L before or after the amount, add extra checks
This commit is contained in:
parent
4dc2e2e3fd
commit
dcf90cbf5a
@ -125,11 +125,11 @@ public class Commandexp extends EssentialsCommand
|
|||||||
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
|
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
|
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException
|
||||||
{
|
{
|
||||||
Long amount;
|
Long amount;
|
||||||
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
||||||
if (strAmount.startsWith("l"))
|
if (strAmount.startsWith("l") || strAmount.endsWith("l"))
|
||||||
{
|
{
|
||||||
strAmount = strAmount.substring(1);
|
strAmount = strAmount.substring(1);
|
||||||
int neededLevel = Integer.parseInt(strAmount);
|
int neededLevel = Integer.parseInt(strAmount);
|
||||||
@ -141,7 +141,7 @@ public class Commandexp extends EssentialsCommand
|
|||||||
SetExpFix.setTotalExperience(target, 0);
|
SetExpFix.setTotalExperience(target, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
amount = Long.parseLong(strAmount);
|
amount = (long)Integer.parseInt(strAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (give)
|
if (give)
|
||||||
@ -152,6 +152,10 @@ public class Commandexp extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
amount = (long)Integer.MAX_VALUE;
|
amount = (long)Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
if (amount < 0 || amount > Integer.MAX_VALUE)
|
||||||
|
{
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
|
}
|
||||||
SetExpFix.setTotalExperience(target, amount.intValue());
|
SetExpFix.setTotalExperience(target, amount.intValue());
|
||||||
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user