MinecraftManagerPlugin/src/main/java/xyz/etztech/minecraftmanager/objects/Question.java

86 lines
2.6 KiB
Java

package xyz.etztech.minecraftmanager.objects;
import org.apache.commons.lang.StringUtils;
public enum Question {
ONE("How old are you?", "Your answer must be numeric."),
TWO("What's your favorite thing to do in Minecraft?", "Your answer must be under 300 characters long."),
THREE1("Have you ever been banned? Please answer just 'yes' or 'no'.", "Your answer must be just 'yes' or 'no'."),
THREE2("Oof. That's okay, it's happened to plenty of people. Do you mind letting us know why?", "Your answer must be under 300 characters long."),
FOUR("How did you find out about us? Please give a website or player name, if applicable.", "Your answer must be under 50 characters long."),
FIVE("Last question! Have you read the rules thoroughly?", "Your answer must be under 10 characters long."),
COMPLETE("All done! Staff should be reviewing your application any second now!", "");
public static final String READ_RULES = "Are you sure? Maybe you should read them again...";
private String question;
private String error;
Question(String s, String e) {
question = s;
error = e;
}
public String getQuestion() {
return question;
}
public String getError() {
return error;
}
public static Question last(Question question) {
switch (question) {
case TWO:
return ONE;
case THREE1:
return TWO;
case THREE2:
return THREE1;
case FOUR:
return THREE2;
default:
return FOUR;
}
}
public static Question next(Question question, String answer) {
switch (question) {
case ONE:
return TWO;
case TWO:
return THREE1;
case THREE1:
return answer.equalsIgnoreCase("yes") ? THREE2 : FOUR;
case THREE2:
return FOUR;
case FOUR:
return FIVE;
default:
return COMPLETE;
}
}
public static boolean validate(Question question, String answer) {
switch (question) {
case ONE:
return StringUtils.isNumeric(answer);
case TWO:
case THREE2:
return answer.length() <= 300;
case THREE1:
return answer.equalsIgnoreCase("yes") || answer.equalsIgnoreCase("no");
case FOUR:
return answer.length() <= 50;
case FIVE:
return answer.length() <= 10;
default:
return false;
}
}
}