mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 23:26:11 +01:00
Better input validation for some Options and Requirements prompts
This commit is contained in:
parent
e5829acad7
commit
7fbd793c85
@ -162,16 +162,14 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
try {
|
||||
boolean b = Boolean.parseBoolean(input);
|
||||
if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase("true")
|
||||
|| input.equalsIgnoreCase(Lang.get("true"))
|
||||
|| input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
b = true;
|
||||
}
|
||||
context.setSessionData(tempKey, b);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (input.startsWith("t") || input.equalsIgnoreCase(Lang.get("true"))
|
||||
|| input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
context.setSessionData(tempKey, true);
|
||||
} else if (input.startsWith("f") || input.equalsIgnoreCase(Lang.get("false"))
|
||||
|| input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||
context.setSessionData(tempKey, false);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new TrueFalsePrompt(plugin, context, factory);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
|
@ -663,18 +663,14 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
|
||||
String[] args = input.split(" ");
|
||||
LinkedList<Boolean> booleans = new LinkedList<Boolean>();
|
||||
for (String s : args) {
|
||||
if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase("true")
|
||||
|| s.equalsIgnoreCase(Lang.get("true"))
|
||||
if (input.startsWith("t") || s.equalsIgnoreCase(Lang.get("true"))
|
||||
|| s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
booleans.add(true);
|
||||
} else if (input.equalsIgnoreCase("f") || input.equalsIgnoreCase("false")
|
||||
|| s.equalsIgnoreCase(Lang.get("false"))
|
||||
} else if (input.startsWith("f") || s.equalsIgnoreCase(Lang.get("false"))
|
||||
|| s.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||
booleans.add(false);
|
||||
} else {
|
||||
String text = Lang.get("reqTrueFalseError");
|
||||
text = text.replace("<input>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + text);
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new RemoveItemsPrompt();
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,6 @@ reqHeroesPrimaryDisplay: "Primary Class:"
|
||||
reqHeroesSecondaryDisplay: "Secondary Class:"
|
||||
reqNotAQuestName: "<quest> is not a Quest name!"
|
||||
reqItemCleared: "Item requirements cleared."
|
||||
reqTrueFalseError: '<input> is not a true or false value!%br%Example: true false true true'
|
||||
reqCustomAlreadyAdded: "That custom requirement has already been added!"
|
||||
reqCustomNotFound: "Custom requirement module not found."
|
||||
reqCustomCleared: "Custom requirements cleared."
|
||||
|
Loading…
Reference in New Issue
Block a user