diff --git a/main/src/main/java/me/blackvein/quests/QuestData.java b/main/src/main/java/me/blackvein/quests/QuestData.java index fc460c318..ae9d4face 100644 --- a/main/src/main/java/me/blackvein/quests/QuestData.java +++ b/main/src/main/java/me/blackvein/quests/QuestData.java @@ -577,73 +577,6 @@ public class QuestData { } }; - public LinkedList citizensIdsKilled = new LinkedList() { - - private static final long serialVersionUID = -6054581494356961482L; - - @Override - public boolean add(final Integer e) { - final boolean b = super.add(e); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public void add(final int index, final Integer element) { - super.add(index, element); - if (doJournalUpdate) - quester.updateJournal(); - } - - @Override - public boolean addAll(final Collection c) { - final boolean b = super.addAll(c); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public boolean addAll(final int index, final Collection c) { - final boolean b = super.addAll(index, c); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public void clear() { - super.clear(); - if (doJournalUpdate) - quester.updateJournal(); - } - - @Override - public boolean remove(final Object o) { - final boolean b = super.remove(o); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public Integer remove(final int index) { - final Integer s = super.remove(index); - if (doJournalUpdate) - quester.updateJournal(); - return s; - } - - @Override - public Integer set(final int index, final Integer element) { - final Integer s = super.set(index, element); - if (doJournalUpdate) - quester.updateJournal(); - return s; - } - }; - public LinkedList citizensNumKilled = new LinkedList() { private static final long serialVersionUID = 1849192351499071688L; @@ -711,73 +644,6 @@ public class QuestData { } }; - public LinkedList mobTypesKilled = new LinkedList() { - - private static final long serialVersionUID = 8178007458817522183L; - - @Override - public boolean add(final EntityType e) { - final boolean b = super.add(e); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public void add(final int index, final EntityType element) { - super.add(index, element); - if (doJournalUpdate) - quester.updateJournal(); - } - - @Override - public boolean addAll(final Collection c) { - final boolean b = super.addAll(c); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public boolean addAll(final int index, final Collection c) { - final boolean b = super.addAll(index, c); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public void clear() { - super.clear(); - if (doJournalUpdate) - quester.updateJournal(); - } - - @Override - public boolean remove(final Object o) { - final boolean b = super.remove(o); - if (doJournalUpdate) - quester.updateJournal(); - return b; - } - - @Override - public EntityType remove(final int index) { - final EntityType s = super.remove(index); - if (doJournalUpdate) - quester.updateJournal(); - return s; - } - - @Override - public EntityType set(final int index, final EntityType element) { - final EntityType s = super.set(index, element); - if (doJournalUpdate) - quester.updateJournal(); - return s; - } - }; - public LinkedList mobNumKilled = new LinkedList() { private static final long serialVersionUID = 2228385647091499176L; @@ -1322,17 +1188,6 @@ public class QuestData { } } - public LinkedList getCitizensIdsKilled() { - return citizensIdsKilled; - } - - public void setCitizensIdsKilled(final LinkedList citizensIdsKilled) { - this.citizensIdsKilled = citizensIdsKilled; - if (doJournalUpdate) { - quester.updateJournal(); - } - } - public LinkedList getCitizensNumKilled() { return citizensNumKilled; } @@ -1344,17 +1199,6 @@ public class QuestData { } } - public LinkedList getMobTypesKilled() { - return mobTypesKilled; - } - - public void setMobTypesKilled(final LinkedList mobTypesKilled) { - this.mobTypesKilled = mobTypesKilled; - if (doJournalUpdate) { - quester.updateJournal(); - } - } - public LinkedList getMobNumKilled() { return mobNumKilled; } diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index dc7af1f33..c501b79a7 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -2239,11 +2239,11 @@ public class Quester implements Comparable { * @param npc The NPC being killed */ public void killNPC(final Quest quest, final NPC npc) { - if (!getQuestData(quest).citizensIdsKilled.contains(npc.getId())) { + if (!getCurrentStage(quest).getCitizensToKill().contains(npc.getId())) { return; } - final int index = getQuestData(quest).citizensIdsKilled.indexOf(npc.getId()); + final int index = getCurrentStage(quest).getCitizensToKill().indexOf(npc.getId()); final int npcsKilled = getQuestData(quest).citizensNumKilled.get(index); final int npcsToKill = getCurrentStage(quest).citizenNumToKill.get(index); @@ -2389,8 +2389,7 @@ public class Quester implements Comparable { if (currentStage.mobsToKill == null) { return; } - - final int index = questData.mobTypesKilled.indexOf(entityType); + final int index = currentStage.getMobsToKill().indexOf(entityType); if (index == -1) { return; } @@ -2418,7 +2417,6 @@ public class Quester implements Comparable { return; } } - final ObjectiveType type = ObjectiveType.KILL_MOB; final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest, new Objective(type, mobsKilled, mobsToKill)); @@ -3286,13 +3284,11 @@ public class Quester implements Comparable { } if (!quest.getStage(stage).citizensToKill.isEmpty()) { for (final Integer toKill : quest.getStage(stage).citizensToKill) { - data.citizensIdsKilled.add(toKill); data.citizensNumKilled.add(0); } } if (!quest.getStage(stage).mobsToKill.isEmpty()) { for (final EntityType toKill : quest.getStage(stage).mobsToKill) { - data.mobTypesKilled.add(toKill); data.mobNumKilled.add(0); } } @@ -3487,15 +3483,10 @@ public class Quester implements Comparable { if (!questData.citizensInteracted.isEmpty()) { questSec.set("has-talked-to", questData.citizensInteracted); } - if (!questData.citizensIdsKilled.isEmpty()) { + if (!questData.citizensNumKilled.isEmpty()) { questSec.set("citizen-amounts-killed", questData.citizensNumKilled); } - if (!questData.mobTypesKilled.isEmpty()) { - final LinkedList mobNames = new LinkedList<>(); - for (final EntityType e : questData.mobTypesKilled) { - mobNames.add(MiscUtil.getPrettyMobName(e)); - } - questSec.set("mobs-killed", mobNames); + if (!questData.mobNumKilled.isEmpty()) { questSec.set("mobs-killed-amounts", questData.mobNumKilled); } if (!questData.mobsTamed.isEmpty()) { diff --git a/main/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java b/main/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java index 95cb7d7a9..e9cd4228f 100644 --- a/main/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java +++ b/main/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java @@ -320,14 +320,14 @@ public class SeparatedYamlStorage implements StorageImplementation { final List talkAmount = questSec.getBooleanList("has-talked-to"); quester.getQuestData(quest).setCitizensInteracted(new LinkedList<>(talkAmount)); } - if (questSec.contains("citizen-ids-killed")) { - final List ids = questSec.getIntegerList("citizen-ids-killed"); - final List num = questSec.getIntegerList("citizen-amounts-killed"); - quester.getQuestData(quest).citizensIdsKilled.clear(); - quester.getQuestData(quest).citizensNumKilled.clear(); - for (final int i : ids) { - quester.getQuestData(quest).citizensIdsKilled.add(i); - quester.getQuestData(quest).citizensNumKilled.add(num.get(ids.indexOf(i))); + if (questSec.contains("citizen-amounts-killed")) { + final List citizensAmounts = questSec.getIntegerList("citizen-amounts-killed"); + int index = 0; + for (final int amt : citizensAmounts) { + if (quester.getQuestData(quest).getCitizensNumKilled().size() > 0) { + quester.getQuestData(quest).citizensNumKilled.set(index, amt); + } + index++; } } if (questSec.contains("cows-milked")) { @@ -339,20 +339,14 @@ public class SeparatedYamlStorage implements StorageImplementation { if (questSec.contains("players-killed")) { quester.getQuestData(quest).setPlayersKilled(questSec.getInt("players-killed")); } - if (questSec.contains("mobs-killed")) { - final LinkedList mobs = new LinkedList<>(); - final List amounts = questSec.getIntegerList("mobs-killed-amounts"); - for (final String s : questSec.getStringList("mobs-killed")) { - final EntityType mob = MiscUtil.getProperMobType(s); - if (mob != null) { - mobs.add(mob); - } - quester.getQuestData(quest).mobTypesKilled.clear(); - quester.getQuestData(quest).mobNumKilled.clear(); - for (final EntityType e : mobs) { - quester.getQuestData(quest).mobTypesKilled.add(e); - quester.getQuestData(quest).mobNumKilled.add(amounts.get(mobs.indexOf(e))); + if (questSec.contains("mobs-killed-amounts")) { + final List mobAmounts = questSec.getIntegerList("mobs-killed-amounts"); + int index = 0; + for (final int amt : mobAmounts) { + if (quester.getQuestData(quest).getMobNumKilled().size() > 0) { + quester.getQuestData(quest).mobNumKilled.set(index, amt); } + index++; } } if (questSec.contains("locations-to-reach")) {