diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java index 38778c2fa1a..5bd6b3bd55d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java @@ -45,25 +45,28 @@ public void run(final Server server, final User user, final String commandLabel, } BigDecimal tempAmount = new BigDecimal(sanitizedString); - switch (Character.toLowerCase(ogStr.charAt(ogStr.length() - 1))) { - case 'k': { + switch (ogStr.replace(sanitizedString, "")) { + case "": { + break; + } + case "k": { tempAmount = tempAmount.multiply(THOUSAND); break; } - case 'm': { + case "m": { tempAmount = tempAmount.multiply(MILLION); break; } - case 'b': { + case "b": { tempAmount = tempAmount.multiply(BILLION); break; } - case 't': { + case "t": { tempAmount = tempAmount.multiply(TRILLION); break; } default: { - break; + throw new InvalidModifierException(); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/InvalidModifierException.java b/Essentials/src/main/java/com/earth2me/essentials/commands/InvalidModifierException.java new file mode 100644 index 00000000000..4cff5d32fc7 --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/InvalidModifierException.java @@ -0,0 +1,9 @@ +package com.earth2me.essentials.commands; + +import net.ess3.api.TranslatableException; + +public class InvalidModifierException extends TranslatableException { + public InvalidModifierException() { + super("invalidModifier"); + } +} diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index f58243cf019..111ed74d4af 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -549,6 +549,7 @@ invalidHome=Home {0} doesn''t exist\! invalidHomeName=Invalid home name\! invalidItemFlagMeta=Invalid itemflag meta\: {0}. invalidMob=Invalid mob type. +invalidModifier=Invalid Modifier. invalidNumber=Invalid Number. invalidPotion=Invalid Potion. invalidPotionMeta=Invalid potion meta\: {0}.