Fix delivering same item to diff NPCs in a single stage, fixes #85

This commit is contained in:
HappyPikachu 2017-07-29 13:28:32 -04:00
parent bf3bcf0588
commit c51fd3394f
2 changed files with 12 additions and 8 deletions

View File

@ -495,10 +495,12 @@ public class Quester {
finishedObjectives.add(ChatColor.GRAY + Lang.get("killPlayer") + ChatColor.GRAY + ": " + getQuestData(quest).getPlayersKilled() + "/" + getCurrentStage(quest).playersToKill);
}
}
int index2 = 0;
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
int delivered = getQuestData(quest).itemsDelivered.get(is);
int amt = is.getAmount();
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is));
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(index2);
index2++;
if (delivered < amt) {
String obj = Lang.get("deliver");
obj = obj.replaceAll("<item>", ItemUtil.getName(is));
@ -2203,18 +2205,18 @@ public class Quester {
public static ConfigurationSection getLegacyQuestData(FileConfiguration questSec, String questName) {
ConfigurationSection newData = questSec.createSection("questData");
if (questSec.contains("blocks-damaged-names")) {
List<String> names = questSec.getStringList("blocks-damaged-names");
List<Integer> amounts = questSec.getIntegerList("blocks-damaged-amounts");
newData.set(questName + ".blocks-damaged-names", names);
newData.set(questName + ".blocks-damaged-amounts", amounts);
}
if (questSec.contains("blocks-broken-names")) {
List<String> names = questSec.getStringList("blocks-broken-names");
List<Integer> amounts = questSec.getIntegerList("blocks-broken-amounts");
newData.set(questName + ".blocks-broken-names", names);
newData.set(questName + ".blocks-broken-amounts", amounts);
}
if (questSec.contains("blocks-damaged-names")) {
List<String> names = questSec.getStringList("blocks-damaged-names");
List<Integer> amounts = questSec.getIntegerList("blocks-damaged-amounts");
newData.set(questName + ".blocks-damaged-names", names);
newData.set(questName + ".blocks-damaged-amounts", amounts);
}
if (questSec.contains("blocks-placed-names")) {
List<String> names = questSec.getStringList("blocks-placed-names");
List<Integer> amounts = questSec.getIntegerList("blocks-placed-amounts");

View File

@ -2780,10 +2780,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
itemsToDeliver = config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".items-to-deliver");
itemDeliveryTargetIds = config.getIntegerList("quests." + questName + ".stages.ordered." + s2 + ".npc-delivery-ids");
deliveryMessages.addAll(config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".delivery-messages"));
int index = 0;
for (String item : itemsToDeliver) {
ItemStack is = ItemUtil.readItemStack("" + item);
int npcId = itemDeliveryTargetIds.get(index);
index++;
if (is != null) {
int npcId = itemDeliveryTargetIds.get(itemsToDeliver.indexOf(item));
NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
if (npc != null) {
oStage.itemsToDeliver.add(is);