mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 03:25:20 +01:00
Better tracking of quests, actions, and NPCs being selected
This commit is contained in:
parent
13bcb4d9ac
commit
fcb1900e57
@ -20,6 +20,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -71,8 +72,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
private Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
|
||||
private Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
|
||||
private Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
|
||||
private HashSet<Player> selectingNpcs = new HashSet<Player>();
|
||||
private List<String> names = new LinkedList<String>();
|
||||
private Set<UUID> selectingNpcs = new HashSet<UUID>();
|
||||
private List<String> editingQuestNames = new LinkedList<String>();
|
||||
|
||||
public QuestFactory(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -107,20 +108,34 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
this.selectedReachLocations = selectedReachLocations;
|
||||
}
|
||||
|
||||
public HashSet<Player> getSelectingNpcs() {
|
||||
public Set<UUID> getSelectingNpcs() {
|
||||
return selectingNpcs;
|
||||
}
|
||||
|
||||
public void setSelectingNpcs(HashSet<Player> selectingNpcs) {
|
||||
public void setSelectingNpcs(Set<UUID> selectingNpcs) {
|
||||
this.selectingNpcs = selectingNpcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link#getNamesOfQuestsBeingEdited}
|
||||
*/
|
||||
public List<String> getNames() {
|
||||
return names;
|
||||
return editingQuestNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link#setNamesOfQuestsBeingEdited}
|
||||
*/
|
||||
public void setNames(List<String> names) {
|
||||
this.names = names;
|
||||
this.editingQuestNames = names;
|
||||
}
|
||||
|
||||
public List<String> getNamesOfQuestsBeingEdited() {
|
||||
return editingQuestNames;
|
||||
}
|
||||
|
||||
public void setNamesOfQuestsBeingEdited(List<String> questNames) {
|
||||
this.editingQuestNames = questNames;
|
||||
}
|
||||
|
||||
public ConversationFactory getConversationFactory() {
|
||||
@ -130,7 +145,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
@Override
|
||||
public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) {
|
||||
if (abandonedEvent.getContext().getSessionData(CK.Q_NAME) != null) {
|
||||
names.remove((String) abandonedEvent.getContext().getSessionData(CK.Q_NAME));
|
||||
editingQuestNames.remove((String) abandonedEvent.getContext().getSessionData(CK.Q_NAME));
|
||||
}
|
||||
Player player = (Player) abandonedEvent.getContext().getForWhom();
|
||||
selectedBlockStarts.remove(player.getUniqueId());
|
||||
@ -536,7 +551,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
return new QuestSelectCreatePrompt(plugin, context);
|
||||
}
|
||||
}
|
||||
if (names.contains(input)) {
|
||||
if (editingQuestNames.contains(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
|
||||
return new QuestSelectCreatePrompt(plugin, context);
|
||||
}
|
||||
@ -549,7 +564,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
return new QuestSelectCreatePrompt(plugin, context);
|
||||
}
|
||||
context.setSessionData(CK.Q_NAME, input);
|
||||
names.add(input);
|
||||
editingQuestNames.add(input);
|
||||
return new QuestMainPrompt(context);
|
||||
} else {
|
||||
return new QuestMenuPrompt(context);
|
||||
@ -1097,7 +1112,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (names.contains(input)) {
|
||||
if (editingQuestNames.contains(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
|
||||
return new QuestSetNamePrompt();
|
||||
}
|
||||
@ -1105,9 +1120,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||
return new QuestSelectCreatePrompt(plugin, context);
|
||||
}
|
||||
names.remove((String) context.getSessionData(CK.Q_NAME));
|
||||
editingQuestNames.remove((String) context.getSessionData(CK.Q_NAME));
|
||||
context.setSessionData(CK.Q_NAME, input);
|
||||
names.add(input);
|
||||
editingQuestNames.add(input);
|
||||
}
|
||||
return new QuestMainPrompt(context);
|
||||
}
|
||||
@ -1163,7 +1178,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
selectingNpcs.add((Player) context.getForWhom());
|
||||
selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
|
||||
return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\n"
|
||||
+ ChatColor.GOLD + Lang.get("npcHint");
|
||||
}
|
||||
@ -1180,7 +1195,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
return new NPCStartPrompt();
|
||||
}
|
||||
context.setSessionData(CK.Q_START_NPC, i);
|
||||
selectingNpcs.remove((Player) context.getForWhom());
|
||||
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
return new QuestMainPrompt(context);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
@ -1191,7 +1206,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(CK.Q_START_NPC, null);
|
||||
}
|
||||
selectingNpcs.remove((Player) context.getForWhom());
|
||||
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
return new QuestMainPrompt(context);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
private Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
|
||||
private Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
|
||||
private Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
|
||||
private List<String> names = new LinkedList<String>();
|
||||
private List<String> editingActionNames = new LinkedList<String>();
|
||||
|
||||
public ActionFactory(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -130,6 +130,14 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
return convoCreator;
|
||||
}
|
||||
|
||||
public List<String> getNamesOfActionsBeingEdited() {
|
||||
return editingActionNames;
|
||||
}
|
||||
|
||||
public void setNamesOfActionsBeingEdited(List<String> actionNames) {
|
||||
this.editingActionNames = actionNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) {
|
||||
Player player = (Player) abandonedEvent.getContext().getForWhom();
|
||||
@ -469,7 +477,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
return new ActionSelectCreatePrompt(context);
|
||||
}
|
||||
}
|
||||
if (names.contains(input)) {
|
||||
if (editingActionNames.contains(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
|
||||
return new ActionSelectCreatePrompt(context);
|
||||
}
|
||||
@ -482,7 +490,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
return new ActionSelectCreatePrompt(context);
|
||||
}
|
||||
context.setSessionData(CK.E_NAME, input);
|
||||
names.add(input);
|
||||
editingActionNames.add(input);
|
||||
return new ActionMainPrompt(context);
|
||||
} else {
|
||||
return new ActionMenuPrompt(context);
|
||||
@ -1195,7 +1203,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
plugin.setActions(temp);
|
||||
}
|
||||
ConfigurationSection section = data.createSection(key + "." + (String) context.getSessionData(CK.E_NAME));
|
||||
names.remove((String) context.getSessionData(CK.E_NAME));
|
||||
editingActionNames.remove((String) context.getSessionData(CK.E_NAME));
|
||||
if (context.getSessionData(CK.E_MESSAGE) != null) {
|
||||
section.set("message", getCString(context, CK.E_MESSAGE));
|
||||
}
|
||||
@ -1389,7 +1397,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
return new ActionSetNamePrompt();
|
||||
}
|
||||
}
|
||||
if (names.contains(input)) {
|
||||
if (editingActionNames.contains(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
|
||||
return new ActionSetNamePrompt();
|
||||
}
|
||||
@ -1397,9 +1405,9 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha"));
|
||||
return new ActionSetNamePrompt();
|
||||
}
|
||||
names.remove((String) context.getSessionData(CK.E_NAME));
|
||||
editingActionNames.remove((String) context.getSessionData(CK.E_NAME));
|
||||
context.setSessionData(CK.E_NAME, input);
|
||||
names.add(input);
|
||||
editingActionNames.add(input);
|
||||
}
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
|
@ -13,9 +13,10 @@
|
||||
package me.blackvein.quests.convo.quests.prompts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
@ -291,8 +292,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
|
||||
}
|
||||
@ -320,8 +321,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
}
|
||||
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
|
||||
}
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
return new DeliveryListPrompt();
|
||||
}
|
||||
@ -351,8 +352,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorNPCToTalkToPrompt") + "\n" + ChatColor.GOLD
|
||||
+ Lang.get("npcHint");
|
||||
@ -380,8 +381,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
return new NPCIDsToTalkToPrompt();
|
||||
}
|
||||
}
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
@ -490,8 +491,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.add(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
|
||||
}
|
||||
@ -519,8 +520,8 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
}
|
||||
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
|
||||
}
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove((Player) context.getForWhom());
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
return new NPCKillListPrompt();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class NpcListener implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onNPCRightClick(NPCRightClickEvent evt) {
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker())) {
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID "
|
||||
+ evt.getNPC().getId());
|
||||
return;
|
||||
@ -300,7 +300,7 @@ public class NpcListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onNPCLeftClick(NPCLeftClickEvent evt) {
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker())) {
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN
|
||||
+ Lang.get("id") + " " + evt.getNPC().getId());
|
||||
}
|
||||
|
@ -14,10 +14,10 @@
|
||||
package me.blackvein.quests.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -1005,9 +1005,9 @@ public class PlayerListener implements Listener {
|
||||
if (quester.hasData()) {
|
||||
quester.saveData();
|
||||
}
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getPlayer())) {
|
||||
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove(evt.getPlayer());
|
||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getPlayer().getUniqueId())) {
|
||||
Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
|
||||
temp.remove(evt.getPlayer().getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
}
|
||||
LinkedList<Quester> temp = plugin.getQuesters();
|
||||
|
Loading…
Reference in New Issue
Block a user