Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for the specific modifier instead of last char in string #5638

Open
wants to merge 16 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.earth2me.essentials.commands;

import net.ess3.api.TranslatableException;

public class InvalidModifierException extends TranslatableException {
public InvalidModifierException() {
super("invalidModifier");
}
}
1 change: 1 addition & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ invalidHome=<dark_red>Home<secondary> {0} <dark_red>doesn''t exist\!
invalidHomeName=<dark_red>Invalid home name\!
invalidItemFlagMeta=<dark_red>Invalid itemflag meta\: <secondary>{0}<dark_red>.
invalidMob=<dark_red>Invalid mob type.
invalidModifier=<dark_red>Invalid Modifier.
invalidNumber=Invalid Number.
invalidPotion=<dark_red>Invalid Potion.
invalidPotionMeta=<dark_red>Invalid potion meta\: <secondary>{0}<dark_red>.
Expand Down