Skip to content

Commit

Permalink
Fix repeating suffix suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
nutyworks committed Mar 28, 2024
1 parent 733a3d2 commit e3244d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ private static Function<SuggestionsBuilder, CompletableFuture<Suggestions>> getS
};
}

private static String removeSuffix(String value) {
if (value.endsWith("d") || value.endsWith("D")) return value.substring(0, value.length() - 1);
return value;
}

public void parse() throws CommandSyntaxException {
final int start = reader().getCursor();
final String value = parentParser.reader().readUnquotedString();
Expand All @@ -40,7 +35,7 @@ public void parse() throws CommandSyntaxException {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedFloat().createWithContext(parentParser.reader());
}
try {
Float.parseFloat(removeSuffix(value));
Double.parseDouble(value);
} catch (NumberFormatException ignored) {
parentParser.reader().setCursor(start);
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerInvalidFloat().createWithContext(parentParser.reader(), value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ private static Function<SuggestionsBuilder, CompletableFuture<Suggestions>> getS
};
}

private static String removeSuffix(String value) {
if (value.endsWith("f") || value.endsWith("F")) return value.substring(0, value.length() - 1);
return value;
}

public void parse() throws CommandSyntaxException {
final int start = parentParser.reader().getCursor();
final String value = parentParser.reader().readUnquotedString();
Expand All @@ -39,7 +34,7 @@ public void parse() throws CommandSyntaxException {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedFloat().createWithContext(parentParser.reader());
}
try {
Float.parseFloat(removeSuffix(value));
Float.parseFloat(value);
} catch (NumberFormatException ignored) {
parentParser.reader().setCursor(start);
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerInvalidFloat().createWithContext(parentParser.reader(), value);
Expand Down

0 comments on commit e3244d3

Please sign in to comment.