Continuing

This commit is contained in:
Blackvein 2014-02-18 20:16:24 -08:00
parent 9cbe3663bf
commit be51074332
7 changed files with 363 additions and 90 deletions

View File

@ -150,7 +150,7 @@ public abstract class CustomObjective implements Listener {
if(index > -1){
if(quester.customObjectiveCounts.get(obj.getName()) >= quester.currentStage.customObjectiveCounts.get(index)){
quester.finishObjective("customObj", null, null, null, null, null, null, null, null, obj);
quester.finishObjective("customObj", null, null, null, null, null, null, null, null, null, obj);
}
}

View File

@ -193,6 +193,12 @@ public class PlayerListener implements Listener {
}
if (quester.hasObjective("password")) {
quester.sayPass(evt.getMessage());
}
}
}

View File

@ -64,6 +64,7 @@ public class Quester {
LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
Map<EntityType, Integer> mobsTamed = new EnumMap<EntityType, Integer>(EntityType.class);
Map<DyeColor, Integer> sheepSheared = new EnumMap<DyeColor, Integer>(DyeColor.class);
Map<String, Boolean> passwordsSaid = new HashMap<String, Boolean>();
public Map<String, Integer> customObjectiveCounts = new HashMap<String, Integer>();
public Map<String, Boolean> eventFired = new HashMap<String, Boolean>();
final Random random = new Random();
@ -151,6 +152,11 @@ public class Quester {
LinkedList<String> finishedObjectives = new LinkedList<String>();
LinkedList<String> objectives = new LinkedList<String>();
if (currentStage.objectiveOverride != null) {
objectives.add(ChatColor.GREEN + currentStage.objectiveOverride);
return objectives;
}
for (Entry<Material, Integer> e : currentStage.blocksToDamage.entrySet()) {
for (Entry<Material, Integer> e2 : blocksDamaged.entrySet()) {
@ -504,6 +510,20 @@ public class Quester {
}
for (String s : currentStage.passwordPhrases) {
if (passwordsSaid.get(s) == false) {
unfinishedObjectives.add(ChatColor.GREEN + currentStage.passwordDisplays.get(currentStage.passwordPhrases.indexOf(s)));
} else {
finishedObjectives.add(ChatColor.GRAY + currentStage.passwordDisplays.get(currentStage.passwordPhrases.indexOf(s)));
}
}
int index = 0;
for (CustomObjective co : currentStage.customObjectives) {
@ -514,18 +534,17 @@ public class Quester {
String display = co.getDisplay();
Map<String, Object> datamap = currentStage.customObjectiveData.get(index);
for(String key : co.datamap.keySet()){
for (String key : co.datamap.keySet()) {
display = display.replaceAll("%" + ((String) key) + "%", ((String) datamap.get(key)));
}
if (entry.getValue() < currentStage.customObjectiveCounts.get(index)){
if(co.isCountShown() && co.isEnableCount()){
if (entry.getValue() < currentStage.customObjectiveCounts.get(index)) {
if (co.isCountShown() && co.isEnableCount()) {
display = display.replaceAll("%count%", entry.getValue() + "/" + currentStage.customObjectiveCounts.get(index));
}
unfinishedObjectives.add(ChatColor.GREEN + display);
}else{
if(co.isCountShown() && co.isEnableCount()){
} else {
if (co.isCountShown() && co.isEnableCount()) {
display = display.replaceAll("%count%", currentStage.customObjectiveCounts.get(index) + "/" + currentStage.customObjectiveCounts.get(index));
}
finishedObjectives.add(ChatColor.GRAY + display);
@ -597,6 +616,9 @@ public class Quester {
} else if (s.equalsIgnoreCase("craftItem")) {
return !currentStage.itemsToCraft.isEmpty();
} else if (s.equalsIgnoreCase("password")) {
return !currentStage.passwordPhrases.isEmpty();
} else {
return !currentStage.locationsToReach.isEmpty();
@ -604,15 +626,15 @@ public class Quester {
}
public boolean hasCustomObjective(String s){
public boolean hasCustomObjective(String s) {
if(customObjectiveCounts.containsKey(s)){
if (customObjectiveCounts.containsKey(s)) {
int count = customObjectiveCounts.get(s);
int index = -1;
for(int i = 0; i < currentStage.customObjectives.size(); i++){
if(currentStage.customObjectives.get(i).getName().equals(s)){
for (int i = 0; i < currentStage.customObjectives.size(); i++) {
if (currentStage.customObjectives.get(i).getName().equals(s)) {
index = i;
break;
}
@ -637,7 +659,7 @@ public class Quester {
blocksDamaged.put(m, (i + 1));
if (blocksDamaged.get(m).equals(currentStage.blocksToDamage.get(m))) {
finishObjective("damageBlock", m, null, null, null, null, null, null, null, null);
finishObjective("damageBlock", m, null, null, null, null, null, null, null, null, null);
}
}
@ -655,7 +677,7 @@ public class Quester {
blocksBroken.put(m, (i + 1));
if (blocksBroken.get(m).equals(currentStage.blocksToBreak.get(m))) {
finishObjective("breakBlock", m, null, null, null, null, null, null, null, null);
finishObjective("breakBlock", m, null, null, null, null, null, null, null, null, null);
}
}
@ -672,7 +694,7 @@ public class Quester {
blocksPlaced.put(m, (i + 1));
if (blocksPlaced.get(m).equals(currentStage.blocksToPlace.get(m))) {
finishObjective("placeBlock", m, null, null, null, null, null, null, null, null);
finishObjective("placeBlock", m, null, null, null, null, null, null, null, null, null);
}
}
@ -689,7 +711,7 @@ public class Quester {
blocksUsed.put(m, (i + 1));
if (blocksUsed.get(m).equals(currentStage.blocksToUse.get(m))) {
finishObjective("useBlock", m, null, null, null, null, null, null, null, null);
finishObjective("useBlock", m, null, null, null, null, null, null, null, null, null);
}
}
@ -707,7 +729,7 @@ public class Quester {
blocksCut.put(m, (i + 1));
if (blocksCut.get(m).equals(currentStage.blocksToCut.get(m))) {
finishObjective("cutBlock", m, null, null, null, null, null, null, null, null);
finishObjective("cutBlock", m, null, null, null, null, null, null, null, null, null);
}
}
@ -722,7 +744,7 @@ public class Quester {
fishCaught++;
if (((Integer) fishCaught).equals(currentStage.fishToCatch)) {
finishObjective("catchFish", null, null, null, null, null, null, null, null, null);
finishObjective("catchFish", null, null, null, null, null, null, null, null, null, null);
}
}
@ -745,7 +767,7 @@ public class Quester {
itemsEnchanted.put(entry.getKey(), num);
if (num.equals(entry2.getValue())) {
finishObjective("enchantItem", m, null, e, null, null, null, null, null, null);
finishObjective("enchantItem", m, null, e, null, null, null, null, null, null, null);
}
}
@ -786,7 +808,7 @@ public class Quester {
mobNumKilled.set(index, numKilledInteger);
if ((numKilledInteger).equals(currentStage.mobNumToKill.get(index))) {
finishObjective("killMob", null, null, null, e, null, null, null, null, null);
finishObjective("killMob", null, null, null, e, null, null, null, null, null, null);
}
}
@ -804,7 +826,7 @@ public class Quester {
mobNumKilled.set(mobsKilled.indexOf(e), mobNumKilled.get(mobsKilled.indexOf(e)) + 1);
if ((mobNumKilled.get(mobsKilled.indexOf(e))).equals(currentStage.mobNumToKill.get(mobsKilled.indexOf(e)))) {
finishObjective("killMob", null, null, null, e, null, null, null, null, null);
finishObjective("killMob", null, null, null, e, null, null, null, null, null, null);
}
}
@ -838,7 +860,7 @@ public class Quester {
playersKilled++;
if (((Integer) playersKilled).equals(currentStage.playersToKill)) {
finishObjective("killPlayer", null, null, null, null, null, null, null, null, null);
finishObjective("killPlayer", null, null, null, null, null, null, null, null, null, null);
}
}
@ -851,7 +873,7 @@ public class Quester {
if (citizensInteracted.get(n.getId()) == false) {
citizensInteracted.put(n.getId(), true);
finishObjective("talkToNPC", null, null, null, null, null, n, null, null, null);
finishObjective("talkToNPC", null, null, null, null, null, n, null, null, null, null);
}
}
@ -866,7 +888,7 @@ public class Quester {
if (citizenNumKilled.get(index) < currentStage.citizenNumToKill.get(index)) {
citizenNumKilled.set(index, citizenNumKilled.get(index) + 1);
if (citizenNumKilled.get(index) == currentStage.citizenNumToKill.get(index)) {
finishObjective("killNPC", null, null, null, null, null, n, null, null, null);
finishObjective("killNPC", null, null, null, null, null, n, null, null, null, null);
}
}
@ -890,7 +912,7 @@ public class Quester {
if (hasReached.get(index) == false) {
hasReached.set(index, true);
finishObjective("reachLocation", null, null, null, null, null, null, location, null, null);
finishObjective("reachLocation", null, null, null, null, null, null, location, null, null, null);
}
@ -911,7 +933,7 @@ public class Quester {
mobsTamed.put(entity, (mobsTamed.get(entity) + 1));
if (mobsTamed.get(entity).equals(currentStage.mobsToTame.get(entity))) {
finishObjective("tameMob", null, null, null, entity, null, null, null, null, null);
finishObjective("tameMob", null, null, null, entity, null, null, null, null, null, null);
}
}
@ -925,7 +947,7 @@ public class Quester {
sheepSheared.put(color, (sheepSheared.get(color) + 1));
if (sheepSheared.get(color).equals(currentStage.sheepToShear.get(color))) {
finishObjective("shearSheep", null, null, null, null, null, null, null, color, null);
finishObjective("shearSheep", null, null, null, null, null, null, null, color, null, null);
}
}
@ -960,14 +982,14 @@ public class Quester {
i.setAmount(i.getAmount() - (req - amount)); //Take away the remaining amount needed to be delivered from the item stack
player.getInventory().setItem(index, i);
player.updateInventory();
finishObjective("deliverItem", null, found, null, null, null, null, null, null, null);
finishObjective("deliverItem", null, found, null, null, null, null, null, null, null, null);
} else if ((i.getAmount() + amount) == req) {
itemsDelivered.put(found, req);
player.getInventory().setItem(player.getInventory().first(i), null);
player.updateInventory();
finishObjective("deliverItem", null, found, null, null, null, null, null, null, null);
finishObjective("deliverItem", null, found, null, null, null, null, null, null, null, null);
} else {
@ -985,11 +1007,46 @@ public class Quester {
}
public void finishObjective(String objective, Material material, ItemStack itemstack, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, CustomObjective co) {
public void sayPass(String s) {
for (String pass : currentStage.passwordPhrases) {
if (pass.equalsIgnoreCase(s)) {
String display = currentStage.passwordDisplays.get(currentStage.passwordPhrases.indexOf(pass));
passwordsSaid.put(pass, true);
finishObjective("password", null, null, null, null, null, null, null, null, display, null);
}
}
}
public void finishObjective(String objective, Material material, ItemStack itemstack, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) {
Player p = plugin.getServer().getPlayerExact(name);
if (objective.equalsIgnoreCase("damageBlock")) {
if (currentStage.objectiveOverride != null) {
if (testComplete()) {
String message = ChatColor.GREEN + "(Completed) " + currentStage.objectiveOverride;
p.sendMessage(message);
currentQuest.nextStage(this);
}
return;
}
if (objective.equalsIgnoreCase("password")) {
String message = ChatColor.GREEN + "(Completed) " + pass;
p.sendMessage(message);
if (testComplete()) {
currentQuest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("damageBlock")) {
String message = ChatColor.GREEN + "(Completed) Damage " + prettyItemString(material.getId());
message = message + " " + currentStage.blocksToDamage.get(material) + "/" + currentStage.blocksToDamage.get(material);
@ -1136,20 +1193,21 @@ public class Quester {
String message = ChatColor.GREEN + "(Completed) " + co.getDisplay();
int index = -1;
for(int i = 0; i < currentStage.customObjectives.size(); i++){
if(currentStage.customObjectives.get(i).getName().equals(co.getName())){
for (int i = 0; i < currentStage.customObjectives.size(); i++) {
if (currentStage.customObjectives.get(i).getName().equals(co.getName())) {
index = i;
break;
}
}
Map<String, Object> datamap = currentStage.customObjectiveData.get(index);
for(String key : co.datamap.keySet()){
for (String key : co.datamap.keySet()) {
message = message.replaceAll("%" + ((String) key) + "%", (String) datamap.get(key));
}
if(co.isCountShown() && co.isEnableCount())
if (co.isCountShown() && co.isEnableCount()) {
message = message.replaceAll("%count%", currentStage.customObjectiveCounts.get(index) + "/" + currentStage.customObjectiveCounts.get(index));
}
p.sendMessage(message);
if (testComplete()) {
currentQuest.nextStage(this);
@ -1301,8 +1359,14 @@ public class Quester {
}
}
if (currentStage.passwordPhrases.isEmpty() == false) {
for (String pass : currentStage.passwordPhrases) {
passwordsSaid.put(pass, false);
}
}
if (currentStage.customObjectives.isEmpty() == false) {
for(CustomObjective co : currentStage.customObjectives){
for (CustomObjective co : currentStage.customObjectives) {
customObjectiveCounts.put(co.getName(), 0);
}
}
@ -1911,12 +1975,29 @@ public class Quester {
}
if (customObjectiveCounts.isEmpty() == false){
if (passwordsSaid.isEmpty() == false) {
LinkedList<String> passwords = new LinkedList<String>();
LinkedList<Boolean> said = new LinkedList<Boolean>();
for (Entry<String, Boolean> entry : passwordsSaid.entrySet()) {
passwords.add(entry.getKey());
said.add(entry.getValue());
}
data.set("passwords", passwords);
data.set("passwords-said", said);
}
if (customObjectiveCounts.isEmpty() == false) {
LinkedList<String> customObj = new LinkedList<String>();
LinkedList<Integer> customObjCounts = new LinkedList<Integer>();
for(Entry<String, Integer> entry : customObjectiveCounts.entrySet()){
for (Entry<String, Integer> entry : customObjectiveCounts.entrySet()) {
customObj.add(entry.getKey());
customObjCounts.add(entry.getValue());
@ -2565,12 +2646,22 @@ public class Quester {
}
if (data.contains("custom-objectives")){
if (data.contains("passwords")) {
List<String> passwords = data.getStringList("passwords");
List<Boolean> said = data.getBooleanList("passwords-said");
for(int i = 0; i < passwords.size(); i++){
passwordsSaid.put(passwords.get(i), said.get(i));
}
}
if (data.contains("custom-objectives")) {
List<String> customObj = data.getStringList("custom-objectives");
List<Integer> customObjCount = data.getIntegerList("custom-objective-counts");
for(int i = 0; i < customObj.size(); i++){
for (int i = 0; i < customObj.size(); i++) {
customObjectiveCounts.put(customObj.get(i), customObjCount.get(i));
}

View File

@ -3268,6 +3268,32 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".password-displays")) {
List<String> displays = config.getStringList("quests." + s + ".stages.ordered." + s2 + ".password-displays");
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".password-phrases")) {
List<String> phrases = config.getStringList("quests." + s + ".stages.ordered." + s2 + ".password-phrases");
if(displays.size() == phrases.size()) {
oStage.passwordDisplays.addAll(displays);
oStage.passwordPhrases.addAll(phrases);
} else {
printSevere("[Quests] password-displays and password-phrases in Stage " + s2 + " of Quest " + quest.name + " are not the same size!");
stageFailed = true;
break;
}
} else {
printSevere("[Quests] Stage " + s2 + " of Quest " + quest.name + " is missing password-phrases!");
stageFailed = true;
break;
}
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".custom-objectives")) {
ConfigurationSection sec = config.getConfigurationSection("quests." + s + ".stages.ordered." + s2 + ".custom-objectives");
@ -3317,6 +3343,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".objective-override")) {
oStage.objectiveOverride = config.getString("quests." + s + ".stages.ordered." + s2 + ".objective-override");
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".start-event")) {
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".start-event"), this);

View File

@ -117,7 +117,8 @@ public class Stage {
public LinkedList<Integer> customObjectiveCounts = new LinkedList<Integer>();
public LinkedList<String> customObjectiveDisplays = new LinkedList<String>();
public LinkedList<Map<String, Object>> customObjectiveData = new LinkedList<Map<String, Object>>();
public LinkedList<String>
public LinkedList<String> passwordDisplays = new LinkedList<String>();
public LinkedList<String> passwordPhrases = new LinkedList<String>();
public String script;
public Event startEvent = null;
public Event deathEvent = null;
@ -257,6 +258,22 @@ public class Stage {
return false;
}
if (other.customObjectiveDisplays.equals(customObjectiveDisplays) == false) {
return false;
}
if (other.customObjectiveData.equals(customObjectiveData) == false) {
return false;
}
if (other.passwordDisplays.equals(passwordDisplays) == false) {
return false;
}
if (other.passwordPhrases.equals(passwordPhrases) == false) {
return false;
}
if (other.script != null && script != null) {
if (other.script.equals(script) == false) {
return false;

View File

@ -40,7 +40,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
public CreateStagePrompt(int stageNum, QuestFactory qf, CitizensPlugin cit) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26");
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.citizens = cit;
@ -315,30 +315,47 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) {
text += PINK + "" + BOLD + "20 " + RESET + PINK + "- Password Objectives" + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
LinkedList<String> passPhrases = (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
LinkedList<String> passDisplays = (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS);
text += PINK + "" + BOLD + "20 " + RESET + PINK + "- Password Objectives\n";
for(int i = 0; i < passPhrases.size(); i++){
text += AQUA + " - " + ITALIC + "\"" + passDisplays.get(i) + "\"" + RESET + DARKAQUA + "(" + passPhrases.get(i) + ")" + "\n";
}
}
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) {
text += PINK + "" + BOLD + "20 " + RESET + PINK + "- Custom Objectives" + GRAY + " (" + Lang.get("noneSet") + ")\n";
text += PINK + "" + BOLD + "21 " + RESET + PINK + "- Custom Objectives" + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
text += PINK + "" + BOLD + "20 " + RESET + PINK + "- Custom Objectives" + GRAY + " (" + Lang.get("noneSet") + ")\n";
text += PINK + "" + BOLD + "21 " + RESET + PINK + "- Custom Objectives\n";
for(String s : customObjs){
text += PINK + " - " + GOLD + s + "\n";
}
}
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
text += PINK + "" + BOLD + "21 " + RESET + PURPLE + "- " + Lang.get("stageEditorStartMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorStartMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += PINK + "" + BOLD + "21 " + RESET + PURPLE + "- " + Lang.get("stageEditorStartMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + GRAY + ")\n";
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorStartMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + GRAY + ")\n";
}
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
text += PINK + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + GRAY + ")\n";
text += PINK + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + GRAY + ")\n";
}
text += RED + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
text += GREEN + "" + BOLD + "24 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
text += PINK + "" + BOLD + "24 " + RESET + PURPLE + "- Objective Display Override " + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += PINK + "" + BOLD + "24 " + RESET + PURPLE + "- Objective Display Override " + GRAY + "(" + DARKAQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + GRAY + ")\n";
}
text += RED + "" + BOLD + "25 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
text += GREEN + "" + BOLD + "26 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
return text;
@ -411,14 +428,18 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new DenizenPrompt();
}
} else if (input.equalsIgnoreCase("20")) {
return new CustomObjectivesPrompt();
return new PasswordListPrompt();
} else if (input.equalsIgnoreCase("21")) {
return new StartMessagePrompt();
return new CustomObjectivesPrompt();
} else if (input.equalsIgnoreCase("22")) {
return new CompleteMessagePrompt();
return new StartMessagePrompt();
} else if (input.equalsIgnoreCase("23")) {
return new DeletePrompt();
return new CompleteMessagePrompt();
} else if (input.equalsIgnoreCase("24")) {
return new OverrideDisplayPrompt();
} else if (input.equalsIgnoreCase("25")) {
return new DeletePrompt();
} else if (input.equalsIgnoreCase("26")) {
return new StagesPrompt(questFactory);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -426,6 +447,109 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
private class PasswordListPrompt extends FixedSetPrompt {
public PasswordListPrompt() {
super("1", "2", "3", "4");
}
@Override
public String getPromptText(ConversationContext context) {
String text = GOLD + "- Password Objectives -\n";
if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) == null) {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add password display (" + Lang.get("noneSet") + ")\n";
text += GRAY + "2 - " + "Add password phrase (No password displays set)\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done");
} else {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add password display\n";
for (String display : getPasswordDisplays(context)) {
text += GRAY + " - " + AQUA + display + "\n";
}
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) {
text += GRAY + "2 - " + "Add password phrase (" + Lang.get("noneSet") + ")\n";
} else {
text += GRAY + "2 - " + "Add password phrase\n";
for (String phrase : getPasswordPhrases(context)) {
text += GRAY + " - " + DARKAQUA + phrase + "\n";
}
}
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done");
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new PasswordDisplayPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) == null) {
context.getForWhom().sendRawMessage(RED + "You must add at least one password display first!");
return new PasswordListPrompt();
} else {
return new PasswordPhrasePrompt();
}
} else if (input.equalsIgnoreCase("3")) {
context.getForWhom().sendRawMessage(YELLOW + "Password Objectives cleared.");
context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null);
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, null);
return new PasswordListPrompt();
} else if (input.equalsIgnoreCase("4")) {
int one;
int two;
if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null) {
one = ((List<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS)).size();
} else {
one = 0;
}
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) {
two = ((List<String>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES)).size();
} else {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(RED + "The password display and password phrase lists are not the same size!");
return new PasswordListPrompt();
}
}
return null;
}
private List<String> getPasswordDisplays(ConversationContext context) {
return (List<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS);
}
private List<String> getPasswordPhrases(ConversationContext context) {
return (List<String>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
}
}
private class BreakBlockListPrompt extends FixedSetPrompt {
public BreakBlockListPrompt() {

View File

@ -98,6 +98,9 @@ public class CK {
public static final String S_DENIZEN = "denizen";
public static final String S_COMPLETE_MESSAGE = "completeMessage";
public static final String S_START_MESSAGE = "startMessage";
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
public static final String S_CUSTOM_OBJECTIVES_COUNT = "customObjectiveCounts";
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";