From c593c210a37f0657640abade3ce3968822022d5d Mon Sep 17 00:00:00 2001
From: PikaMug <2267126+PikaMug@users.noreply.github.com>
Date: Sun, 17 Apr 2022 19:28:23 -0400
Subject: [PATCH] Track NPCs by UUID instead. Bump version
---
api/pom.xml | 2 +-
.../java/me/blackvein/quests/QuestData.java | 20 +-
.../quests/dependencies/IDependencies.java | 2 +
.../me/blackvein/quests/quests/IStage.java | 25 +-
core/pom.xml | 2 +-
.../me/blackvein/quests/Dependencies.java | 16 +-
.../main/java/me/blackvein/quests/Quest.java | 10 +-
.../java/me/blackvein/quests/Quester.java | 82 +-
.../main/java/me/blackvein/quests/Quests.java | 277 ++++---
.../main/java/me/blackvein/quests/Stage.java | 91 ++-
.../convo/conditions/tasks/EntityPrompt.java | 2 +-
.../convo/quests/main/QuestMainPrompt.java | 59 +-
.../convo/quests/objectives/BlocksPrompt.java | 48 +-
.../convo/quests/objectives/NpcsPrompt.java | 245 +++---
.../quests/listeners/NpcListener.java | 34 +-
.../quests/quests/BukkitQuestFactory.java | 725 +++++++++---------
.../file/SeparatedYamlStorage.java | 22 +-
.../implementation/sql/SqlStorage.java | 8 +-
core/src/main/resources/strings.yml | 18 +-
dist/pom.xml | 2 +-
pom.xml | 4 +-
v1_8_R1/pom.xml | 2 +-
v1_8_R2/pom.xml | 2 +-
v1_8_R3/pom.xml | 2 +-
24 files changed, 950 insertions(+), 750 deletions(-)
diff --git a/api/pom.xml b/api/pom.xml
index 83b56d1c3..daaa24f78 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -5,7 +5,7 @@
me.blackvein.quests
quests-parent
- 4.3.1
+ 4.4.0
quests-api
diff --git a/api/src/main/java/me/blackvein/quests/QuestData.java b/api/src/main/java/me/blackvein/quests/QuestData.java
index 5a4b5463f..2c0972158 100644
--- a/api/src/main/java/me/blackvein/quests/QuestData.java
+++ b/api/src/main/java/me/blackvein/quests/QuestData.java
@@ -513,7 +513,7 @@ public class QuestData {
}
};
- public LinkedList citizensInteracted = new LinkedList() {
+ public LinkedList npcsInteracted = new LinkedList() {
private static final long serialVersionUID = 2447610341508300847L;
@@ -580,7 +580,7 @@ public class QuestData {
}
};
- public LinkedList citizensNumKilled = new LinkedList() {
+ public LinkedList npcsNumKilled = new LinkedList() {
private static final long serialVersionUID = 1849192351499071688L;
@@ -1180,23 +1180,23 @@ public class QuestData {
}
}
- public LinkedList getCitizensInteracted() {
- return citizensInteracted;
+ public LinkedList getNpcsInteracted() {
+ return npcsInteracted;
}
- public void setCitizensInteracted(final LinkedList citizensInteracted) {
- this.citizensInteracted = citizensInteracted;
+ public void setNpcsInteracted(final LinkedList npcsInteracted) {
+ this.npcsInteracted = npcsInteracted;
if (doJournalUpdate) {
quester.updateJournal();
}
}
- public LinkedList getCitizensNumKilled() {
- return citizensNumKilled;
+ public LinkedList getNpcsNumKilled() {
+ return npcsNumKilled;
}
- public void setCitizensNumKilled(final LinkedList citizensNumKilled) {
- this.citizensNumKilled = citizensNumKilled;
+ public void setNpcsNumKilled(final LinkedList npcsNumKilled) {
+ this.npcsNumKilled = npcsNumKilled;
if (doJournalUpdate) {
quester.updateJournal();
}
diff --git a/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java b/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java
index 61f2d7794..387aa6686 100644
--- a/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java
+++ b/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java
@@ -71,6 +71,8 @@ public interface IDependencies {
String getNPCName(final int id);
+ String getNPCName(final UUID uuid);
+
int getMcmmoSkillLevel(final SkillType st, final String player);
Hero getHero(final UUID uuid);
diff --git a/api/src/main/java/me/blackvein/quests/quests/IStage.java b/api/src/main/java/me/blackvein/quests/quests/IStage.java
index 6718665f1..f17e858a9 100644
--- a/api/src/main/java/me/blackvein/quests/quests/IStage.java
+++ b/api/src/main/java/me/blackvein/quests/quests/IStage.java
@@ -24,6 +24,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.Map;
+import java.util.UUID;
public interface IStage {
LinkedList getBlocksToBreak();
@@ -92,11 +93,11 @@ public interface IStage {
void setItemsToDeliver(final LinkedList itemsToDeliver);
- LinkedList getItemDeliveryTargets();
+ LinkedList getItemDeliveryTargets();
- boolean addItemDeliveryTarget(Integer itemDeliveryTarget);
+ boolean addItemDeliveryTarget(UUID itemDeliveryTarget);
- void setItemDeliveryTargets(final LinkedList itemDeliveryTargets);
+ void setItemDeliveryTargets(final LinkedList itemDeliveryTargets);
LinkedList getDeliverMessages();
@@ -104,23 +105,23 @@ public interface IStage {
void setDeliverMessages(final LinkedList deliverMessages);
- LinkedList getCitizensToInteract();
+ LinkedList getNpcsToInteract();
- boolean addCitizenToInteract(Integer citizenToInteract);
+ boolean addNpcToInteract(UUID npcToInteract);
- void setCitizensToInteract(final LinkedList citizensToInteract);
+ void setNpcsToInteract(final LinkedList npcsToInteract);
- LinkedList getCitizensToKill();
+ LinkedList getNpcsToKill();
- boolean addCitizenToKill(Integer citizenToKill);
+ boolean addNpcToKill(UUID citizenToKill);
- void setCitizensToKill(final LinkedList citizensToKill);
+ void setNpcsToKill(final LinkedList npcsToKill);
- LinkedList getCitizenNumToKill();
+ LinkedList getNpcNumToKill();
- boolean addCitizenNumToKill(Integer citizenNumToKill);
+ boolean addNpcNumToKill(Integer npcNumToKill);
- void setCitizenNumToKill(final LinkedList citizenNumToKill);
+ void setNpcNumToKill(final LinkedList npcNumToKill);
LinkedList getMobsToKill();
diff --git a/core/pom.xml b/core/pom.xml
index f0ef32937..768c6c3e3 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -5,7 +5,7 @@
me.blackvein.quests
quests-parent
- 4.3.1
+ 4.4.0
quests-core
diff --git a/core/src/main/java/me/blackvein/quests/Dependencies.java b/core/src/main/java/me/blackvein/quests/Dependencies.java
index 912b437a9..be08062f9 100644
--- a/core/src/main/java/me/blackvein/quests/Dependencies.java
+++ b/core/src/main/java/me/blackvein/quests/Dependencies.java
@@ -271,14 +271,28 @@ public class Dependencies implements IDependencies {
public boolean runDenizenScript(final String scriptName, final IQuester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
}
-
+
+ /**
+ * @deprecated Use {@link #getNPCLocation(UUID)}
+ */
public Location getNPCLocation(final int id) {
return citizens.getNPCRegistry().getById(id).getStoredLocation();
}
+ public Location getNPCLocation(final UUID uuid) {
+ return citizens.getNPCRegistry().getByUniqueId(uuid).getStoredLocation();
+ }
+
+ /**
+ * @deprecated Use {@link #getNPCName(UUID)}
+ */
public String getNPCName(final int id) {
return citizens.getNPCRegistry().getById(id).getName();
}
+
+ public String getNPCName(final UUID uuid) {
+ return citizens.getNPCRegistry().getByUniqueId(uuid).getName();
+ }
public int getMcmmoSkillLevel(final SkillType st, final String player) {
final McMMOPlayer mPlayer = UserManager.getPlayer(player);
diff --git a/core/src/main/java/me/blackvein/quests/Quest.java b/core/src/main/java/me/blackvein/quests/Quest.java
index 692771188..8c4a96405 100644
--- a/core/src/main/java/me/blackvein/quests/Quest.java
+++ b/core/src/main/java/me/blackvein/quests/Quest.java
@@ -449,14 +449,14 @@ public class Quest implements IQuest {
final IQuest quest = this;
Bukkit.getScheduler().runTask(plugin, () -> {
Location targetLocation = null;
- if (stage.getCitizensToInteract() != null && stage.getCitizensToInteract().size() > 0) {
- targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToInteract().getFirst());
- } else if (stage.getCitizensToKill() != null && stage.getCitizensToKill().size() > 0) {
- targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToKill().getFirst());
+ if (stage.getNpcsToInteract() != null && stage.getNpcsToInteract().size() > 0) {
+ targetLocation = plugin.getDependencies().getNPCLocation(stage.getNpcsToInteract().getFirst());
+ } else if (stage.getNpcsToKill() != null && stage.getNpcsToKill().size() > 0) {
+ targetLocation = plugin.getDependencies().getNPCLocation(stage.getNpcsToKill().getFirst());
} else if (stage.getLocationsToReach() != null && stage.getLocationsToReach().size() > 0) {
targetLocation = stage.getLocationsToReach().getFirst();
} else if (stage.getItemDeliveryTargets() != null && stage.getItemDeliveryTargets().size() > 0) {
- final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(stage
+ final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(stage
.getItemDeliveryTargets().getFirst());
targetLocation = npc.getStoredLocation();
} else if (stage.getPlayersToKill() != null && stage.getPlayersToKill() > 0) {
diff --git a/core/src/main/java/me/blackvein/quests/Quester.java b/core/src/main/java/me/blackvein/quests/Quester.java
index 8696b0303..e6ae22c5d 100644
--- a/core/src/main/java/me/blackvein/quests/Quester.java
+++ b/core/src/main/java/me/blackvein/quests/Quester.java
@@ -1341,7 +1341,7 @@ public class Quester implements IQuester {
delivered = data.itemsDelivered.get(deliverIndex).getAmount();
}
final int toDeliver = is.getAmount();
- final Integer npc = stage.getItemDeliveryTargets().get(deliverIndex);
+ final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex);
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "deliver").replace("", depends.getNPCName(npc));
if (message.contains("")) {
@@ -1357,10 +1357,10 @@ public class Quester implements IQuester {
deliverIndex++;
}
int interactIndex = 0;
- for (final Integer n : stage.getCitizensToInteract()) {
+ for (final UUID n : stage.getNpcsToInteract()) {
boolean interacted = false;
- if (data.citizensInteracted.size() > interactIndex) {
- interacted = data.citizensInteracted.get(interactIndex);
+ if (data.npcsInteracted.size() > interactIndex) {
+ interacted = data.npcsInteracted.get(interactIndex);
}
final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "talkTo")
@@ -1372,12 +1372,12 @@ public class Quester implements IQuester {
interactIndex++;
}
int npcKillIndex = 0;
- for (final Integer n : stage.getCitizensToKill()) {
+ for (final UUID n : stage.getNpcsToKill()) {
int npcKilled = 0;
- if (data.citizensNumKilled.size() > npcKillIndex) {
- npcKilled = data.citizensNumKilled.get(npcKillIndex);
+ if (data.npcsNumKilled.size() > npcKillIndex) {
+ npcKilled = data.npcsNumKilled.get(npcKillIndex);
}
- final int toNpcKill = stage.getCitizenNumToKill().get(npcKillIndex);
+ final int toNpcKill = stage.getNpcNumToKill().get(npcKillIndex);
final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "kill");
if (message.contains("")) {
@@ -1850,7 +1850,7 @@ public class Quester implements IQuester {
final ItemStack progress = data.itemsDelivered.get(deliverIndex);
final int delivered = progress.getAmount();
final int toDeliver = goal.getAmount();
- final Integer npc = stage.getItemDeliveryTargets().get(deliverIndex);
+ final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex);
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "deliver").replace("", depends.getNPCName(npc));
if (message.contains("")) {
@@ -1870,10 +1870,10 @@ public class Quester implements IQuester {
deliverIndex++;
}
int interactIndex = 0;
- for (final Integer n : stage.getCitizensToInteract()) {
+ for (final UUID n : stage.getNpcsToInteract()) {
boolean interacted = false;
- if (data.citizensInteracted.size() > interactIndex) {
- interacted = data.citizensInteracted.get(interactIndex);
+ if (data.npcsInteracted.size() > interactIndex) {
+ interacted = data.npcsInteracted.get(interactIndex);
final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "talkTo")
.replace("", depends.getNPCName(n));
@@ -1885,12 +1885,12 @@ public class Quester implements IQuester {
interactIndex++;
}
int npcKillIndex = 0;
- for (final Integer n : stage.getCitizensToKill()) {
+ for (final UUID n : stage.getNpcsToKill()) {
int npcKilled = 0;
- if (data.citizensNumKilled.size() > npcKillIndex) {
- npcKilled = data.citizensNumKilled.get(npcKillIndex);
+ if (data.npcsNumKilled.size() > npcKillIndex) {
+ npcKilled = data.npcsNumKilled.get(npcKillIndex);
}
- final int toNpcKill = stage.getCitizenNumToKill().get(npcKillIndex);
+ final int toNpcKill = stage.getNpcNumToKill().get(npcKillIndex);
final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "kill");
if (message.contains("")) {
@@ -2967,7 +2967,7 @@ public class Quester implements IQuester {
if (npc == null) {
return;
}
-
+
int currentIndex = -1;
final LinkedList matches = new LinkedList<>();
for (final ItemStack is : getQuestData(quest).itemsDelivered) {
@@ -2982,7 +2982,7 @@ public class Quester implements IQuester {
final Player player = getPlayer();
for (final Integer match : matches) {
final LinkedList items = new LinkedList<>(getQuestData(quest).itemsDelivered);
- if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc.getId())) {
+ if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc.getUniqueId())) {
continue;
}
final ItemStack found = items.get(match);
@@ -3025,7 +3025,7 @@ public class Quester implements IQuester {
final String[] message = ConfigUtil.parseStringWithPossibleLineBreaks(getCurrentStage(quest)
.getDeliverMessages().get(new Random().nextInt(getCurrentStage(quest).getDeliverMessages()
.size())), plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(getCurrentStage(quest).getItemDeliveryTargets().get(items.indexOf(found))));
+ .getByUniqueId(getCurrentStage(quest).getItemDeliveryTargets().get(items.indexOf(found))));
player.sendMessage(message);
}
@@ -3054,12 +3054,12 @@ public class Quester implements IQuester {
* @param npc The NPC being interacted with
*/
public void interactWithNPC(final IQuest quest, final NPC npc) {
- if (!getCurrentStage(quest).getCitizensToInteract().contains(npc.getId())) {
+ if (!getCurrentStage(quest).getNpcsToInteract().contains(npc.getUniqueId())) {
return;
}
- final int index = getCurrentStage(quest).getCitizensToInteract().indexOf(npc.getId());
- final boolean npcsInteracted = getQuestData(quest).citizensInteracted.get(index);
+ final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc.getUniqueId());
+ final boolean npcsInteracted = getQuestData(quest).npcsInteracted.get(index);
final ObjectiveType type = ObjectiveType.TALK_TO_NPC;
final Set dispatchedQuestIDs = new HashSet<>();
@@ -3068,14 +3068,14 @@ public class Quester implements IQuester {
plugin.getServer().getPluginManager().callEvent(preEvent);
if (!npcsInteracted) {
- getQuestData(quest).citizensInteracted.set(index, true);
+ getQuestData(quest).npcsInteracted.set(index, true);
finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null);
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
- q.getQuestData(quest).citizensInteracted.set(index, true);
+ q.getQuestData(quest).npcsInteracted.set(index, true);
if (q.testComplete(quest)) {
quest.nextStage(q, false);
}
@@ -3096,13 +3096,13 @@ public class Quester implements IQuester {
* @param npc The NPC being killed
*/
public void killNPC(final IQuest quest, final NPC npc) {
- if (!getCurrentStage(quest).getCitizensToKill().contains(npc.getId())) {
+ if (!getCurrentStage(quest).getNpcsToKill().contains(npc.getUniqueId())) {
return;
}
- final int index = getCurrentStage(quest).getCitizensToKill().indexOf(npc.getId());
- final int npcsKilled = getQuestData(quest).citizensNumKilled.get(index);
- final int npcsToKill = getCurrentStage(quest).getCitizenNumToKill().get(index);
+ final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc.getUniqueId());
+ final int npcsKilled = getQuestData(quest).npcsNumKilled.get(index);
+ final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index);
final ObjectiveType type = ObjectiveType.KILL_NPC;
final Set dispatchedQuestIDs = new HashSet<>();
@@ -3110,9 +3110,9 @@ public class Quester implements IQuester {
new BukkitObjective(type, npcsKilled, npcsToKill));
plugin.getServer().getPluginManager().callEvent(preEvent);
- final int newNpcsKilled = getQuestData(quest).citizensNumKilled.get(index) + 1;
+ final int newNpcsKilled = getQuestData(quest).npcsNumKilled.get(index) + 1;
if (npcsKilled < npcsToKill) {
- getQuestData(quest).citizensNumKilled.set(index, newNpcsKilled);
+ getQuestData(quest).npcsNumKilled.set(index, newNpcsKilled);
if (newNpcsKilled >= npcsToKill) {
finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, npcsToKill)), null, null, npc, null, null, null, null);
@@ -3121,7 +3121,7 @@ public class Quester implements IQuester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
- q.getQuestData(quest).citizensNumKilled.set(index, newNpcsKilled);
+ q.getQuestData(quest).npcsNumKilled.set(index, newNpcsKilled);
if (q.testComplete(quest)) {
quest.nextStage(q, false);
}
@@ -4183,14 +4183,14 @@ public class Quester implements IQuester {
data.itemsDelivered.add(temp);
}
}
- if (!quest.getStage(stage).getCitizensToInteract().isEmpty()) {
- for (final Integer ignored : quest.getStage(stage).getCitizensToInteract()) {
- data.citizensInteracted.add(false);
+ if (!quest.getStage(stage).getNpcsToInteract().isEmpty()) {
+ for (final UUID ignored : quest.getStage(stage).getNpcsToInteract()) {
+ data.npcsInteracted.add(false);
}
}
- if (!quest.getStage(stage).getCitizensToKill().isEmpty()) {
- for (final Integer ignored : quest.getStage(stage).getCitizensToKill()) {
- data.citizensNumKilled.add(0);
+ if (!quest.getStage(stage).getNpcsToKill().isEmpty()) {
+ for (final UUID ignored : quest.getStage(stage).getNpcsToKill()) {
+ data.npcsNumKilled.add(0);
}
}
if (!quest.getStage(stage).getMobsToKill().isEmpty()) {
@@ -4374,11 +4374,11 @@ public class Quester implements IQuester {
}
questSec.set("item-delivery-amounts", deliveryAmounts);
}
- if (!questData.citizensInteracted.isEmpty()) {
- questSec.set("has-talked-to", questData.citizensInteracted);
+ if (!questData.npcsInteracted.isEmpty()) {
+ questSec.set("has-talked-to", questData.npcsInteracted);
}
- if (!questData.citizensNumKilled.isEmpty()) {
- questSec.set("citizen-amounts-killed", questData.citizensNumKilled);
+ if (!questData.npcsNumKilled.isEmpty()) {
+ questSec.set("npc-killed-amounts", questData.npcsNumKilled);
}
if (!questData.mobNumKilled.isEmpty()) {
questSec.set("mobs-killed-amounts", questData.mobNumKilled);
diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java
index c8420a6c2..266f1166d 100644
--- a/core/src/main/java/me/blackvein/quests/Quests.java
+++ b/core/src/main/java/me/blackvein/quests/Quests.java
@@ -151,6 +151,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
private final Collection quests = new ConcurrentSkipListSet<>();
private Collection actions = new ConcurrentSkipListSet<>();
private Collection conditions = new ConcurrentSkipListSet<>();
+ private LinkedList questNpcUuids = new LinkedList<>();
private LinkedList questNpcIds = new LinkedList<>();
private TabExecutor cmdExecutor;
private ConversationFactory conversationFactory;
@@ -535,10 +536,24 @@ public class Quests extends JavaPlugin implements QuestsAPI {
this.questers = new ConcurrentSkipListSet<>(questers);
}
+ public LinkedList getQuestNpcUuids() {
+ return questNpcUuids;
+ }
+
+ public void setQuestNpcUuids(final LinkedList questNpcUuids) {
+ this.questNpcUuids = questNpcUuids;
+ }
+
+ /**
+ * @deprecated Use {@link #getQuestNpcUuids()}
+ */
public LinkedList getQuestNpcIds() {
return questNpcIds;
}
+ /**
+ * @deprecated Use {@link #setQuestNpcUuids(LinkedList)}
+ */
public void setQuestNpcIds(final LinkedList questNpcIds) {
this.questNpcIds = questNpcIds;
}
@@ -1366,7 +1381,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
delivered = data.itemsDelivered.get(deliverIndex).getAmount();
}
final int toDeliver = is.getAmount();
- final Integer npc = stage.getItemDeliveryTargets().get(deliverIndex);
+ final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex);
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + "- " + Lang.get(quester.getPlayer(), "deliver").replace("", depends.getNPCName(npc));
if (message.contains("")) {
@@ -1387,14 +1402,14 @@ public class Quests extends JavaPlugin implements QuestsAPI {
deliverIndex++;
}
int interactIndex = 0;
- for (final Integer n : stage.getCitizensToInteract()) {
+ for (final UUID uuid : stage.getNpcsToInteract()) {
boolean interacted = false;
- if (data.citizensInteracted.size() > interactIndex) {
- interacted = data.citizensInteracted.get(interactIndex);
+ if (data.npcsInteracted.size() > interactIndex) {
+ interacted = data.npcsInteracted.get(interactIndex);
}
final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + "- " + Lang.get(quester.getPlayer(), "talkTo")
- .replace("", depends.getNPCName(n));
+ .replace("", depends.getNPCName(uuid));
if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
}
@@ -1402,18 +1417,18 @@ public class Quests extends JavaPlugin implements QuestsAPI {
interactIndex++;
}
int npcKillIndex = 0;
- for (final Integer n : stage.getCitizensToKill()) {
+ for (final UUID uuid : stage.getNpcsToKill()) {
int npcKilled = 0;
- if (data.citizensNumKilled.size() > npcKillIndex) {
- npcKilled = data.citizensNumKilled.get(npcKillIndex);
+ if (data.npcsNumKilled.size() > npcKillIndex) {
+ npcKilled = data.npcsNumKilled.get(npcKillIndex);
}
- final int toNpcKill = stage.getCitizenNumToKill().get(npcKillIndex);
+ final int toNpcKill = stage.getNpcNumToKill().get(npcKillIndex);
final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + "- " + Lang.get(quester.getPlayer(), "kill");
if (message.contains("")) {
- message = message.replace("", depends.getNPCName(n));
+ message = message.replace("", depends.getNPCName(uuid));
} else {
- message += " " + depends.getNPCName(n);
+ message += " " + depends.getNPCName(uuid);
}
if (message.contains("")) {
message = message.replace("", "" + color + npcKilled + "/" + toNpcKill);
@@ -1830,11 +1845,23 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} else {
throw new QuestFormatException("finish-message is missing", questKey);
}
- if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) {
+ if (config.contains("quests." + questKey + ".npc-giver-uuid")) {
+ final UUID uuid = UUID.fromString(Objects.requireNonNull(config.getString("quests." + questKey
+ + ".npc-giver-uuid")));
+ if (CitizensAPI.getNPCRegistry().getByUniqueId(uuid) != null) {
+ quest.setNpcStart(CitizensAPI.getNPCRegistry().getByUniqueId(uuid));
+ questNpcUuids.add(uuid);
+ } else {
+ throw new QuestFormatException("npc-giver-uuid has invalid NPC UUID " + uuid, questKey);
+ }
+ } else if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) {
+ // Legacy
final int npcId = config.getInt("quests." + questKey + ".npc-giver-id");
if (CitizensAPI.getNPCRegistry().getById(npcId) != null) {
- quest.setNpcStart(CitizensAPI.getNPCRegistry().getById(npcId));
+ final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
+ quest.setNpcStart(npc);
questNpcIds.add(npcId);
+ questNpcUuids.add(npc.getUniqueId());
} else {
throw new QuestFormatException("npc-giver-id has invalid NPC ID " + npcId, questKey);
}
@@ -2435,10 +2462,13 @@ public class Quests extends JavaPlugin implements QuestsAPI {
final List itemsToEnchant;
final List itemsToBrew;
final List itemsToConsume;
+ final List npcUuidsToTalkTo;
final List npcIdsToTalkTo;
final List itemsToDeliver;
+ final List itemDeliveryTargetUuids;
final List itemDeliveryTargetIds;
final List deliveryMessages;
+ final List npcUuidsToKill;
final List npcIdsToKill;
final List npcAmountsToKill;
// Legacy Denizen script load
@@ -2896,15 +2926,45 @@ public class Quests extends JavaPlugin implements QuestsAPI {
throw new StageFormatException("players-to-kill is not a number", quest, stageNum);
}
}
- if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-talk-to")) {
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-talk-to")) {
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-uuids-to-talk-to"), String.class)) {
+ npcUuidsToTalkTo = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-uuids-to-talk-to");
+ for (final String s : npcUuidsToTalkTo) {
+ final UUID uuid = UUID.fromString(s);
+ if (getDependencies().getCitizens() != null) {
+ NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(uuid);
+ if (npc != null) {
+ oStage.addNpcToInteract(uuid);
+ questNpcIds.add(npc.getId());
+ questNpcUuids.add(uuid);
+ } else {
+ throw new StageFormatException("npc-uuids-to-talk-to has invalid NPC UUID of "
+ + s, quest, stageNum);
+ }
+ } else {
+ throw new StageFormatException("Citizens not found for npc-uuids-to-talk-to", quest,
+ stageNum);
+ }
+ }
+ } else {
+ throw new StageFormatException("npc-ids-to-talk-to is not a list of numbers", quest, stageNum);
+ }
+ } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-talk-to")) {
+ // Legacy
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-ids-to-talk-to"), Integer.class)) {
npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-ids-to-talk-to");
for (final int i : npcIdsToTalkTo) {
if (getDependencies().getCitizens() != null) {
- if (CitizensAPI.getNPCRegistry().getById(i) != null) {
- questNpcIds.add(i);
+ final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
+ if (npc != null) {
+ final UUID npcUuid = npc.getUniqueId();
+ oStage.addNpcToInteract(npcUuid);
+ questNpcIds.add(npc.getId());
+ questNpcUuids.add(npcUuid);
} else {
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest,
stageNum);
@@ -2914,37 +2974,82 @@ public class Quests extends JavaPlugin implements QuestsAPI {
stageNum);
}
}
- oStage.setCitizensToInteract(new LinkedList<>(npcIdsToTalkTo));
} else {
throw new StageFormatException("npc-ids-to-talk-to is not a list of numbers", quest, stageNum);
}
}
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-deliver")) {
- if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-ids")) {
- if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
- + ".npc-delivery-ids"), Integer.class)) {
- if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-uuids")) {
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-delivery-uuids"), String.class)) {
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
+ ".delivery-messages")) {
- itemsToDeliver = (List) config.get("quests." + questKey + ".stages.ordered."
+ itemsToDeliver = (List) config.get("quests." + questKey + ".stages.ordered."
+ stageNum + ".items-to-deliver");
- itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ itemDeliveryTargetUuids = config.getStringList("quests." + questKey + ".stages.ordered."
+ + stageNum + ".npc-delivery-uuids");
+ deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
+ + stageNum + ".delivery-messages");
+ int index = 0;
+ if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
+ for (final ItemStack stack : itemsToDeliver) {
+ if (stack != null) {
+ final UUID npcUuid = UUID.fromString(itemDeliveryTargetUuids.get(index));
+ final String msg = deliveryMessages.size() > index
+ ? deliveryMessages.get(index)
+ : deliveryMessages.get(deliveryMessages.size() - 1);
+ index++;
+ if (getDependencies().getCitizens() != null) {
+ final NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(npcUuid);
+ if (npc != null) {
+ oStage.addItemToDeliver(stack);
+ oStage.addItemDeliveryTarget(npcUuid);
+ oStage.addDeliverMessage(msg);
+ } else {
+ throw new StageFormatException("npc-delivery-ids has invalid NPC " +
+ "UUID of " + npcUuid, quest, stageNum);
+ }
+ } else {
+ throw new StageFormatException(
+ "Citizens not found for npc-delivery-uuids", quest, stageNum);
+ }
+ }
+ }
+ } else {
+ throw new StageFormatException("items-to-deliver has invalid formatting", quest,
+ stageNum);
+ }
+ }
+ } else {
+ throw new StageFormatException("npc-delivery-ids is not a list of numbers", quest, stageNum);
+ }
+ } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-delivery-ids")) {
+ // Legacy
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-delivery-ids"), Integer.class)) {
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
+ + ".delivery-messages")) {
+ itemsToDeliver = (List) config.get("quests." + questKey + ".stages.ordered."
+ + stageNum + ".items-to-deliver");
+ itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-delivery-ids");
- deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
+ deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".delivery-messages");
int index = 0;
if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
for (final ItemStack stack : itemsToDeliver) {
if (stack != null) {
final int npcId = itemDeliveryTargetIds.get(index);
- final String msg = deliveryMessages.size() > index
- ? deliveryMessages.get(index)
+ final String msg = deliveryMessages.size() > index
+ ? deliveryMessages.get(index)
: deliveryMessages.get(deliveryMessages.size() - 1);
index++;
if (getDependencies().getCitizens() != null) {
final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
if (npc != null) {
oStage.addItemToDeliver(stack);
- oStage.addItemDeliveryTarget(npcId);
+ oStage.addItemDeliveryTarget(npc.getUniqueId());
oStage.addDeliverMessage(msg);
} else {
throw new StageFormatException("npc-delivery-ids has invalid NPC " +
@@ -2957,52 +3062,8 @@ public class Quests extends JavaPlugin implements QuestsAPI {
}
}
} else {
- final List items = config.getStringList("quests." + questKey
- + ".stages.ordered." + stageNum + ".items-to-deliver");
- if (ConfigUtil.checkList(items, String.class)) {
- // Legacy
- for (final String item : items) {
- final ItemStack is = ItemUtil.readItemStack("" + item);
- if (index <= itemDeliveryTargetIds.size()) {
- if (itemDeliveryTargetIds.size() != deliveryMessages.size()) {
- throw new StageFormatException(
- "delivery-messages must be same size as items-to-deliver",
- quest, stageNum);
- }
- final int npcId = itemDeliveryTargetIds.get(index);
- final String msg = deliveryMessages.get(index);
- index++;
- if (is != null) {
- if (getDependencies().getCitizens() != null) {
- final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
- if (npc != null) {
- oStage.addItemToDeliver(is);
- oStage.addItemDeliveryTarget(npcId);
- oStage.addDeliverMessage(msg);
- } else {
- throw new StageFormatException(
- "npc-delivery-ids has invalid NPC ID of " + npcId,
- quest, stageNum);
- }
- } else {
- throw new StageFormatException(
- "Citizens was not found installed for npc-delivery-ids",
- quest, stageNum);
- }
- } else {
- throw new StageFormatException(
- "items-to-deliver has invalid formatting " + item, quest,
- stageNum);
- }
- } else {
- throw new StageFormatException("items-to-deliver is missing target IDs"
- , quest, stageNum);
- }
- }
- } else {
- throw new StageFormatException("items-to-deliver has invalid formatting", quest,
- stageNum);
- }
+ throw new StageFormatException("items-to-deliver has invalid formatting", quest,
+ stageNum);
}
}
} else {
@@ -3012,29 +3073,32 @@ public class Quests extends JavaPlugin implements QuestsAPI {
throw new StageFormatException("npc-delivery-id is missing", quest, stageNum);
}
}
- if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) {
- if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
- + ".npc-ids-to-kill"), Integer.class)) {
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-kill")) {
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-uuids-to-kill"), String.class)) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) {
- if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-kill-amounts"), Integer.class)) {
- npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
- + ".npc-ids-to-kill");
+ npcUuidsToKill = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-uuids-to-kill");
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-kill-amounts");
- for (final int i : npcIdsToKill) {
- if (CitizensAPI.getNPCRegistry().getById(i) != null) {
- if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
- oStage.addCitizenToKill(i);
- oStage.addCitizenNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
- questNpcIds.add(i);
+ for (final String s : npcUuidsToKill) {
+ final UUID npcUuid = UUID.fromString(s);
+ final NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(npcUuid);
+ if (npc != null) {
+ if (npcAmountsToKill.get(npcUuidsToKill.indexOf(s)) > 0) {
+ oStage.addNpcToKill(npcUuid);
+ oStage.addNpcNumToKill(npcAmountsToKill.get(npcUuidsToKill.indexOf(s)));
+ questNpcIds.add(npc.getId());
+ questNpcUuids.add(npcUuid);
} else {
throw new StageFormatException("npc-kill-amounts is not a positive number",
quest, stageNum);
}
} else {
- throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest,
- stageNum);
+ throw new StageFormatException("npc-uuids-to-kill has invalid NPC UUID of " + s,
+ quest, stageNum);
}
}
} else {
@@ -3044,8 +3108,43 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} else {
throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum);
}
- } else {
- throw new StageFormatException("npc-ids-to-kill is not a list of numbers", quest, stageNum);
+ }
+ } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) {
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-ids-to-kill"), Integer.class)) {
+ // Legacy
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) {
+ if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-kill-amounts"), Integer.class)) {
+ npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ + ".npc-ids-to-kill");
+ npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ + stageNum + ".npc-kill-amounts");
+ for (final int i : npcIdsToKill) {
+ final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
+ if (npc != null) {
+ if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
+ final UUID npcUuid = npc.getUniqueId();
+ oStage.addNpcToKill(npcUuid);
+ oStage.addNpcNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
+ questNpcIds.add(npc.getId());
+ questNpcUuids.add(npcUuid);
+ } else {
+ throw new StageFormatException("npc-kill-amounts is not a positive number",
+ quest, stageNum);
+ }
+ } else {
+ throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest,
+ stageNum);
+ }
+ }
+ } else {
+ throw new StageFormatException("npc-kill-amounts is not a list of numbers", quest,
+ stageNum);
+ }
+ } else {
+ throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum);
+ }
}
}
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) {
diff --git a/core/src/main/java/me/blackvein/quests/Stage.java b/core/src/main/java/me/blackvein/quests/Stage.java
index e4009db46..53ab8910d 100644
--- a/core/src/main/java/me/blackvein/quests/Stage.java
+++ b/core/src/main/java/me/blackvein/quests/Stage.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.UUID;
public class Stage implements IStage {
@@ -42,7 +43,7 @@ public class Stage implements IStage {
private LinkedList itemsToBrew = new LinkedList<>();
private LinkedList itemsToConsume = new LinkedList<>();
private LinkedList itemsToDeliver = new LinkedList<>();
- private LinkedList itemDeliveryTargets = new LinkedList() {
+ private LinkedList itemDeliveryTargets = new LinkedList() {
private static final long serialVersionUID = -2774443496142382127L;
@@ -50,11 +51,10 @@ public class Stage implements IStage {
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
- final
- LinkedList otherList = (LinkedList) o;
- for (final Integer i : this) {
- final Integer other = otherList.get(this.indexOf(i));
- if (!other.equals(i)) {
+ final LinkedList otherList = (LinkedList) o;
+ for (final UUID uuid : this) {
+ final UUID other = otherList.get(this.indexOf(uuid));
+ if (!other.equals(uuid)) {
return false;
}
}
@@ -63,7 +63,7 @@ public class Stage implements IStage {
}
};
private LinkedList deliverMessages = new LinkedList<>();
- private LinkedList citizensToInteract = new LinkedList() {
+ private LinkedList npcsToInteract = new LinkedList() {
private static final long serialVersionUID = -4086855121042524435L;
@@ -71,11 +71,10 @@ public class Stage implements IStage {
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
- final
- LinkedList otherList = (LinkedList) o;
- for (final Integer i : this) {
- final Integer other = otherList.get(this.indexOf(i));
- if (!other.equals(i)) {
+ final LinkedList otherList = (LinkedList) o;
+ for (final UUID uuid : this) {
+ final UUID other = otherList.get(this.indexOf(uuid));
+ if (!other.equals(uuid)) {
return false;
}
}
@@ -83,7 +82,7 @@ public class Stage implements IStage {
return true;
}
};
- private LinkedList citizensToKill = new LinkedList() {
+ private LinkedList npcsToKill = new LinkedList() {
private static final long serialVersionUID = 7705964814014176415L;
@@ -91,11 +90,10 @@ public class Stage implements IStage {
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
- final
- LinkedList otherList = (LinkedList) o;
- for (final Integer i : this) {
- final Integer other = otherList.get(this.indexOf(i));
- if (!other.equals(i)) {
+ final LinkedList otherList = (LinkedList) o;
+ for (final UUID uuid : this) {
+ final UUID other = otherList.get(this.indexOf(uuid));
+ if (!other.equals(uuid)) {
return false;
}
}
@@ -103,7 +101,7 @@ public class Stage implements IStage {
return true;
}
};
- private LinkedList citizenNumToKill = new LinkedList<>();
+ private LinkedList npcNumToKill = new LinkedList<>();
private LinkedList mobsToKill = new LinkedList<>();
private LinkedList mobNumToKill = new LinkedList<>();
private LinkedList locationsToKillWithin = new LinkedList<>();
@@ -284,16 +282,16 @@ public class Stage implements IStage {
this.itemsToDeliver = itemsToDeliver;
}
- public LinkedList getItemDeliveryTargets() {
+ public LinkedList getItemDeliveryTargets() {
return itemDeliveryTargets;
}
@Override
- public boolean addItemDeliveryTarget(Integer itemDeliveryTarget) {
+ public boolean addItemDeliveryTarget(UUID itemDeliveryTarget) {
return itemDeliveryTargets.add(itemDeliveryTarget);
}
- public void setItemDeliveryTargets(final LinkedList itemDeliveryTargets) {
+ public void setItemDeliveryTargets(final LinkedList itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets;
}
@@ -310,43 +308,42 @@ public class Stage implements IStage {
this.deliverMessages = deliverMessages;
}
- public LinkedList getCitizensToInteract() {
- return citizensToInteract;
+ public LinkedList getNpcsToInteract() {
+ return npcsToInteract;
}
@Override
- public boolean addCitizenToInteract(Integer citizenToInteract) {
- return citizensToInteract.add(citizenToInteract);
+ public boolean addNpcToInteract(UUID npcToInteract) {
+ return npcsToInteract.add(npcToInteract);
}
- public void setCitizensToInteract(final LinkedList citizensToInteract) {
- this.citizensToInteract = citizensToInteract;
+ public void setNpcsToInteract(final LinkedList npcsToInteract) {
+ this.npcsToInteract = npcsToInteract;
}
- public LinkedList getCitizensToKill() {
- return citizensToKill;
+ public LinkedList getNpcsToKill() {
+ return npcsToKill;
}
@Override
- public boolean addCitizenToKill(Integer citizenToKill) {
- return citizensToKill.add(citizenToKill);
+ public boolean addNpcToKill(UUID npcToKill) {
+ return npcsToKill.add(npcToKill);
}
- public void setCitizensToKill(final LinkedList citizensToKill) {
- this.citizensToKill = citizensToKill;
+ public void setNpcsToKill(final LinkedList npcsToKill) {
+ this.npcsToKill = npcsToKill;
}
- public LinkedList getCitizenNumToKill() {
- return citizenNumToKill;
+ public LinkedList getNpcNumToKill() {
+ return npcNumToKill;
}
- @Override
- public boolean addCitizenNumToKill(Integer citizenNumToKill) {
- return this.citizenNumToKill.add(citizenNumToKill);
+ public boolean addNpcNumToKill(Integer npcNumToKill) {
+ return this.npcNumToKill.add(npcNumToKill);
}
- public void setCitizenNumToKill(final LinkedList citizenNumToKill) {
- this.citizenNumToKill = citizenNumToKill;
+ public void setNpcNumToKill(final LinkedList npcNumToKill) {
+ this.npcNumToKill = npcNumToKill;
}
public LinkedList getMobsToKill() {
@@ -761,8 +758,8 @@ public class Stage implements IStage {
if (!itemsToBrew.isEmpty()) { return true; }
if (!itemsToConsume.isEmpty()) { return true; }
if (!itemsToDeliver.isEmpty()) { return true; }
- if (!citizensToInteract.isEmpty()) { return true; }
- if (!citizensToKill.isEmpty()) { return true; }
+ if (!npcsToInteract.isEmpty()) { return true; }
+ if (!npcsToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; }
if (!mobsToKill.isEmpty()) {return true; }
if (!mobsToTame.isEmpty()) { return true; }
@@ -777,8 +774,8 @@ public class Stage implements IStage {
* @return true if stage contains a locatable objective
*/
public boolean hasLocatableObjective() {
- if (!citizensToInteract.isEmpty()) { return true; }
- if (!citizensToKill.isEmpty()) { return true; }
+ if (!npcsToInteract.isEmpty()) { return true; }
+ if (!npcsToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; }
if (!itemDeliveryTargets.isEmpty()) { return true; }
if (playersToKill != null) { return true; }
@@ -826,9 +823,9 @@ public class Stage implements IStage {
} else if (type.equals(ObjectiveType.KILL_PLAYER)) {
return playersToKill != null;
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
- return !citizensToInteract.isEmpty();
+ return !npcsToInteract.isEmpty();
} else if (type.equals(ObjectiveType.KILL_NPC)) {
- return !citizensToKill.isEmpty();
+ return !npcsToKill.isEmpty();
} else if (type.equals(ObjectiveType.TAME_MOB)) {
return !mobsToTame.isEmpty();
} else if (type.equals(ObjectiveType.SHEAR_SHEEP)) {
diff --git a/core/src/main/java/me/blackvein/quests/convo/conditions/tasks/EntityPrompt.java b/core/src/main/java/me/blackvein/quests/convo/conditions/tasks/EntityPrompt.java
index 461bc6d9b..16d0f8000 100644
--- a/core/src/main/java/me/blackvein/quests/convo/conditions/tasks/EntityPrompt.java
+++ b/core/src/main/java/me/blackvein/quests/convo/conditions/tasks/EntityPrompt.java
@@ -251,7 +251,7 @@ public class EntityPrompt extends QuestsEditorNumericPrompt {
@Override
public String getQueryText(final ConversationContext context) {
- return Lang.get("conditionEditorNpcsPrompt");
+ return Lang.get("enterNpcUniqueIds");
}
@Override
diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/main/QuestMainPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/main/QuestMainPrompt.java
index d1de7f394..fb1989942 100644
--- a/core/src/main/java/me/blackvein/quests/convo/quests/main/QuestMainPrompt.java
+++ b/core/src/main/java/me/blackvein/quests/convo/quests/main/QuestMainPrompt.java
@@ -13,7 +13,6 @@
package me.blackvein.quests.convo.quests.main;
import com.sk89q.worldguard.protection.managers.RegionManager;
-import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.ItemStackPrompt;
@@ -26,6 +25,7 @@ import me.blackvein.quests.convo.quests.rewards.RewardsPrompt;
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
+import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
@@ -49,6 +49,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@@ -192,16 +193,13 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.Q_FINISH_MESSAGE)
+ ChatColor.RESET + ChatColor.GRAY + ")";
case 4:
- if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
+ if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
!= null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else if (plugin.getDependencies().getCitizens() != null) {
- final Integer id = (Integer) context.getSessionData(CK.Q_START_NPC);
- if (id != null) {
- return ChatColor.GRAY + "(" + ChatColor.AQUA + CitizensAPI.getNPCRegistry().getById(id).getName()
- + ChatColor.RESET + ChatColor.GRAY + ")";
- }
-
+ final UUID uuid = UUID.fromString((String) Objects.requireNonNull(context.getSessionData(CK.Q_START_NPC)));
+ return ChatColor.GRAY + "(" + ChatColor.AQUA + CitizensAPI.getNPCRegistry().getByUniqueId(uuid)
+ .getName() + ChatColor.RESET + ChatColor.GRAY + ")";
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
@@ -246,11 +244,17 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) {
final QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
-
+
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": "
+ ChatColor.AQUA) + ChatColor.GOLD + " -");
- for (int i = 1; i <= size; i++) {
- text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i).append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ").append(getAdditionalText(context, i));
+ try {
+ for (int i = 1; i <= size; i++) {
+ text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
+ .append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ")
+ .append(getAdditionalText(context, i));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
return text.toString();
}
@@ -475,15 +479,15 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
- final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
if (context.getForWhom() instanceof Player) {
final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
- return ChatColor.YELLOW + getQueryText(context) + "\n"
- + ChatColor.GOLD + Lang.get("npcHint");
+ return ChatColor.YELLOW + Lang.get("questEditorClickNPCStart");
} else {
return ChatColor.YELLOW + getQueryText(context);
}
@@ -496,23 +500,23 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
try {
- final int i = Integer.parseInt(input);
- if (i > -1) {
- if (CitizensAPI.getNPCRegistry().getById(i) == null) {
+ final UUID uuid = UUID.fromString(input);
+ if (plugin.getDependencies().getCitizens() != null) {
+ if (CitizensAPI.getNPCRegistry().getByUniqueId(uuid) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidNPC"));
return new QuestNPCStartPrompt(context);
}
- context.setSessionData(CK.Q_START_NPC, i);
- if (context.getForWhom() instanceof Player) {
- final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
- selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
- }
- return new QuestMainPrompt(context);
+ context.setSessionData(CK.Q_START_NPC, uuid.toString());
}
- } catch (final NumberFormatException e) {
+ if (context.getForWhom() instanceof Player) {
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
+ }
+ return new QuestMainPrompt(context);
+ } catch (final IllegalArgumentException e) {
context.getForWhom().sendRawMessage(ChatColor.RED
- + Lang.get("reqNotANumber").replace("", input));
+ + Lang.get("reqNotAUniqueId").replace("", input));
return new QuestNPCStartPrompt(context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@@ -606,7 +610,8 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
- final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
StringBuilder text = new StringBuilder(ChatColor.AQUA + getTitle(context) + "\n");
diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java
index 5978d3701..1d6b8ae0d 100644
--- a/core/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java
+++ b/core/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java
@@ -438,8 +438,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockBreakNamesPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockBreakNamesPrompt(context);
}
}
@@ -508,8 +508,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockBreakAmountsPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockBreakAmountsPrompt(context);
}
}
@@ -565,8 +565,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockBreakDurabilityPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockBreakDurabilityPrompt(context);
}
}
@@ -808,8 +808,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockDamageNamesPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockDamageNamesPrompt(context);
}
}
@@ -877,8 +877,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockDamageAmountsPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockDamageAmountsPrompt(context);
}
}
@@ -933,8 +933,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockDamageDurabilityPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockDamageDurabilityPrompt(context);
}
}
@@ -1176,8 +1176,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockPlaceNamesPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockPlaceNamesPrompt(context);
}
}
@@ -1245,8 +1245,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockPlaceAmountsPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockPlaceAmountsPrompt(context);
}
}
@@ -1301,8 +1301,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockPlaceDurabilityPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockPlaceDurabilityPrompt(context);
}
}
@@ -1542,8 +1542,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockUseNamesPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockUseNamesPrompt(context);
}
}
@@ -1610,8 +1610,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockUseAmountsPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockUseAmountsPrompt(context);
}
}
@@ -1666,8 +1666,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new BlockUseDurabilityPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfNumbers")
+ .replace("", s));
return new BlockUseDurabilityPrompt(context);
}
}
diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/objectives/NpcsPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/objectives/NpcsPrompt.java
index 8e5f77560..eb76faeb3 100644
--- a/core/src/main/java/me/blackvein/quests/convo/quests/objectives/NpcsPrompt.java
+++ b/core/src/main/java/me/blackvein/quests/convo/quests/objectives/NpcsPrompt.java
@@ -18,6 +18,7 @@ import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
import me.blackvein.quests.convo.quests.stages.StageMainPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
+import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
@@ -98,7 +99,8 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
final StringBuilder text = new StringBuilder();
- final LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
+ final LinkedList npcs
+ = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
final LinkedList items
= (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
if (npcs != null && items != null) {
@@ -106,9 +108,9 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(ItemUtil.getName(items.get(i))).append(ChatColor.GRAY).append(" x ")
.append(ChatColor.AQUA).append(items.get(i).getAmount()).append(ChatColor.GRAY)
- .append(" ").append(Lang.get("to")).append(" ").append(ChatColor.DARK_AQUA)
+ .append(" ").append(Lang.get("to")).append(" ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(npcs.get(i)).getName());
+ .getByUniqueId(UUID.fromString(npcs.get(i))).getName());
}
}
return text.toString();
@@ -122,13 +124,13 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
final StringBuilder text = new StringBuilder();
- final LinkedList npcs
- = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
+ final LinkedList npcs
+ = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
if (npcs != null) {
- for (final Integer npc : npcs) {
- text.append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
+ for (final String npc : npcs) {
+ text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(npc).getName()).append("\n");
+ .getByUniqueId(UUID.fromString(npc)).getName());
}
}
return text.toString();
@@ -142,15 +144,16 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
final StringBuilder text = new StringBuilder();
- final LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
+ final LinkedList npcs
+ = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final LinkedList amounts
= (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
if (npcs != null && amounts != null) {
for (int i = 0; i < npcs.size(); i++) {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(npcs.get(i)).getName()).append(ChatColor.GRAY).append(" x ")
- .append(ChatColor.AQUA).append(amounts.get(i));
+ .getByUniqueId(UUID.fromString(npcs.get(i))).getName()).append(ChatColor.GRAY)
+ .append(" x ").append(ChatColor.AQUA).append(amounts.get(i));
}
}
return text.toString();
@@ -260,7 +263,7 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
case 1:
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
case 2:
- return ChatColor.YELLOW + Lang.get("stageEditorDeliveryNPCs");
+ return ChatColor.YELLOW + Lang.get("stageEditorNPCUniqueIds");
case 3:
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryMessages");
case 4:
@@ -296,14 +299,14 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
final StringBuilder text = new StringBuilder();
- final List deliveryNpcs
- = (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
+ final List deliveryNpcs = (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
if (deliveryNpcs != null) {
- for (final int i : deliveryNpcs) {
- text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(i)
- .append(ChatColor.GRAY).append(" (").append(ChatColor.AQUA)
- .append(plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(i).getName()).append(ChatColor.GRAY).append(")");
+ for (final String s : deliveryNpcs) {
+ final UUID uuid = UUID.fromString(s);
+ text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
+ .append(plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid)
+ .getName()).append(ChatColor.GRAY).append(" (").append(ChatColor.BLUE).append(s)
+ .append(ChatColor.GRAY).append(")");
}
}
return text.toString();
@@ -386,7 +389,7 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
final int one;
final int two;
final List items = (List) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
- final List npcs = (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
+ final List npcs = (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
if (items != null) {
one = items.size();
} else {
@@ -427,56 +430,69 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getQueryText(final ConversationContext context) {
- return Lang.get("stageEditorNPCPrompt");
+ return Lang.get("enterNpcUniqueIds");
}
@Override
- public @NotNull String getPromptText(final ConversationContext context) {
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.add(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
- return ChatColor.YELLOW + getQueryText(context) + "\n" + ChatColor.GOLD + Lang.get("npcHint");
+ public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (context.getForWhom() instanceof Player) {
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
+ return ChatColor.YELLOW + Lang.get("questEditorClickNPCStart");
+ } else {
+ return ChatColor.YELLOW + getQueryText(context);
+ }
}
@Override
+ @SuppressWarnings("unchecked")
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final String[] args = input.split(" ");
- final LinkedList npcs = new LinkedList<>();
+ final LinkedList npcs = context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
+ ? (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS) : new LinkedList<>();
for (final String s : args) {
try {
- final int i = Integer.parseInt(s);
- if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) {
- npcs.add(i);
+ final UUID uuid = UUID.fromString(s);
+ if (plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) != null
+ && npcs != null) {
+ npcs.add(uuid.toString());
} else {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " "
+ context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + uuid + ChatColor.RED + " "
+ Lang.get("stageEditorInvalidNPC"));
return new NpcDeliveryNpcsPrompt(context);
}
- } catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ } catch (final IllegalArgumentException e) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfUniqueIds")
+ .replace("", s));
return new NpcDeliveryNpcsPrompt(context);
}
}
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
}
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.remove(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
return new NpcsDeliveryListPrompt(context);
}
}
public class NpcDeliveryMessagesPrompt extends QuestsEditorStringPrompt {
-
+
public NpcDeliveryMessagesPrompt(final ConversationContext context) {
super(context);
}
-
+
@Override
public String getTitle(final ConversationContext context) {
return null;
@@ -488,6 +504,12 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
}
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ }
+
return ChatColor.YELLOW + getQueryText(context) + "\n" + ChatColor.GOLD + Lang.get("stageEditorNPCNote");
}
@@ -506,11 +528,11 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
}
public class NpcsIdsToTalkToPrompt extends QuestsEditorStringPrompt {
-
+
public NpcsIdsToTalkToPrompt(final ConversationContext context) {
super(context);
}
-
+
@Override
public String getTitle(final ConversationContext context) {
return null;
@@ -518,39 +540,51 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getQueryText(final ConversationContext context) {
- return Lang.get("stageEditorNPCToTalkToPrompt");
+ return Lang.get("enterOrClearNpcUniqueIds");
}
@Override
- public @NotNull String getPromptText(final ConversationContext context) {
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.add(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
- return ChatColor.YELLOW + getQueryText(context) + "\n" + ChatColor.GOLD
- + Lang.get("npcHint");
+ public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (context.getForWhom() instanceof Player) {
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
+ return ChatColor.YELLOW + Lang.get("questEditorClickNPCStart");
+ } else {
+ return ChatColor.YELLOW + getQueryText(context);
+ }
}
@Override
+ @SuppressWarnings("unchecked")
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
final String[] args = input.split(" ");
- final LinkedList npcs = new LinkedList<>();
+ final LinkedList npcs = context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
+ ? (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : new LinkedList<>();
for (final String s : args) {
try {
- final int i = Integer.parseInt(s);
- if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) {
- npcs.add(i);
+ final UUID uuid = UUID.fromString(s);
+ if (plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) != null
+ && npcs != null) {
+ npcs.add(uuid.toString());
} else {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " "
+ context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + uuid + ChatColor.RED + " "
+ Lang.get("stageEditorInvalidNPC"));
return new NpcsIdsToTalkToPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfUniqueIds")
+ .replace("", s));
return new NpcsIdsToTalkToPrompt(context);
}
}
@@ -559,9 +593,9 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
}
if (context.getForWhom() instanceof Player) {
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.remove(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
}
return new StageMainPrompt(stageNum, context);
}
@@ -572,19 +606,19 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
public NpcsKillListPrompt(final ConversationContext context) {
super(context);
}
-
+
private final int size = 4;
-
+
@Override
public int getSize() {
return size;
}
-
+
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("stageEditorNPCs");
}
-
+
@Override
public ChatColor getNumberColor(final ConversationContext context, final int number) {
switch (number) {
@@ -599,12 +633,12 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return null;
}
}
-
+
@Override
public String getSelectionText(final ConversationContext context, final int number) {
switch(number) {
case 1:
- return ChatColor.YELLOW + Lang.get("stageEditorSetKillIds");
+ return ChatColor.YELLOW + Lang.get("stageEditorNPCUniqueIds");
case 2:
return ChatColor.YELLOW + Lang.get("stageEditorSetKillAmounts");
case 3:
@@ -615,7 +649,7 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return null;
}
}
-
+
@Override
@SuppressWarnings("unchecked")
public String getAdditionalText(final ConversationContext context, final int number) {
@@ -626,13 +660,13 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
final StringBuilder text = new StringBuilder();
- final List npcsToKill = (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
+ final List npcsToKill = (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
if (npcsToKill != null) {
- for (final Integer i : npcsToKill) {
- text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
+ for (final String s : npcsToKill) {
+ text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getCitizens().getNPCRegistry()
- .getById(i).getName()).append(ChatColor.DARK_AQUA).append(" (").append(i)
- .append(")");
+ .getByUniqueId(UUID.fromString(s)).getName()).append(ChatColor.GRAY).append(" (")
+ .append(ChatColor.AQUA).append(s).append(ChatColor.GRAY).append(")");
}
}
return text.toString();
@@ -678,7 +712,7 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
-
+
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
@@ -695,7 +729,7 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
case 4:
final int one;
final int two;
- final List kill = (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
+ final List kill = (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final List killAmounts
= (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
if (kill != null) {
@@ -721,11 +755,11 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
}
public class NpcIdsToKillPrompt extends QuestsEditorStringPrompt {
-
+
public NpcIdsToKillPrompt(final ConversationContext context) {
super(context);
}
-
+
@Override
public String getTitle(final ConversationContext context) {
return null;
@@ -733,46 +767,59 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getQueryText(final ConversationContext context) {
- return Lang.get("stageEditorNPCPrompt");
- }
-
- @Override
- public @NotNull String getPromptText(final ConversationContext context) {
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.add(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
- return ChatColor.YELLOW + getQueryText(context) + "\n" + ChatColor.GOLD + Lang.get("npcHint");
+ return Lang.get("enterNpcUniqueIds");
}
@Override
+ public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (context.getForWhom() instanceof Player) {
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
+ return ChatColor.YELLOW + Lang.get("questEditorClickNPCStart");
+ } else {
+ return ChatColor.YELLOW + getQueryText(context);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final String[] args = input.split(" ");
- final LinkedList npcs = new LinkedList<>();
+ final LinkedList npcs = context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
+ ? (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL) : new LinkedList<>();
for (final String s : args) {
try {
- final int i = Integer.parseInt(s);
- if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) {
- npcs.add(i);
+ final UUID uuid = UUID.fromString(s);
+ if (plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) != null
+ && npcs != null) {
+ npcs.add(uuid.toString());
} else {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " "
+ context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + uuid + ChatColor.RED + " "
+ Lang.get("stageEditorInvalidNPC"));
return new NpcIdsToKillPrompt(context);
}
- } catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ } catch (final IllegalArgumentException e) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfUniqueIds")
+ .replace("", s));
return new NpcIdsToKillPrompt(context);
}
}
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
}
- final Set temp = plugin.getQuestFactory().getSelectingNpcs();
- temp.remove(((Player) context.getForWhom()).getUniqueId());
- plugin.getQuestFactory().setSelectingNpcs(temp);
+ final Set selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
+ selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
+ plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
return new NpcsKillListPrompt(context);
}
}
@@ -795,6 +842,12 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ }
+
return ChatColor.YELLOW + getQueryText(context);
}
@@ -816,8 +869,8 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
return new NpcAmountsToKillPrompt(context);
}
} catch (final NumberFormatException e) {
- context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
- + Lang.get("stageEditorNotListofNumbers"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNotListOfUniqueIds")
+ .replace("", s));
return new NpcAmountsToKillPrompt(context);
}
}
diff --git a/core/src/main/java/me/blackvein/quests/listeners/NpcListener.java b/core/src/main/java/me/blackvein/quests/listeners/NpcListener.java
index d4a2fdccf..5ac96e7e8 100644
--- a/core/src/main/java/me/blackvein/quests/listeners/NpcListener.java
+++ b/core/src/main/java/me/blackvein/quests/listeners/NpcListener.java
@@ -12,10 +12,10 @@
package me.blackvein.quests.listeners;
-import me.blackvein.quests.quests.IQuest;
-import me.blackvein.quests.player.IQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType;
+import me.blackvein.quests.player.IQuester;
+import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.event.NPCDeathEvent;
@@ -42,6 +42,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.UUID;
public class NpcListener implements Listener {
@@ -58,9 +59,11 @@ public class NpcListener implements Listener {
return;
}
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());
- return;
+ if (evt.getNPC() == null) {
+ plugin.getLogger().severe("NPC was null while selecting by right-click");
+ return;
+ }
+ evt.getClicker().acceptConversationInput(String.valueOf(evt.getNPC().getUniqueId()));
}
if (!evt.getClicker().isConversing()) {
final Player player = evt.getClicker();
@@ -81,15 +84,15 @@ public class NpcListener implements Listener {
final NPC clicked = evt.getNPC();
if (!matches.isEmpty()) {
for (final Integer match : matches) {
- final Integer id = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
- if (id.equals(clicked.getId())) {
+ final UUID uuid = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
+ if (uuid.equals(clicked.getUniqueId())) {
quester.deliverToNPC(quest, clicked, hand);
return;
}
}
} else if (!hand.getType().equals(Material.AIR)) {
- for (final Integer n : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
- if (n.equals(clicked.getId())) {
+ for (final UUID uuid : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
+ if (uuid.equals(clicked.getUniqueId())) {
String text = "";
final boolean hasMeta = hand.getItemMeta() != null;
if (hasMeta) {
@@ -189,10 +192,10 @@ public class NpcListener implements Listener {
boolean hasObjective = false;
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
- final int npcIndex
- = quester.getCurrentStage(quest).getCitizensToInteract().indexOf(evt.getNPC().getId());
+ final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(evt.getNPC()
+ .getUniqueId());
if (quester.getQuestData(quest) != null && npcIndex > -1
- && !quester.getQuestData(quest).citizensInteracted.get(npcIndex)) {
+ && !quester.getQuestData(quest).npcsInteracted.get(npcIndex)) {
hasObjective = true;
}
quester.interactWithNPC(quest, evt.getNPC());
@@ -262,8 +265,11 @@ public class NpcListener implements Listener {
return;
}
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());
+ if (evt.getNPC() == null) {
+ plugin.getLogger().severe("NPC was null while selecting by left-click");
+ return;
+ }
+ evt.getClicker().acceptConversationInput(String.valueOf(evt.getNPC().getUniqueId()));
}
}
diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java
index f4069f56c..e54000b94 100644
--- a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java
+++ b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java
@@ -12,12 +12,12 @@
package me.blackvein.quests.quests;
-import me.blackvein.quests.module.ICustomObjective;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.main.QuestMainPrompt;
import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt;
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
import me.blackvein.quests.interfaces.ReloadCallback;
+import me.blackvein.quests.module.ICustomObjective;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.FakeConversable;
@@ -144,377 +144,390 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
@SuppressWarnings("deprecation")
public void loadQuest(final ConversationContext context, final IQuest q) {
- context.setSessionData(CK.ED_QUEST_EDIT, q.getName());
- context.setSessionData(CK.Q_ID, q.getId());
- context.setSessionData(CK.Q_NAME, q.getName());
- context.setSessionData(CK.Q_ASK_MESSAGE, q.getDescription());
- context.setSessionData(CK.Q_FINISH_MESSAGE, q.getFinished());
- if (plugin.getDependencies().getCitizens() != null) {
- if (q.getNpcStart() != null) {
- context.setSessionData(CK.Q_START_NPC, q.getNpcStart().getId());
- }
- }
- context.setSessionData(CK.Q_START_BLOCK, q.getBlockStart());
- if (q.getInitialAction() != null) {
- context.setSessionData(CK.Q_INITIAL_EVENT, q.getInitialAction().getName());
- }
- if (q.getRegionStart() != null) {
- context.setSessionData(CK.Q_REGION, q.getRegionStart());
- }
- if (q.getGUIDisplay() != null) {
- context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay());
- }
- final Requirements requirements = q.getRequirements();
- if (requirements.getMoney() != 0) {
- context.setSessionData(CK.REQ_MONEY, requirements.getMoney());
- }
- if (requirements.getQuestPoints() != 0) {
- context.setSessionData(CK.REQ_QUEST_POINTS, requirements.getQuestPoints());
- }
- if (requirements.getExp() != 0) {
- context.setSessionData(CK.REW_EXP, requirements.getExp());
- }
- if (!requirements.getItems().isEmpty()) {
- context.setSessionData(CK.REQ_ITEMS, requirements.getItems());
- context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
- }
- if (!requirements.getNeededQuests().isEmpty()) {
- final List ids = requirements.getNeededQuests().stream().map(IQuest::getId).collect(Collectors.toList());
- context.setSessionData(CK.REQ_QUEST, ids);
- }
- if (!requirements.getBlockQuests().isEmpty()) {
- final List ids = requirements.getBlockQuests().stream().map(IQuest::getId).collect(Collectors.toList());
- context.setSessionData(CK.REQ_QUEST_BLOCK, ids);
- }
- if (!requirements.getMcmmoSkills().isEmpty()) {
- context.setSessionData(CK.REQ_MCMMO_SKILLS, requirements.getMcmmoAmounts());
- context.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, requirements.getMcmmoAmounts());
- }
- if (!requirements.getPermissions().isEmpty()) {
- context.setSessionData(CK.REQ_PERMISSION, requirements.getPermissions());
- }
- if (requirements.getHeroesPrimaryClass() != null) {
- context.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, requirements.getHeroesPrimaryClass());
- }
- if (requirements.getHeroesSecondaryClass() != null) {
- context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, requirements.getHeroesSecondaryClass());
- }
- if (!requirements.getCustomRequirements().isEmpty()) {
- final LinkedList list = new LinkedList<>();
- final LinkedList