From 91701e8c2f34a98b62dfec0d769731118b1a3927 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 21 Jan 2013 14:15:53 +0000 Subject: Allow negative exp to be given --- Essentials/src/com/earth2me/essentials/commands/Commandexp.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java index fc043f3a0..e8c187d29 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java @@ -149,6 +149,7 @@ public class Commandexp extends EssentialsCommand 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 { long amount; @@ -167,7 +168,7 @@ public class Commandexp extends EssentialsCommand else { amount = Long.parseLong(strAmount); - if (amount < 0 || amount > Integer.MAX_VALUE) + if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE) { throw new NotEnoughArgumentsException(); } @@ -181,6 +182,10 @@ public class Commandexp extends EssentialsCommand { amount = (long)Integer.MAX_VALUE; } + if (amount < 0l) + { + amount = 0l; + } SetExpFix.setTotalExperience(target, (int)amount); sender.sendMessage(_("expSet", target.getDisplayName(), amount)); } -- cgit v1.2.3