Fixed suffix with empty input

This commit is contained in:
Nathan Adams
2017-07-20 13:08:12 +02:00
parent e82d657d26
commit daea2d76d7
2 changed files with 39 additions and 1 deletions
@@ -55,6 +55,11 @@ public class IntegerArgumentType implements ArgumentType<Integer> {
if (end > -1) {
raw = command.substring(0, end);
}
if (raw.length() < suffix.length()) {
throw ERROR_WRONG_SUFFIX.create(this.suffix);
}
String number = raw.substring(0, raw.length() - suffix.length());
String suffix = raw.substring(number.length());
@@ -74,7 +79,7 @@ public class IntegerArgumentType implements ArgumentType<Integer> {
return new FixedParsedArgument<>(raw, value);
} catch (NumberFormatException ignored) {
throw ERROR_NOT_A_NUMBER.create(raw);
throw ERROR_NOT_A_NUMBER.create(number);
}
}