diff options
author | Iaccidentally <coryhuckaby@gmail.com> | 2012-10-31 16:25:13 -0400 |
---|---|---|
committer | Iaccidentally <coryhuckaby@gmail.com> | 2012-10-31 16:25:13 -0400 |
commit | dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434 (patch) | |
tree | 3ed24290a073d591586a6faf32f94a9110dfb412 | |
parent | 4dc2e2e3fdab32117fafd9133cd39d1e5e6d1ad7 (diff) | |
download | Essentials-dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434.tar Essentials-dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434.tar.gz Essentials-dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434.tar.lz Essentials-dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434.tar.xz Essentials-dcf90cbf5a890bebb2ab551d04a6a60fe1f7d434.zip |
Make /exp accept L before or after the amount, add extra checks
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandexp.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java index f3dac79e2..08fb61ea1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java @@ -125,11 +125,11 @@ public class Commandexp extends EssentialsCommand 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;
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
- if (strAmount.startsWith("l"))
+ if (strAmount.startsWith("l") || strAmount.endsWith("l"))
{
strAmount = strAmount.substring(1);
int neededLevel = Integer.parseInt(strAmount);
@@ -141,7 +141,7 @@ public class Commandexp extends EssentialsCommand SetExpFix.setTotalExperience(target, 0);
}
else {
- amount = Long.parseLong(strAmount);
+ amount = (long)Integer.parseInt(strAmount);
}
if (give)
@@ -152,6 +152,10 @@ public class Commandexp extends EssentialsCommand {
amount = (long)Integer.MAX_VALUE;
}
+ if (amount < 0 || amount > Integer.MAX_VALUE)
+ {
+ throw new NotEnoughArgumentsException();
+ }
SetExpFix.setTotalExperience(target, amount.intValue());
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
}
|