mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-18 05:21:20 +01:00
Store quest NPCs by their ID
This commit is contained in:
parent
71511a4f8a
commit
2bd85cae9f
@ -128,7 +128,7 @@ public class Quests extends JavaPlugin {
|
|||||||
private final Collection<Quest> quests = new ConcurrentSkipListSet<>();
|
private final Collection<Quest> quests = new ConcurrentSkipListSet<>();
|
||||||
private Collection<Action> actions = new ConcurrentSkipListSet<>();
|
private Collection<Action> actions = new ConcurrentSkipListSet<>();
|
||||||
private Collection<Condition> conditions = new ConcurrentSkipListSet<>();
|
private Collection<Condition> conditions = new ConcurrentSkipListSet<>();
|
||||||
private LinkedList<NPC> questNpcs = new LinkedList<>();
|
private LinkedList<Integer> questNpcIds = new LinkedList<>();
|
||||||
private CommandExecutor cmdExecutor;
|
private CommandExecutor cmdExecutor;
|
||||||
private ConversationFactory conversationFactory;
|
private ConversationFactory conversationFactory;
|
||||||
private ConversationFactory npcConversationFactory;
|
private ConversationFactory npcConversationFactory;
|
||||||
@ -502,12 +502,12 @@ public class Quests extends JavaPlugin {
|
|||||||
this.questers = new ConcurrentSkipListSet<>(questers);
|
this.questers = new ConcurrentSkipListSet<>(questers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<NPC> getQuestNpcs() {
|
public LinkedList<Integer> getQuestNpcIds() {
|
||||||
return questNpcs;
|
return questNpcIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuestNpcs(final LinkedList<NPC> questNpcs) {
|
public void setQuestNpcIds(final LinkedList<Integer> questNpcIds) {
|
||||||
this.questNpcs = questNpcs;
|
this.questNpcIds = questNpcIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutor getCommandExecutor() {
|
public CommandExecutor getCommandExecutor() {
|
||||||
@ -1771,7 +1771,7 @@ public class Quests extends JavaPlugin {
|
|||||||
final int npcId = config.getInt("quests." + questKey + ".npc-giver-id");
|
final int npcId = config.getInt("quests." + questKey + ".npc-giver-id");
|
||||||
if (CitizensAPI.getNPCRegistry().getById(npcId) != null) {
|
if (CitizensAPI.getNPCRegistry().getById(npcId) != null) {
|
||||||
quest.npcStart = CitizensAPI.getNPCRegistry().getById(npcId);
|
quest.npcStart = CitizensAPI.getNPCRegistry().getById(npcId);
|
||||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(npcId));
|
questNpcIds.add(npcId);
|
||||||
} else {
|
} else {
|
||||||
throw new QuestFormatException("npc-giver-id has invalid NPC ID " + npcId, questKey);
|
throw new QuestFormatException("npc-giver-id has invalid NPC ID " + npcId, questKey);
|
||||||
}
|
}
|
||||||
@ -2834,7 +2834,7 @@ public class Quests extends JavaPlugin {
|
|||||||
for (final int i : npcIdsToTalkTo) {
|
for (final int i : npcIdsToTalkTo) {
|
||||||
if (getDependencies().getCitizens() != null) {
|
if (getDependencies().getCitizens() != null) {
|
||||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
questNpcIds.add(i);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest,
|
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest,
|
||||||
stageNum);
|
stageNum);
|
||||||
@ -2957,7 +2957,7 @@ public class Quests extends JavaPlugin {
|
|||||||
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
|
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
|
||||||
oStage.citizensToKill.add(i);
|
oStage.citizensToKill.add(i);
|
||||||
oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
||||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
questNpcIds.add(i);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-kill-amounts is not a positive number",
|
throw new StageFormatException("npc-kill-amounts is not a positive number",
|
||||||
quest, stageNum);
|
quest, stageNum);
|
||||||
|
@ -181,7 +181,7 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getQuestNpcs().contains(evt.getNPC())) {
|
if (plugin.getQuestNpcIds().contains(evt.getNPC().getId())) {
|
||||||
boolean hasObjective = false;
|
boolean hasObjective = false;
|
||||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
|
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user