Expand Boolean Prompt Values in Conversation API

By: md_5 <md_5@live.com.au>
This commit is contained in:
Bukkit/Spigot 2018-12-26 08:00:00 +11:00
parent e58ce0019f
commit b48983bff8

View file

@ -15,12 +15,13 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
@Override
protected boolean isInputValid(ConversationContext context, String input) {
String[] accepted = {"true", "false", "on", "off", "yes", "no"};
String[] accepted = {/* Apache values: */"true", "false", "on", "off", "yes", "no",/* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
return ArrayUtils.contains(accepted, input.toLowerCase());
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("y") || input.equals("1") || input.equalsIgnoreCase("right") || input.equalsIgnoreCase("correct") || input.equalsIgnoreCase("valid")) input = "true";
return acceptValidatedInput(context, BooleanUtils.toBoolean(input));
}