Skip to content

Commit

Permalink
Only allow proper true/false strings to be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
benwoo1110 committed Jan 9, 2025
1 parent 9e38142 commit 918d54f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public static <T> NodeStringParser<T> getDefaultStringParser(Class<T> clazz) {
() -> input);

private static final NodeStringParser<Boolean> BOOLEAN_STRING_PARSER = (input, type) -> Try.of(
() -> ACFUtil.isTruthy(String.valueOf(input).toLowerCase()));
() -> switch (String.valueOf(input).toLowerCase()) {
case "t", "true", "on", "y", "yes", "1", "allow" -> true;
case "f", "false", "off", "n", "no", "0", "deny" -> false;
default -> throw new MultiverseException("Unable to convert '" + input + "' to boolean. Please use 'true' or 'false'");
});

private static final NodeStringParser<Integer> INTEGER_STRING_PARSER = (input, type) -> Try.of(
() -> ACFUtil.parseInt(input))
Expand Down

0 comments on commit 918d54f

Please sign in to comment.