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 acc4bbf13..b58d26001 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java @@ -46,25 +46,28 @@ public class Commandpay extends EssentialsLoopCommand { } 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 000000000..4cff5d32f --- /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 bea0f4151..841428d1a 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -550,6 +550,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}.