From 67f01ce4b6d6b2b02cf9dc3ffda60a67a66e7c38 Mon Sep 17 00:00:00 2001 From: Blackvein Date: Tue, 16 Oct 2012 10:42:21 -0700 Subject: [PATCH] Unstable commit --- src/me/blackvein/quests/QuestFactory.java | 9 +++ .../quests/prompts/RequirementPrompt.java | 65 +++++++++++++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/me/blackvein/quests/QuestFactory.java b/src/me/blackvein/quests/QuestFactory.java index ff6d363f4..f9c554cbd 100644 --- a/src/me/blackvein/quests/QuestFactory.java +++ b/src/me/blackvein/quests/QuestFactory.java @@ -3,6 +3,7 @@ package me.blackvein.quests; import java.io.File; import java.util.HashMap; import java.util.Map; +import me.blackvein.quests.prompts.RequirementPrompt; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.conversations.*; @@ -203,7 +204,15 @@ public class QuestFactory implements ConversationAbandonedListener { }else if(input.equalsIgnoreCase("6")){ + if(quests.citizens == null){ + return new RequirementPrompt(quests); + } + }else if(input.equalsIgnoreCase("7")){ + + if(quests.citizens != null){ + return new RequirementPrompt(quests); + } } diff --git a/src/me/blackvein/quests/prompts/RequirementPrompt.java b/src/me/blackvein/quests/prompts/RequirementPrompt.java index add3bb582..876d30069 100644 --- a/src/me/blackvein/quests/prompts/RequirementPrompt.java +++ b/src/me/blackvein/quests/prompts/RequirementPrompt.java @@ -53,6 +53,20 @@ public class RequirementPrompt extends FixedSetPrompt{ text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement (" + context.getSessionData("questPointsReq") + " Quest Points)\n"; } + if(context.getSessionData("itemIdReqs") == null) + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set Item requirements (None set)\n"; + else{ + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set Item requirements"; + List ids = (List) context.getSessionData("itemIdReqs"); + List amounts = (List) context.getSessionData("itemAmountReqs"); + + for(int i : ids){ + + text += GRAY + "\t- " + AQUA + Quester.prettyItemString(i) + YELLOW + " x " + AQUA + amounts.get(ids.indexOf(i)); + + } + } + return text; @@ -65,6 +79,8 @@ public class RequirementPrompt extends FixedSetPrompt{ return new MoneyPrompt(); }else if(input.equalsIgnoreCase("2")){ return new QuestPointsPrompt(); + }else if(input.equalsIgnoreCase("3")){ + return new ItemListPrompt(); } return null; @@ -122,7 +138,7 @@ public class RequirementPrompt extends FixedSetPrompt{ public ItemListPrompt(){ - super("1", "2", "3"); + super("1", "2", "3", "4"); } @@ -133,7 +149,8 @@ public class RequirementPrompt extends FixedSetPrompt{ if(context.getSessionData("itemIdReqs") == null){ text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item IDs (None set)\n"; text += GRAY + "2 - Set item amounts (No IDs set)\n"; - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Done"; + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done"; }else{ text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item IDs\n"; @@ -144,10 +161,10 @@ public class RequirementPrompt extends FixedSetPrompt{ } if(context.getSessionData("itemAmountReqs") == null){ - text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item amounts (None set)\n"; + text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set item amounts (None set)\n"; }else{ - text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item amounts\n"; + text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set item amounts\n"; for(Integer i : getItemAmounts(context)){ text += GRAY + "\t- " + AQUA + i; @@ -156,6 +173,8 @@ public class RequirementPrompt extends FixedSetPrompt{ } + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done"; } @@ -167,7 +186,21 @@ public class RequirementPrompt extends FixedSetPrompt{ protected Prompt acceptValidatedInput(ConversationContext context, String input){ if(input.equalsIgnoreCase("1")){ - + return new ItemIdsPrompt(); + }else if(input.equalsIgnoreCase("2")){ + if(context.getSessionData("itemIdReqs") == null){ + context.getForWhom().sendRawMessage(RED + "You must set item IDs first!"); + return new ItemListPrompt(); + }else{ + return new ItemAmountsPrompt(); + } + }else if(input.equalsIgnoreCase("3")){ + context.getForWhom().sendRawMessage(YELLOW + "Item requirements cleared."); + context.setSessionData("itemIdReqs", null); + context.setSessionData("itemAmountReqs", null); + return new ItemListPrompt(); + }else if(input.equalsIgnoreCase("4")){ + return new RequirementPrompt(quests); } return null; @@ -201,9 +234,16 @@ public class RequirementPrompt extends FixedSetPrompt{ try{ - if(Material.getMaterial(Integer.parseInt(s)) != null) - ids.add(Integer.parseInt(s)); - else{ + if(Material.getMaterial(Integer.parseInt(s)) != null){ + + if(ids.contains(Integer.parseInt(s)) == false){ + ids.add(Integer.parseInt(s)); + }else{ + context.getForWhom().sendRawMessage(RED + " List contains duplicates!"); + return new ItemIdsPrompt(); + } + + }else{ context.getForWhom().sendRawMessage(PINK + s + RED + " is not a valid item ID!"); return new ItemIdsPrompt(); } @@ -219,18 +259,17 @@ public class RequirementPrompt extends FixedSetPrompt{ } - return new RequirementPrompt(quests); + return new ItemListPrompt(); } - } private class ItemAmountsPrompt extends StringPrompt { @Override public String getPromptText(ConversationContext context){ - return YELLOW + "Enter item amounts, seperating each one by a space, or enter \'cancel\' to return."; + return YELLOW + "Enter item amounts (numbers), separating each one by a space, or enter \'cancel\' to return."; } @Override @@ -253,7 +292,7 @@ public class RequirementPrompt extends FixedSetPrompt{ }catch (Exception e){ context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!"); - return new ItemIdsPrompt(); + return new ItemAmountsPrompt(); } } @@ -262,7 +301,7 @@ public class RequirementPrompt extends FixedSetPrompt{ } - return new RequirementPrompt(quests); + return new ItemListPrompt(); }