Yet another unstable commit

This commit is contained in:
Blackvein 2012-10-17 12:15:56 -07:00
parent c211496a2b
commit 3aee04241e
4 changed files with 31 additions and 11 deletions

View File

@ -428,7 +428,7 @@ public class PlayerListener implements Listener {
}else { }else {
quester.saveData(); quester.saveData();
} }
plugin.questers.add(quester); plugin.questers.put(evt.getPlayer().getName(), quester);
for(String s : quester.completedQuests){ for(String s : quester.completedQuests){

View File

@ -2,6 +2,8 @@ package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import me.blackvein.quests.prompts.RequirementPrompt; import me.blackvein.quests.prompts.RequirementPrompt;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -13,6 +15,7 @@ public class QuestFactory implements ConversationAbandonedListener {
Quests quests; Quests quests;
Map<Player, Quest> editSessions = new HashMap<Player, Quest>(); Map<Player, Quest> editSessions = new HashMap<Player, Quest>();
List<String> names = new LinkedList<String>();
ConversationFactory convoCreator; ConversationFactory convoCreator;
static final ChatColor BOLD = ChatColor.BOLD; static final ChatColor BOLD = ChatColor.BOLD;
static final ChatColor AQUA = ChatColor.AQUA; static final ChatColor AQUA = ChatColor.AQUA;
@ -271,6 +274,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); context.setSessionData("questName", input);
return new CreateMenuPrompt(); return new CreateMenuPrompt();
@ -356,9 +366,19 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override @Override
public Prompt acceptInput(ConversationContext context, String input){ 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); context.setSessionData("questName", input);
}
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} }

View File

@ -46,7 +46,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
NpcListener npcListener; NpcListener npcListener;
Denizen denizen; Denizen denizen;
QuestTaskTrigger trigger; QuestTaskTrigger trigger;
LinkedList<Quester> questers = new LinkedList<Quester>(); Map<String, Quester> questers = new HashMap<String, Quester>();
LinkedList<Quest> quests = new LinkedList<Quest>(); LinkedList<Quest> quests = new LinkedList<Quest>();
LinkedList<NPC> questNPCs = new LinkedList<NPC>(); LinkedList<NPC> questNPCs = new LinkedList<NPC>();
boolean allowCommands = true; boolean allowCommands = true;
@ -163,7 +163,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
questers = getOnlineQuesters(); questers = getOnlineQuesters();
Quester redPower = new Quester(this); Quester redPower = new Quester(this);
redPower.name = "[RedPower]"; redPower.name = "[RedPower]";
questers.add(redPower); questers.put("[RedPower]", redPower);
} }
@ -1249,7 +1249,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
loadQuests(); loadQuests();
loadConfig(); loadConfig();
for (Quester quester : questers) { for (Quester quester : questers.values()) {
quester.checkQuest(); quester.checkQuest();
} }
@ -1259,7 +1259,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
Quester quester = null; Quester quester = null;
for (Quester q : questers) { for (Quester q : questers.values()) {
if (q.name.equalsIgnoreCase(player)) { if (q.name.equalsIgnoreCase(player)) {
quester = q; quester = q;
@ -1282,7 +1282,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (debug == true) { if (debug == true) {
log.log(Level.INFO, "[Quests] Manual data retrieval succeeded for player \"" + player + "\""); 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<Quester> getOnlineQuesters() { public Map<String, Quester> getOnlineQuesters() {
LinkedList<Quester> qs = new LinkedList<Quester>(); Map<String, Quester> qs = new HashMap<String, Quester>();
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
@ -1303,7 +1303,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
} else { } else {
quester.saveData(); quester.saveData();
} }
qs.add(quester); qs.put(p.getName(), quester);
} }

View File

@ -62,7 +62,7 @@ public class RequirementPrompt extends FixedSetPrompt{
for(int i : ids){ 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";
} }
} }