From 918d54f4668aebfa78d4817a935993df316abf30 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:28:46 +0800 Subject: [PATCH] Only allow proper true/false strings to be parsed --- .../functions/DefaultStringParserProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/configuration/functions/DefaultStringParserProvider.java b/src/main/java/org/mvplugins/multiverse/core/configuration/functions/DefaultStringParserProvider.java index a7d19341a..464ebaeac 100644 --- a/src/main/java/org/mvplugins/multiverse/core/configuration/functions/DefaultStringParserProvider.java +++ b/src/main/java/org/mvplugins/multiverse/core/configuration/functions/DefaultStringParserProvider.java @@ -47,7 +47,11 @@ public static NodeStringParser getDefaultStringParser(Class clazz) { () -> input); private static final NodeStringParser 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_STRING_PARSER = (input, type) -> Try.of( () -> ACFUtil.parseInt(input))