mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-09-10 20:29:28 +00:00
Allow negative exp to be given
This commit is contained in:
parent
9cef107bc3
commit
91701e8c2f
|
@ -149,6 +149,7 @@ 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Limit who can give negative exp?
|
||||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException
|
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException
|
||||||
{
|
{
|
||||||
long amount;
|
long amount;
|
||||||
|
@ -167,7 +168,7 @@ public class Commandexp extends EssentialsCommand
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
amount = Long.parseLong(strAmount);
|
amount = Long.parseLong(strAmount);
|
||||||
if (amount < 0 || amount > Integer.MAX_VALUE)
|
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
@ -181,6 +182,10 @@ public class Commandexp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
amount = (long)Integer.MAX_VALUE;
|
amount = (long)Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
if (amount < 0l)
|
||||||
|
{
|
||||||
|
amount = 0l;
|
||||||
|
}
|
||||||
SetExpFix.setTotalExperience(target, (int)amount);
|
SetExpFix.setTotalExperience(target, (int)amount);
|
||||||
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue