Track NPCs by UUID instead. Bump version

This commit is contained in:
PikaMug 2022-04-17 19:28:23 -04:00
parent b7282cbada
commit c593c210a3
24 changed files with 950 additions and 750 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<artifactId>quests-api</artifactId>

View File

@ -513,7 +513,7 @@ public class QuestData {
}
};
public LinkedList<Boolean> citizensInteracted = new LinkedList<Boolean>() {
public LinkedList<Boolean> npcsInteracted = new LinkedList<Boolean>() {
private static final long serialVersionUID = 2447610341508300847L;
@ -580,7 +580,7 @@ public class QuestData {
}
};
public LinkedList<Integer> citizensNumKilled = new LinkedList<Integer>() {
public LinkedList<Integer> npcsNumKilled = new LinkedList<Integer>() {
private static final long serialVersionUID = 1849192351499071688L;
@ -1180,23 +1180,23 @@ public class QuestData {
}
}
public LinkedList<Boolean> getCitizensInteracted() {
return citizensInteracted;
public LinkedList<Boolean> getNpcsInteracted() {
return npcsInteracted;
}
public void setCitizensInteracted(final LinkedList<Boolean> citizensInteracted) {
this.citizensInteracted = citizensInteracted;
public void setNpcsInteracted(final LinkedList<Boolean> npcsInteracted) {
this.npcsInteracted = npcsInteracted;
if (doJournalUpdate) {
quester.updateJournal();
}
}
public LinkedList<Integer> getCitizensNumKilled() {
return citizensNumKilled;
public LinkedList<Integer> getNpcsNumKilled() {
return npcsNumKilled;
}
public void setCitizensNumKilled(final LinkedList<Integer> citizensNumKilled) {
this.citizensNumKilled = citizensNumKilled;
public void setNpcsNumKilled(final LinkedList<Integer> npcsNumKilled) {
this.npcsNumKilled = npcsNumKilled;
if (doJournalUpdate) {
quester.updateJournal();
}

View File

@ -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);

View File

@ -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<ItemStack> getBlocksToBreak();
@ -92,11 +93,11 @@ public interface IStage {
void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver);
LinkedList<Integer> getItemDeliveryTargets();
LinkedList<UUID> getItemDeliveryTargets();
boolean addItemDeliveryTarget(Integer itemDeliveryTarget);
boolean addItemDeliveryTarget(UUID itemDeliveryTarget);
void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets);
void setItemDeliveryTargets(final LinkedList<UUID> itemDeliveryTargets);
LinkedList<String> getDeliverMessages();
@ -104,23 +105,23 @@ public interface IStage {
void setDeliverMessages(final LinkedList<String> deliverMessages);
LinkedList<Integer> getCitizensToInteract();
LinkedList<UUID> getNpcsToInteract();
boolean addCitizenToInteract(Integer citizenToInteract);
boolean addNpcToInteract(UUID npcToInteract);
void setCitizensToInteract(final LinkedList<Integer> citizensToInteract);
void setNpcsToInteract(final LinkedList<UUID> npcsToInteract);
LinkedList<Integer> getCitizensToKill();
LinkedList<UUID> getNpcsToKill();
boolean addCitizenToKill(Integer citizenToKill);
boolean addNpcToKill(UUID citizenToKill);
void setCitizensToKill(final LinkedList<Integer> citizensToKill);
void setNpcsToKill(final LinkedList<UUID> npcsToKill);
LinkedList<Integer> getCitizenNumToKill();
LinkedList<Integer> getNpcNumToKill();
boolean addCitizenNumToKill(Integer citizenNumToKill);
boolean addNpcNumToKill(Integer npcNumToKill);
void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill);
void setNpcNumToKill(final LinkedList<Integer> npcNumToKill);
LinkedList<EntityType> getMobsToKill();

View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<artifactId>quests-core</artifactId>

View File

@ -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);

View File

@ -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) {

View File

@ -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("<npc>", depends.getNPCName(npc));
if (message.contains("<count>")) {
@ -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("<mob>")) {
@ -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("<npc>", depends.getNPCName(npc));
if (message.contains("<count>")) {
@ -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("<npc>", 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("<mob>")) {
@ -2967,7 +2967,7 @@ public class Quester implements IQuester {
if (npc == null) {
return;
}
int currentIndex = -1;
final LinkedList<Integer> 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<ItemStack> 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<String> 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<String> 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);

View File

@ -151,6 +151,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
private final Collection<IQuest> quests = new ConcurrentSkipListSet<>();
private Collection<IAction> actions = new ConcurrentSkipListSet<>();
private Collection<ICondition> conditions = new ConcurrentSkipListSet<>();
private LinkedList<UUID> questNpcUuids = new LinkedList<>();
private LinkedList<Integer> 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<UUID> getQuestNpcUuids() {
return questNpcUuids;
}
public void setQuestNpcUuids(final LinkedList<UUID> questNpcUuids) {
this.questNpcUuids = questNpcUuids;
}
/**
* @deprecated Use {@link #getQuestNpcUuids()}
*/
public LinkedList<Integer> getQuestNpcIds() {
return questNpcIds;
}
/**
* @deprecated Use {@link #setQuestNpcUuids(LinkedList)}
*/
public void setQuestNpcIds(final LinkedList<Integer> 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("<npc>", depends.getNPCName(npc));
if (message.contains("<count>")) {
@ -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("<npc>", depends.getNPCName(n));
.replace("<npc>", 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("<mob>")) {
message = message.replace("<mob>", depends.getNPCName(n));
message = message.replace("<mob>", depends.getNPCName(uuid));
} else {
message += " " + depends.getNPCName(n);
message += " " + depends.getNPCName(uuid);
}
if (message.contains("<count>")) {
message = message.replace("<count>", "" + 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<ItemStack> itemsToEnchant;
final List<ItemStack> itemsToBrew;
final List<ItemStack> itemsToConsume;
final List<String> npcUuidsToTalkTo;
final List<Integer> npcIdsToTalkTo;
final List<ItemStack> itemsToDeliver;
final List<String> itemDeliveryTargetUuids;
final List<Integer> itemDeliveryTargetIds;
final List<String> deliveryMessages;
final List<String> npcUuidsToKill;
final List<Integer> npcIdsToKill;
final List<Integer> 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<ItemStack>) config.get("quests." + questKey + ".stages.ordered."
itemsToDeliver = (List<ItemStack>) 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<ItemStack>) 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<String> 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")) {

View File

@ -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<ItemStack> itemsToBrew = new LinkedList<>();
private LinkedList<ItemStack> itemsToConsume = new LinkedList<>();
private LinkedList<ItemStack> itemsToDeliver = new LinkedList<>();
private LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private LinkedList<UUID> itemDeliveryTargets = new LinkedList<UUID>() {
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<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
final LinkedList<UUID> otherList = (LinkedList<UUID>) 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<String> deliverMessages = new LinkedList<>();
private LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
private LinkedList<UUID> npcsToInteract = new LinkedList<UUID>() {
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<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
final LinkedList<UUID> otherList = (LinkedList<UUID>) 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<Integer> citizensToKill = new LinkedList<Integer>() {
private LinkedList<UUID> npcsToKill = new LinkedList<UUID>() {
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<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
final LinkedList<UUID> otherList = (LinkedList<UUID>) 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<Integer> citizenNumToKill = new LinkedList<>();
private LinkedList<Integer> npcNumToKill = new LinkedList<>();
private LinkedList<EntityType> mobsToKill = new LinkedList<>();
private LinkedList<Integer> mobNumToKill = new LinkedList<>();
private LinkedList<Location> locationsToKillWithin = new LinkedList<>();
@ -284,16 +282,16 @@ public class Stage implements IStage {
this.itemsToDeliver = itemsToDeliver;
}
public LinkedList<Integer> getItemDeliveryTargets() {
public LinkedList<UUID> getItemDeliveryTargets() {
return itemDeliveryTargets;
}
@Override
public boolean addItemDeliveryTarget(Integer itemDeliveryTarget) {
public boolean addItemDeliveryTarget(UUID itemDeliveryTarget) {
return itemDeliveryTargets.add(itemDeliveryTarget);
}
public void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets) {
public void setItemDeliveryTargets(final LinkedList<UUID> itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets;
}
@ -310,43 +308,42 @@ public class Stage implements IStage {
this.deliverMessages = deliverMessages;
}
public LinkedList<Integer> getCitizensToInteract() {
return citizensToInteract;
public LinkedList<UUID> 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<Integer> citizensToInteract) {
this.citizensToInteract = citizensToInteract;
public void setNpcsToInteract(final LinkedList<UUID> npcsToInteract) {
this.npcsToInteract = npcsToInteract;
}
public LinkedList<Integer> getCitizensToKill() {
return citizensToKill;
public LinkedList<UUID> 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<Integer> citizensToKill) {
this.citizensToKill = citizensToKill;
public void setNpcsToKill(final LinkedList<UUID> npcsToKill) {
this.npcsToKill = npcsToKill;
}
public LinkedList<Integer> getCitizenNumToKill() {
return citizenNumToKill;
public LinkedList<Integer> 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<Integer> citizenNumToKill) {
this.citizenNumToKill = citizenNumToKill;
public void setNpcNumToKill(final LinkedList<Integer> npcNumToKill) {
this.npcNumToKill = npcNumToKill;
}
public LinkedList<EntityType> 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)) {

View File

@ -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

View File

@ -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<UUID> 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<UUID> 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<UUID> 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>", input));
+ Lang.get("reqNotAUniqueId").replace("<input>", 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");

View File

@ -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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", 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("<data>", s));
return new BlockUseDurabilityPrompt(context);
}
}

View File

@ -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<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
final LinkedList<String> npcs
= (LinkedList<String>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
final LinkedList<ItemStack> items
= (LinkedList<ItemStack>) 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<Integer> npcs
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
final LinkedList<String> npcs
= (LinkedList<String>) 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<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final LinkedList<String> npcs
= (LinkedList<String>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final LinkedList<Integer> amounts
= (LinkedList<Integer>) 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<Integer> deliveryNpcs
= (List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
final List<String> deliveryNpcs = (List<String>) 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<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
final List<Integer> npcs = (List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
final List<UUID> npcs = (List<UUID>) 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<UUID> 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<UUID> 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<Integer> npcs = new LinkedList<>();
final LinkedList<String> npcs = context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
? (LinkedList<String>) 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("<data>", s));
return new NpcDeliveryNpcsPrompt(context);
}
}
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
}
final Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove(((Player) context.getForWhom()).getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp);
final Set<UUID> 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<UUID> 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<UUID> 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<Integer> npcs = new LinkedList<>();
final LinkedList<String> npcs = context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
? (LinkedList<String>) 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("<data>", 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<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove(((Player) context.getForWhom()).getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp);
final Set<UUID> 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<Integer> npcsToKill = (List<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final List<String> npcsToKill = (List<String>) 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<Integer> kill = (List<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final List<UUID> kill = (List<UUID>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
final List<Integer> killAmounts
= (List<Integer>) 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<UUID> 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<UUID> 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<Integer> npcs = new LinkedList<>();
final LinkedList<String> npcs = context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
? (LinkedList<String>) 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("<data>", s));
return new NpcIdsToKillPrompt(context);
}
}
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
}
final Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove(((Player) context.getForWhom()).getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp);
final Set<UUID> 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("<data>", s));
return new NpcAmountsToKillPrompt(context);
}
}

View File

@ -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()));
}
}

View File

@ -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<String> ids = requirements.getNeededQuests().stream().map(IQuest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids);
}
if (!requirements.getBlockQuests().isEmpty()) {
final List<String> 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<String> list = new LinkedList<>();
final LinkedList<Map<String, Object>> dataMapList = new LinkedList<>();
for (final Entry<String, Map<String, Object>> entry : requirements.getCustomRequirements().entrySet()) {
list.add(entry.getKey());
dataMapList.add(entry.getValue());
}
context.setSessionData(CK.REQ_CUSTOM, list);
context.setSessionData(CK.REQ_CUSTOM_DATA, dataMapList);
}
if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
}
final Rewards rewards = q.getRewards();
if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney());
}
if (rewards.getQuestPoints() != 0) {
context.setSessionData(CK.REW_QUEST_POINTS, rewards.getQuestPoints());
}
if (rewards.getExp() != 0) {
context.setSessionData(CK.REW_EXP, rewards.getExp());
}
if (!rewards.getItems().isEmpty()) {
context.setSessionData(CK.REW_ITEMS, rewards.getItems());
}
if (!rewards.getCommands().isEmpty()) {
context.setSessionData(CK.REW_COMMAND, rewards.getCommands());
}
if (!rewards.getCommandsOverrideDisplay().isEmpty()) {
context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rewards.getCommandsOverrideDisplay());
}
if (!rewards.getPermissions().isEmpty()) {
context.setSessionData(CK.REW_PERMISSION, rewards.getPermissions());
}
if (!rewards.getPermissions().isEmpty()) {
context.setSessionData(CK.REW_PERMISSION_WORLDS, rewards.getPermissionWorlds());
}
if (!rewards.getMcmmoSkills().isEmpty()) {
context.setSessionData(CK.REW_MCMMO_SKILLS, rewards.getMcmmoSkills());
context.setSessionData(CK.REW_MCMMO_AMOUNTS, rewards.getMcmmoAmounts());
}
if (!rewards.getHeroesClasses().isEmpty()) {
context.setSessionData(CK.REW_HEROES_CLASSES, rewards.getHeroesClasses());
context.setSessionData(CK.REW_HEROES_AMOUNTS, rewards.getHeroesAmounts());
}
if (rewards.getPartiesExperience() != 0) {
context.setSessionData(CK.REW_PARTIES_EXPERIENCE, rewards.getPartiesExperience());
}
if (!rewards.getPhatLoots().isEmpty()) {
context.setSessionData(CK.REW_PHAT_LOOTS, rewards.getPhatLoots());
}
if (!rewards.getCustomRewards().isEmpty()) {
context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rewards.getCustomRewards().keySet()));
context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(rewards.getCustomRewards().values()));
}
if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
}
final Planner pln = q.getPlanner();
if (pln.getStart() != null) {
context.setSessionData(CK.PLN_START_DATE, pln.getStart());
}
if (pln.getEnd() != null) {
context.setSessionData(CK.PLN_END_DATE, pln.getEnd());
}
if (pln.getRepeat() != -1) {
context.setSessionData(CK.PLN_REPEAT_CYCLE, pln.getRepeat());
}
if (pln.getCooldown() != -1) {
context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
}
context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride());
final Options opt = q.getOptions();
context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch());
context.setSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN, opt.getExternalPartyPlugin());
context.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.canUsePartiesPlugin());
context.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel());
context.setSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY, opt.canShareSameQuestOnly());
context.setSessionData(CK.OPT_SHARE_DISTANCE, opt.getShareDistance());
context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers());
// Stages (Objectives)
int index = 1;
for (final IStage stage : q.getStages()) {
final String pref = "stage" + index;
index++;
context.setSessionData(pref, Boolean.TRUE);
if (!stage.getBlocksToBreak().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToBreak()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
try {
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().getUniqueId().toString());
}
context.setSessionData(pref + CK.S_BREAK_NAMES, names);
context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_BREAK_DURABILITY, durability);
}
if (!stage.getBlocksToDamage().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToDamage()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
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<String> ids = requirements.getNeededQuests().stream().map(IQuest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids);
}
if (!requirements.getBlockQuests().isEmpty()) {
final List<String> 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<String> list = new LinkedList<>();
final LinkedList<Map<String, Object>> dataMapList = new LinkedList<>();
for (final Entry<String, Map<String, Object>> entry : requirements.getCustomRequirements().entrySet()) {
list.add(entry.getKey());
dataMapList.add(entry.getValue());
}
context.setSessionData(pref + CK.S_DAMAGE_NAMES, names);
context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durability);
context.setSessionData(CK.REQ_CUSTOM, list);
context.setSessionData(CK.REQ_CUSTOM_DATA, dataMapList);
}
if (!stage.getBlocksToPlace().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToPlace()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
}
final Rewards rewards = q.getRewards();
if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney());
}
if (rewards.getQuestPoints() != 0) {
context.setSessionData(CK.REW_QUEST_POINTS, rewards.getQuestPoints());
}
if (rewards.getExp() != 0) {
context.setSessionData(CK.REW_EXP, rewards.getExp());
}
if (!rewards.getItems().isEmpty()) {
context.setSessionData(CK.REW_ITEMS, rewards.getItems());
}
if (!rewards.getCommands().isEmpty()) {
context.setSessionData(CK.REW_COMMAND, rewards.getCommands());
}
if (!rewards.getCommandsOverrideDisplay().isEmpty()) {
context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rewards.getCommandsOverrideDisplay());
}
if (!rewards.getPermissions().isEmpty()) {
context.setSessionData(CK.REW_PERMISSION, rewards.getPermissions());
}
if (!rewards.getPermissions().isEmpty()) {
context.setSessionData(CK.REW_PERMISSION_WORLDS, rewards.getPermissionWorlds());
}
if (!rewards.getMcmmoSkills().isEmpty()) {
context.setSessionData(CK.REW_MCMMO_SKILLS, rewards.getMcmmoSkills());
context.setSessionData(CK.REW_MCMMO_AMOUNTS, rewards.getMcmmoAmounts());
}
if (!rewards.getHeroesClasses().isEmpty()) {
context.setSessionData(CK.REW_HEROES_CLASSES, rewards.getHeroesClasses());
context.setSessionData(CK.REW_HEROES_AMOUNTS, rewards.getHeroesAmounts());
}
if (rewards.getPartiesExperience() != 0) {
context.setSessionData(CK.REW_PARTIES_EXPERIENCE, rewards.getPartiesExperience());
}
if (!rewards.getPhatLoots().isEmpty()) {
context.setSessionData(CK.REW_PHAT_LOOTS, rewards.getPhatLoots());
}
if (!rewards.getCustomRewards().isEmpty()) {
context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rewards.getCustomRewards().keySet()));
context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(rewards.getCustomRewards().values()));
}
if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
}
final Planner pln = q.getPlanner();
if (pln.getStart() != null) {
context.setSessionData(CK.PLN_START_DATE, pln.getStart());
}
if (pln.getEnd() != null) {
context.setSessionData(CK.PLN_END_DATE, pln.getEnd());
}
if (pln.getRepeat() != -1) {
context.setSessionData(CK.PLN_REPEAT_CYCLE, pln.getRepeat());
}
if (pln.getCooldown() != -1) {
context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
}
context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride());
final Options opt = q.getOptions();
context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch());
context.setSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN, opt.getExternalPartyPlugin());
context.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.canUsePartiesPlugin());
context.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel());
context.setSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY, opt.canShareSameQuestOnly());
context.setSessionData(CK.OPT_SHARE_DISTANCE, opt.getShareDistance());
context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers());
// Stages (Objectives)
int index = 1;
for (final IStage stage : q.getStages()) {
final String pref = "stage" + index;
index++;
context.setSessionData(pref, Boolean.TRUE);
if (!stage.getBlocksToBreak().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToBreak()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
}
context.setSessionData(pref + CK.S_BREAK_NAMES, names);
context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_BREAK_DURABILITY, durability);
}
context.setSessionData(pref + CK.S_PLACE_NAMES, names);
context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_PLACE_DURABILITY, durability);
}
if (!stage.getBlocksToUse().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToUse()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
if (!stage.getBlocksToDamage().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToDamage()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
}
context.setSessionData(pref + CK.S_DAMAGE_NAMES, names);
context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durability);
}
context.setSessionData(pref + CK.S_USE_NAMES, names);
context.setSessionData(pref + CK.S_USE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_USE_DURABILITY, durability);
}
if (!stage.getBlocksToCut().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToCut()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
if (!stage.getBlocksToPlace().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToPlace()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
}
context.setSessionData(pref + CK.S_PLACE_NAMES, names);
context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_PLACE_DURABILITY, durability);
}
context.setSessionData(pref + CK.S_CUT_NAMES, names);
context.setSessionData(pref + CK.S_CUT_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_CUT_DURABILITY, durability);
}
if (!stage.getItemsToCraft().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToCraft());
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
}
if (!stage.getItemsToSmelt().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToSmelt());
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
}
if (!stage.getItemsToEnchant().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToEnchant());
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
}
if (!stage.getItemsToBrew().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToBrew());
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
}
if (!stage.getItemsToConsume().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToConsume());
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
}
if (stage.getCowsToMilk() != null) {
context.setSessionData(pref + CK.S_COW_MILK, stage.getCowsToMilk());
}
if (stage.getFishToCatch() != null) {
context.setSessionData(pref + CK.S_FISH, stage.getFishToCatch());
}
if (stage.getPlayersToKill() != null) {
context.setSessionData(pref + CK.S_PLAYER_KILL, stage.getPlayersToKill());
}
if (!stage.getItemsToDeliver().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToDeliver());
final LinkedList<Integer> npcs = new LinkedList<>(stage.getItemDeliveryTargets());
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.getDeliverMessages());
}
if (!stage.getCitizensToInteract().isEmpty()) {
final LinkedList<Integer> npcs = new LinkedList<>(stage.getCitizensToInteract());
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
}
if (!stage.getCitizensToKill().isEmpty()) {
final LinkedList<Integer> npcs = new LinkedList<>(stage.getCitizensToKill());
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.getCitizenNumToKill());
}
if (!stage.getMobsToKill().isEmpty()) {
final LinkedList<String> mobs = new LinkedList<>();
for (final EntityType et : stage.getMobsToKill()) {
mobs.add(MiscUtil.getPrettyMobName(et));
if (!stage.getBlocksToUse().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToUse()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
}
context.setSessionData(pref + CK.S_USE_NAMES, names);
context.setSessionData(pref + CK.S_USE_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_USE_DURABILITY, durability);
}
context.setSessionData(pref + CK.S_MOB_TYPES, mobs);
context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill());
if (!stage.getLocationsToKillWithin().isEmpty()) {
if (!stage.getBlocksToCut().isEmpty()) {
final LinkedList<String> names = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> durability = new LinkedList<>();
for (final ItemStack e : stage.getBlocksToCut()) {
names.add(e.getType().name());
amounts.add(e.getAmount());
durability.add(e.getDurability());
}
context.setSessionData(pref + CK.S_CUT_NAMES, names);
context.setSessionData(pref + CK.S_CUT_AMOUNTS, amounts);
context.setSessionData(pref + CK.S_CUT_DURABILITY, durability);
}
if (!stage.getItemsToCraft().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToCraft());
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
}
if (!stage.getItemsToSmelt().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToSmelt());
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
}
if (!stage.getItemsToEnchant().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToEnchant());
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
}
if (!stage.getItemsToBrew().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToBrew());
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
}
if (!stage.getItemsToConsume().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToConsume());
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
}
if (stage.getCowsToMilk() != null) {
context.setSessionData(pref + CK.S_COW_MILK, stage.getCowsToMilk());
}
if (stage.getFishToCatch() != null) {
context.setSessionData(pref + CK.S_FISH, stage.getFishToCatch());
}
if (stage.getPlayersToKill() != null) {
context.setSessionData(pref + CK.S_PLAYER_KILL, stage.getPlayersToKill());
}
if (!stage.getItemsToDeliver().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToDeliver());
final LinkedList<String> npcs = new LinkedList<>();
for (UUID uuid : stage.getItemDeliveryTargets()) {
npcs.add(uuid.toString());
}
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.getDeliverMessages());
}
if (!stage.getNpcsToInteract().isEmpty()) {
final LinkedList<String> npcs = new LinkedList<>();
for (UUID uuid : stage.getNpcsToInteract()) {
npcs.add(uuid.toString());
}
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
}
if (!stage.getNpcsToKill().isEmpty()) {
final LinkedList<String> npcs = new LinkedList<>();
for (UUID uuid : stage.getNpcsToKill()) {
npcs.add(uuid.toString());
}
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.getNpcNumToKill());
}
if (!stage.getMobsToKill().isEmpty()) {
final LinkedList<String> mobs = new LinkedList<>();
for (final EntityType et : stage.getMobsToKill()) {
mobs.add(MiscUtil.getPrettyMobName(et));
}
context.setSessionData(pref + CK.S_MOB_TYPES, mobs);
context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill());
if (!stage.getLocationsToKillWithin().isEmpty()) {
final LinkedList<String> locations = new LinkedList<>();
for (final Location l : stage.getLocationsToKillWithin()) {
locations.add(ConfigUtil.getLocationInfo(l));
}
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locations);
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, stage.getRadiiToKillWithin());
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, stage.getKillNames());
}
}
if (!stage.getLocationsToReach().isEmpty()) {
final LinkedList<String> locations = new LinkedList<>();
for (final Location l : stage.getLocationsToKillWithin()) {
for (final Location l : stage.getLocationsToReach()) {
locations.add(ConfigUtil.getLocationInfo(l));
}
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locations);
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, stage.getRadiiToKillWithin());
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, stage.getKillNames());
context.setSessionData(pref + CK.S_REACH_LOCATIONS, locations);
context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, stage.getRadiiToReachWithin());
context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames());
}
}
if (!stage.getLocationsToReach().isEmpty()) {
final LinkedList<String> locations = new LinkedList<>();
for (final Location l : stage.getLocationsToReach()) {
locations.add(ConfigUtil.getLocationInfo(l));
if (!stage.getMobsToTame().isEmpty()) {
final LinkedList<String> mobs = new LinkedList<>();
for (final EntityType e : stage.getMobsToTame()) {
mobs.add(MiscUtil.getPrettyMobName(e));
}
final LinkedList<Integer> amounts = new LinkedList<>(stage.getMobNumToTame());
context.setSessionData(pref + CK.S_TAME_TYPES, mobs);
context.setSessionData(pref + CK.S_TAME_AMOUNTS, amounts);
}
context.setSessionData(pref + CK.S_REACH_LOCATIONS, locations);
context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, stage.getRadiiToReachWithin());
context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames());
}
if (!stage.getMobsToTame().isEmpty()) {
final LinkedList<String> mobs = new LinkedList<>();
for (final EntityType e : stage.getMobsToTame()) {
mobs.add(MiscUtil.getPrettyMobName(e));
}
final LinkedList<Integer> amounts = new LinkedList<>(stage.getMobNumToTame());
context.setSessionData(pref + CK.S_TAME_TYPES, mobs);
context.setSessionData(pref + CK.S_TAME_AMOUNTS, amounts);
}
if (!stage.getSheepToShear().isEmpty()) {
final LinkedList<String> colors = new LinkedList<>();
for (final DyeColor d : stage.getSheepToShear()) {
colors.add(MiscUtil.getPrettyDyeColorName(d));
if (!stage.getSheepToShear().isEmpty()) {
final LinkedList<String> colors = new LinkedList<>();
for (final DyeColor d : stage.getSheepToShear()) {
colors.add(MiscUtil.getPrettyDyeColorName(d));
}
final LinkedList<Integer> amounts = new LinkedList<>(stage.getSheepNumToShear());
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts);
}
final LinkedList<Integer> amounts = new LinkedList<>(stage.getSheepNumToShear());
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts);
}
if (!stage.getPasswordDisplays().isEmpty()) {
context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, stage.getPasswordDisplays());
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, stage.getPasswordPhrases());
}
if (!stage.getCustomObjectives().isEmpty()) {
final LinkedList<String> list = new LinkedList<>();
final LinkedList<Integer> countList = new LinkedList<>();
for (int i = 0; i < stage.getCustomObjectives().size(); i++) {
list.add(stage.getCustomObjectives().get(i).getName());
countList.add(stage.getCustomObjectiveCounts().get(i));
if (!stage.getPasswordDisplays().isEmpty()) {
context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, stage.getPasswordDisplays());
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, stage.getPasswordPhrases());
}
final LinkedList<Entry<String, Object>> dataMapList = new LinkedList<>(stage.getCustomObjectiveData());
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, dataMapList);
}
if (stage.getStartAction() != null) {
context.setSessionData(pref + CK.S_START_EVENT, stage.getStartAction().getName());
}
if (stage.getFinishAction() != null) {
context.setSessionData(pref + CK.S_FINISH_EVENT, stage.getFinishAction().getName());
}
if (stage.getFailAction() != null) {
context.setSessionData(pref + CK.S_FAIL_EVENT, stage.getFailAction().getName());
}
if (stage.getDeathAction() != null) {
context.setSessionData(pref + CK.S_DEATH_EVENT, stage.getDeathAction().getName());
}
if (stage.getDisconnectAction() != null) {
context.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.getDisconnectAction().getName());
}
if (!stage.getChatActions().isEmpty()) {
final LinkedList<String> chatEvents = new LinkedList<>();
final LinkedList<String> chatEventTriggers = new LinkedList<>();
for (final String s : stage.getChatActions().keySet()) {
chatEventTriggers.add(s);
chatEvents.add(stage.getChatActions().get(s).getName());
if (!stage.getCustomObjectives().isEmpty()) {
final LinkedList<String> list = new LinkedList<>();
final LinkedList<Integer> countList = new LinkedList<>();
for (int i = 0; i < stage.getCustomObjectives().size(); i++) {
list.add(stage.getCustomObjectives().get(i).getName());
countList.add(stage.getCustomObjectiveCounts().get(i));
}
final LinkedList<Entry<String, Object>> dataMapList = new LinkedList<>(stage.getCustomObjectiveData());
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, dataMapList);
}
context.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents);
context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
}
if (!stage.getCommandActions().isEmpty()) {
final LinkedList<String> commandEvents = new LinkedList<>();
final LinkedList<String> commandEventTriggers = new LinkedList<>();
for (final String s : stage.getCommandActions().keySet()) {
commandEventTriggers.add(s);
commandEvents.add(stage.getCommandActions().get(s).getName());
if (stage.getStartAction() != null) {
context.setSessionData(pref + CK.S_START_EVENT, stage.getStartAction().getName());
}
context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
}
if (stage.getCondition() != null) {
context.setSessionData(pref + CK.S_CONDITION, stage.getCondition().getName());
}
if (stage.getDelay() != -1) {
context.setSessionData(pref + CK.S_DELAY, stage.getDelay());
if (stage.getDelayMessage() != null) {
context.setSessionData(pref + CK.S_DELAY_MESSAGE, stage.getDelayMessage());
if (stage.getFinishAction() != null) {
context.setSessionData(pref + CK.S_FINISH_EVENT, stage.getFinishAction().getName());
}
if (stage.getFailAction() != null) {
context.setSessionData(pref + CK.S_FAIL_EVENT, stage.getFailAction().getName());
}
if (stage.getDeathAction() != null) {
context.setSessionData(pref + CK.S_DEATH_EVENT, stage.getDeathAction().getName());
}
if (stage.getDisconnectAction() != null) {
context.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.getDisconnectAction().getName());
}
if (!stage.getChatActions().isEmpty()) {
final LinkedList<String> chatEvents = new LinkedList<>();
final LinkedList<String> chatEventTriggers = new LinkedList<>();
for (final String s : stage.getChatActions().keySet()) {
chatEventTriggers.add(s);
chatEvents.add(stage.getChatActions().get(s).getName());
}
context.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents);
context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
}
if (!stage.getCommandActions().isEmpty()) {
final LinkedList<String> commandEvents = new LinkedList<>();
final LinkedList<String> commandEventTriggers = new LinkedList<>();
for (final String s : stage.getCommandActions().keySet()) {
commandEventTriggers.add(s);
commandEvents.add(stage.getCommandActions().get(s).getName());
}
context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
}
if (stage.getCondition() != null) {
context.setSessionData(pref + CK.S_CONDITION, stage.getCondition().getName());
}
if (stage.getDelay() != -1) {
context.setSessionData(pref + CK.S_DELAY, stage.getDelay());
if (stage.getDelayMessage() != null) {
context.setSessionData(pref + CK.S_DELAY_MESSAGE, stage.getDelayMessage());
}
}
if (stage.getScript() != null) {
context.setSessionData(pref + CK.S_DENIZEN, stage.getScript());
}
if (stage.getCompleteMessage() != null) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.getCompleteMessage());
}
if (stage.getStartMessage() != null) {
context.setSessionData(pref + CK.S_START_MESSAGE, stage.getStartMessage());
}
if (!stage.getObjectiveOverrides().isEmpty()) {
context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.getObjectiveOverrides());
}
}
if (stage.getScript() != null) {
context.setSessionData(pref + CK.S_DENIZEN, stage.getScript());
}
if (stage.getCompleteMessage() != null) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.getCompleteMessage());
}
if (stage.getStartMessage() != null) {
context.setSessionData(pref + CK.S_START_MESSAGE, stage.getStartMessage());
}
if (!stage.getObjectiveOverrides().isEmpty()) {
context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.getObjectiveOverrides());
}
} catch (Exception e) {
e.printStackTrace();
}
}
@ -585,7 +598,7 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
? context.getSessionData(CK.Q_ASK_MESSAGE) : null);
section.set("finish-message", context.getSessionData(CK.Q_FINISH_MESSAGE) != null
? context.getSessionData(CK.Q_FINISH_MESSAGE) : null);
section.set("npc-giver-id", context.getSessionData(CK.Q_START_NPC) != null
section.set("npc-giver-uuid", context.getSessionData(CK.Q_START_NPC) != null
? context.getSessionData(CK.Q_START_NPC) : null);
section.set("block-start", context.getSessionData(CK.Q_START_BLOCK) != null
? ConfigUtil.getLocationInfo((Location) Objects.requireNonNull(context
@ -710,13 +723,13 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
? context.getSessionData(pref + CK.S_PLAYER_KILL) : null);
stage.set("items-to-deliver", context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null
? context.getSessionData(pref + CK.S_DELIVERY_ITEMS) : null);
stage.set("npc-delivery-ids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
stage.set("npc-delivery-uuids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
? context.getSessionData(pref + CK.S_DELIVERY_NPCS) : null);
stage.set("delivery-messages", context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null
? context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) : null);
stage.set("npc-ids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
stage.set("npc-uuids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
? context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : null);
stage.set("npc-ids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
stage.set("npc-uuids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
? context.getSessionData(pref + CK.S_NPCS_TO_KILL) : null);
stage.set("npc-kill-amounts", context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null
? context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) : null);

View File

@ -314,14 +314,24 @@ public class SeparatedYamlStorage implements StorageImplementation {
}
if (questSec.contains("has-talked-to")) {
final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to");
quester.getQuestData(quest).setCitizensInteracted(new LinkedList<>(talkAmount));
quester.getQuestData(quest).setNpcsInteracted(new LinkedList<>(talkAmount));
}
if (questSec.contains("citizen-amounts-killed")) {
final List<Integer> citizensAmounts = questSec.getIntegerList("citizen-amounts-killed");
if (questSec.contains("npc-killed-amounts")) {
final List<Integer> npcAmounts = questSec.getIntegerList("npc-killed-amounts");
int index = 0;
for (final int amt : citizensAmounts) {
if (quester.getQuestData(quest).getCitizensNumKilled().size() > 0) {
quester.getQuestData(quest).citizensNumKilled.set(index, amt);
for (final int amt : npcAmounts) {
if (quester.getQuestData(quest).getNpcsNumKilled().size() > 0) {
quester.getQuestData(quest).npcsNumKilled.set(index, amt);
}
index++;
}
} else if (questSec.contains("citizen-amounts-killed")) {
// Legacy
final List<Integer> npcAmounts = questSec.getIntegerList("citizen-amounts-killed");
int index = 0;
for (final int amt : npcAmounts) {
if (quester.getQuestData(quest).getNpcsNumKilled().size() > 0) {
quester.getQuestData(quest).npcsNumKilled.set(index, amt);
}
index++;
}

View File

@ -371,8 +371,8 @@ public class SqlStorage implements StorageImplementation {
ps.setString(11, serializeItemStackProgress(entry.getValue().getItemsBrewed()));
ps.setString(12, serializeItemStackProgress(entry.getValue().getItemsConsumed()));
ps.setString(13, serializeItemStackProgress(entry.getValue().getItemsDelivered()));
ps.setString(14, serializeProgress(entry.getValue().getCitizensInteracted()));
ps.setString(15, serializeProgress(entry.getValue().getCitizensNumKilled()));
ps.setString(14, serializeProgress(entry.getValue().getNpcsInteracted()));
ps.setString(15, serializeProgress(entry.getValue().getNpcsNumKilled()));
ps.setString(16, serializeProgress(entry.getValue().getMobNumKilled()));
ps.setString(17, serializeProgress(entry.getValue().getMobsTamed()));
ps.setInt(18, entry.getValue().getFishCaught());
@ -483,8 +483,8 @@ public class SqlStorage implements StorageImplementation {
quester.getCurrentStage(quest).getItemsToConsume()));
data.itemsDelivered.addAll(deserializeItemStackProgress(rs.getString("items_delivered"),
quester.getCurrentStage(quest).getItemsToDeliver()));
data.citizensInteracted.addAll(deserializeBooleanProgress(rs.getString("npcs_interacted")));
data.citizensNumKilled.addAll(deserializeIntProgress(rs.getString("npcs_killed")));
data.npcsInteracted.addAll(deserializeBooleanProgress(rs.getString("npcs_interacted")));
data.npcsNumKilled.addAll(deserializeIntProgress(rs.getString("npcs_killed")));
data.mobNumKilled.addAll(deserializeIntProgress(rs.getString("mobs_killed")));
data.mobsTamed.addAll(deserializeIntProgress(rs.getString("mobs_tamed")));
data.setFishCaught(rs.getInt("fish_caught"));

View File

@ -69,7 +69,8 @@ questEditorDefaultFinishMessage: "Well done!"
questEditorEnterQuestName: "Enter quest name, <cancel>"
questEditorEnterAskMessage: "Enter ask message, <cancel>"
questEditorEnterFinishMessage: "Enter finish message, <cancel>"
questEditorEnterNPCStart: "Enter NPC ID, <clear>, <cancel>"
questEditorEnterNPCStart: "Enter NPC UUID, <clear>, <cancel>"
questEditorClickNPCStart: "Click on a NPC, <clear>, <cancel>"
questEditorEnterBlockStart: "Right-click on a block to use as a start point, <done>, <clear>, <cancel>"
questDungeonsCreate: "Players added to this group may perform quests together!"
questDungeonsDisband: "The quest group was disbanded."
@ -167,7 +168,6 @@ stageEditorSetEnchantAmounts: "Set enchant amounts"
stageEditorSetMobAmounts: "Set mob amounts"
stageEditorSetEnchantments: "Set enchantments"
stageEditorSetItemNames: "Set item names"
stageEditorSetKillIds: "Set NPC IDs"
stageEditorSetMobTypes: "Set mob types"
stageEditorSetKillLocations: "Set kill locations"
stageEditorSetKillLocationRadii: "Set kill location radii"
@ -199,8 +199,6 @@ stageEditorKillPlayerPrompt: "Enter number of players to kill, <clear>, <cancel>
stageEditorEnchantTypePrompt: "Enter enchantment names, <space>, <cancel>"
stageEditorEnchantAmountsPrompt: "Enter enchant amounts (numbers), <space>, <cancel>"
stageEditorItemNamesPrompt: "Enter item names, <space>, <cancel>"
stageEditorNPCPrompt: "Enter NPC IDs, <space>, <cancel>"
stageEditorNPCToTalkToPrompt: "Enter NPC IDs, <space>, <clear>, <cancel>"
stageEditorDeliveryMessagesPrompt: "Enter delivery messages, <semicolon>, <cancel>"
stageEditorKillNPCsPrompt: "Enter kill amounts (numbers), <space>, <cancel>"
stageEditorMobsPrompt: "Enter mob names, <space>, <cancel>"
@ -227,12 +225,12 @@ stageEditorCompleteMessagePrompt: "Enter complete message, <clear>, <cancel>"
stageEditorPasswordDisplayPrompt: "Enter password hints, <semicolon>, <cancel>"
stageEditorPasswordPhrasePrompt: "Enter password phrases, <semicolon>, <cancel>"
stageEditorDeliveryAddItem: "Add item"
stageEditorDeliveryNPCs: "Set NPC IDs"
stageEditorNPCUniqueIds: "Add NPC UUIDs"
stageEditorDeliveryMessages: "Set partial delivery messages"
stageEditorNotSolid: "is not a solid block!"
stageEditorInvalidBlockName: "is not a valid block name!"
stageEditorInvalidEnchantment: "is not a valid enchantment name!"
stageEditorInvalidNPC: "is not a valid NPC ID!"
stageEditorInvalidNPC: "is not a valid NPC UUID!"
stageEditorInvalidMob: "is not a valid mob name!"
stageEditorInvalidItemName: "is not a valid item name!"
stageEditorInvalidDye: "is not a valid dye color!"
@ -243,7 +241,8 @@ stageEditorInvalidScript: "Denizen script not found!"
stageEditorNoCitizens: "Citizens is not installed!"
stageEditorNoDenizen: "Denizen is not installed!"
stageEditorPositiveAmount: "You must enter a positive number!"
stageEditorNotListofNumbers: "is not a list of numbers!"
stageEditorNotListOfNumbers: "<data> is not a list of numbers!"
stageEditorNotListOfUniqueIds: "<data> is not a list of valid UUIDs!"
stageEditorNoDelaySet: "You must set a delay first!"
stageEditorNoItems: "You must add items first!"
stageEditorNoDeliveryMessage: "You must set at least one delivery message!"
@ -404,7 +403,6 @@ conditionEditorRideNPC: "Ride NPC"
conditionEditorEntitiesTitle: "- Entities -"
conditionEditorEntitiesPrompt: "Enter entity names, <space>, <cancel>"
conditionEditorNpcsTitle: "- NPCs -"
conditionEditorNpcsPrompt: "Enter NPC IDs, <space>, <cancel>"
conditionEditorPermissions: "Own permission"
conditionEditorPermissionsPrompt: "Enter permission nodes, <space>, <cancel>"
conditionEditorItemsInMainHand: "Hold in main hand"
@ -467,6 +465,7 @@ reqHeroesNotSecondary: "The <class> class is not secondary!"
reqHeroesSecondaryCleared: "Heroes Secondary Class requirement cleared."
reqHeroesClassNotFound: "Class not found!"
reqNotANumber: "<input> is not a number!"
reqNotAUniqueId: "<input> is not a valid UUID!"
reqMustAddItem: "You must add at least one item first!"
reqNoMessage: "You must set a fail requirements message!"
plnStart: "Set start date"
@ -774,7 +773,8 @@ noIdsSet: "No IDs set"
noNamesSet: "No names set"
worlds: "Worlds"
points: "points"
npcHint: "Note: You can click on NPCs to get their ID."
enterNpcUniqueIds: "Enter NPC UUIDs, <space>, <cancel>"
enterOrClearNpcUniqueIds: "Enter NPC UUIDs, <space>, <clear>, <cancel>"
listsNotSameSize: "All required lists must have the same number of entries!"
listDuplicate: "List contains duplicates!"
id: "ID"

2
dist/pom.xml vendored
View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<artifactId>quests-dist</artifactId>
<packaging>pom</packaging>

View File

@ -6,12 +6,12 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
<name>quests</name>
<url>https://github.com/PikaMug/Quests/</url>
<properties>
<revision>4.3.1</revision>
<revision>4.4.0</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<properties>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<properties>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<properties>