Expand Boolean Prompt Values

This commit is contained in:
Alex Bennett 2013-08-03 19:42:55 +10:00 committed by md_5
parent 5c9d00bad4
commit 5a237b8e57

View File

@ -0,0 +1,28 @@
From 358d6030f9f6bfa6f0d79d2166bfe37067ceea71 Mon Sep 17 00:00:00 2001
From: Alex Bennett <me@alexben.net>
Date: Sat, 3 Aug 2013 19:42:16 +1000
Subject: [PATCH] Expand Boolean Prompt Values
diff --git a/src/main/java/org/bukkit/conversations/BooleanPrompt.java b/src/main/java/org/bukkit/conversations/BooleanPrompt.java
index 3bfd733..cd29a0c 100644
--- a/src/main/java/org/bukkit/conversations/BooleanPrompt.java
+++ b/src/main/java/org/bukkit/conversations/BooleanPrompt.java
@@ -14,12 +14,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 = {"true", "false", "on", "off", "yes", "no" /* Spigot: */, "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"}; // Spigot
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"; // Spigot
return acceptValidatedInput(context, BooleanUtils.toBoolean(input));
}
--
1.8.1.2