diff --git a/src/me/blackvein/quests/PlayerListener.java b/src/me/blackvein/quests/PlayerListener.java index 2411a63d5..69801d2aa 100644 --- a/src/me/blackvein/quests/PlayerListener.java +++ b/src/me/blackvein/quests/PlayerListener.java @@ -428,7 +428,7 @@ public class PlayerListener implements Listener { }else { quester.saveData(); } - plugin.questers.add(quester); + plugin.questers.put(evt.getPlayer().getName(), quester); for(String s : quester.completedQuests){ diff --git a/src/me/blackvein/quests/QuestFactory.java b/src/me/blackvein/quests/QuestFactory.java index b59c4e424..906a6427e 100644 --- a/src/me/blackvein/quests/QuestFactory.java +++ b/src/me/blackvein/quests/QuestFactory.java @@ -2,6 +2,8 @@ package me.blackvein.quests; import java.io.File; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import me.blackvein.quests.prompts.RequirementPrompt; import org.bukkit.ChatColor; @@ -13,6 +15,7 @@ public class QuestFactory implements ConversationAbandonedListener { Quests quests; Map editSessions = new HashMap(); + List names = new LinkedList(); ConversationFactory convoCreator; static final ChatColor BOLD = ChatColor.BOLD; static final ChatColor AQUA = ChatColor.AQUA; @@ -270,6 +273,13 @@ public class QuestFactory implements ConversationAbandonedListener { } } + + if(names.contains(input)){ + + context.getForWhom().sendRawMessage(ChatColor.RED + "Someone is creating/editing a Quest with that name!"); + return new QuestNamePrompt(); + + } context.setSessionData("questName", input); return new CreateMenuPrompt(); @@ -356,8 +366,18 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public Prompt acceptInput(ConversationContext context, String input){ - if(input.equalsIgnoreCase("cancel") == false) + if(input.equalsIgnoreCase("cancel") == false){ + + for(Quest q : quests.quests){ + + if(q.name.equalsIgnoreCase(input)){ + s + } + + } context.setSessionData("questName", input); + + } return new CreateMenuPrompt(); diff --git a/src/me/blackvein/quests/Quests.java b/src/me/blackvein/quests/Quests.java index 2b918b674..3d01aa6ff 100644 --- a/src/me/blackvein/quests/Quests.java +++ b/src/me/blackvein/quests/Quests.java @@ -46,7 +46,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ NpcListener npcListener; Denizen denizen; QuestTaskTrigger trigger; - LinkedList questers = new LinkedList(); + Map questers = new HashMap(); LinkedList quests = new LinkedList(); LinkedList questNPCs = new LinkedList(); boolean allowCommands = true; @@ -163,7 +163,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ questers = getOnlineQuesters(); Quester redPower = new Quester(this); redPower.name = "[RedPower]"; - questers.add(redPower); + questers.put("[RedPower]", redPower); } @@ -1249,7 +1249,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ loadQuests(); loadConfig(); - for (Quester quester : questers) { + for (Quester quester : questers.values()) { quester.checkQuest(); } @@ -1259,7 +1259,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ Quester quester = null; - for (Quester q : questers) { + for (Quester q : questers.values()) { if (q.name.equalsIgnoreCase(player)) { quester = q; @@ -1282,7 +1282,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ if (debug == true) { log.log(Level.INFO, "[Quests] Manual data retrieval succeeded for player \"" + player + "\""); } - questers.add(quester); + questers.put(player, quester); } } @@ -1290,9 +1290,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ } - public LinkedList getOnlineQuesters() { + public Map getOnlineQuesters() { - LinkedList qs = new LinkedList(); + Map qs = new HashMap(); for (Player p : getServer().getOnlinePlayers()) { @@ -1303,7 +1303,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{ } else { quester.saveData(); } - qs.add(quester); + qs.put(p.getName(), quester); } diff --git a/src/me/blackvein/quests/prompts/RequirementPrompt.java b/src/me/blackvein/quests/prompts/RequirementPrompt.java index 4630dd15a..cae64b10e 100644 --- a/src/me/blackvein/quests/prompts/RequirementPrompt.java +++ b/src/me/blackvein/quests/prompts/RequirementPrompt.java @@ -62,7 +62,7 @@ public class RequirementPrompt extends FixedSetPrompt{ for(int i : ids){ - text += GRAY + " - " + AQUA + Quester.prettyItemString(i) + YELLOW + " x " + AQUA + amounts.get(ids.indexOf(i)); + text += GRAY + " - " + AQUA + Quester.prettyItemString(i) + YELLOW + " x " + AQUA + amounts.get(ids.indexOf(i)) + "\n"; } }