Resolve kill objectives not incrementing, fixes #1792

This commit is contained in:
PikaMug 2021-09-23 23:56:53 -04:00
parent a078973df2
commit 8e77e625ca
3 changed files with 20 additions and 191 deletions

View File

@ -577,73 +577,6 @@ public class QuestData {
} }
}; };
public LinkedList<Integer> citizensIdsKilled = new LinkedList<Integer>() {
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<? extends Integer> c) {
final boolean b = super.addAll(c);
if (doJournalUpdate)
quester.updateJournal();
return b;
}
@Override
public boolean addAll(final int index, final Collection<? extends Integer> 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<Integer> citizensNumKilled = new LinkedList<Integer>() { public LinkedList<Integer> citizensNumKilled = new LinkedList<Integer>() {
private static final long serialVersionUID = 1849192351499071688L; private static final long serialVersionUID = 1849192351499071688L;
@ -711,73 +644,6 @@ public class QuestData {
} }
}; };
public LinkedList<EntityType> mobTypesKilled = new LinkedList<EntityType>() {
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<? extends EntityType> c) {
final boolean b = super.addAll(c);
if (doJournalUpdate)
quester.updateJournal();
return b;
}
@Override
public boolean addAll(final int index, final Collection<? extends EntityType> 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<Integer> mobNumKilled = new LinkedList<Integer>() { public LinkedList<Integer> mobNumKilled = new LinkedList<Integer>() {
private static final long serialVersionUID = 2228385647091499176L; private static final long serialVersionUID = 2228385647091499176L;
@ -1322,17 +1188,6 @@ public class QuestData {
} }
} }
public LinkedList<Integer> getCitizensIdsKilled() {
return citizensIdsKilled;
}
public void setCitizensIdsKilled(final LinkedList<Integer> citizensIdsKilled) {
this.citizensIdsKilled = citizensIdsKilled;
if (doJournalUpdate) {
quester.updateJournal();
}
}
public LinkedList<Integer> getCitizensNumKilled() { public LinkedList<Integer> getCitizensNumKilled() {
return citizensNumKilled; return citizensNumKilled;
} }
@ -1344,17 +1199,6 @@ public class QuestData {
} }
} }
public LinkedList<EntityType> getMobTypesKilled() {
return mobTypesKilled;
}
public void setMobTypesKilled(final LinkedList<EntityType> mobTypesKilled) {
this.mobTypesKilled = mobTypesKilled;
if (doJournalUpdate) {
quester.updateJournal();
}
}
public LinkedList<Integer> getMobNumKilled() { public LinkedList<Integer> getMobNumKilled() {
return mobNumKilled; return mobNumKilled;
} }

View File

@ -2239,11 +2239,11 @@ public class Quester implements Comparable<Quester> {
* @param npc The NPC being killed * @param npc The NPC being killed
*/ */
public void killNPC(final Quest quest, final NPC npc) { public void killNPC(final Quest quest, final NPC npc) {
if (!getQuestData(quest).citizensIdsKilled.contains(npc.getId())) { if (!getCurrentStage(quest).getCitizensToKill().contains(npc.getId())) {
return; 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 npcsKilled = getQuestData(quest).citizensNumKilled.get(index);
final int npcsToKill = getCurrentStage(quest).citizenNumToKill.get(index); final int npcsToKill = getCurrentStage(quest).citizenNumToKill.get(index);
@ -2389,8 +2389,7 @@ public class Quester implements Comparable<Quester> {
if (currentStage.mobsToKill == null) { if (currentStage.mobsToKill == null) {
return; return;
} }
final int index = currentStage.getMobsToKill().indexOf(entityType);
final int index = questData.mobTypesKilled.indexOf(entityType);
if (index == -1) { if (index == -1) {
return; return;
} }
@ -2418,7 +2417,6 @@ public class Quester implements Comparable<Quester> {
return; return;
} }
} }
final ObjectiveType type = ObjectiveType.KILL_MOB; final ObjectiveType type = ObjectiveType.KILL_MOB;
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest, final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
new Objective(type, mobsKilled, mobsToKill)); new Objective(type, mobsKilled, mobsToKill));
@ -3286,13 +3284,11 @@ public class Quester implements Comparable<Quester> {
} }
if (!quest.getStage(stage).citizensToKill.isEmpty()) { if (!quest.getStage(stage).citizensToKill.isEmpty()) {
for (final Integer toKill : quest.getStage(stage).citizensToKill) { for (final Integer toKill : quest.getStage(stage).citizensToKill) {
data.citizensIdsKilled.add(toKill);
data.citizensNumKilled.add(0); data.citizensNumKilled.add(0);
} }
} }
if (!quest.getStage(stage).mobsToKill.isEmpty()) { if (!quest.getStage(stage).mobsToKill.isEmpty()) {
for (final EntityType toKill : quest.getStage(stage).mobsToKill) { for (final EntityType toKill : quest.getStage(stage).mobsToKill) {
data.mobTypesKilled.add(toKill);
data.mobNumKilled.add(0); data.mobNumKilled.add(0);
} }
} }
@ -3487,15 +3483,10 @@ public class Quester implements Comparable<Quester> {
if (!questData.citizensInteracted.isEmpty()) { if (!questData.citizensInteracted.isEmpty()) {
questSec.set("has-talked-to", questData.citizensInteracted); questSec.set("has-talked-to", questData.citizensInteracted);
} }
if (!questData.citizensIdsKilled.isEmpty()) { if (!questData.citizensNumKilled.isEmpty()) {
questSec.set("citizen-amounts-killed", questData.citizensNumKilled); questSec.set("citizen-amounts-killed", questData.citizensNumKilled);
} }
if (!questData.mobTypesKilled.isEmpty()) { if (!questData.mobNumKilled.isEmpty()) {
final LinkedList<String> mobNames = new LinkedList<>();
for (final EntityType e : questData.mobTypesKilled) {
mobNames.add(MiscUtil.getPrettyMobName(e));
}
questSec.set("mobs-killed", mobNames);
questSec.set("mobs-killed-amounts", questData.mobNumKilled); questSec.set("mobs-killed-amounts", questData.mobNumKilled);
} }
if (!questData.mobsTamed.isEmpty()) { if (!questData.mobsTamed.isEmpty()) {

View File

@ -320,14 +320,14 @@ public class SeparatedYamlStorage implements StorageImplementation {
final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to"); final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to");
quester.getQuestData(quest).setCitizensInteracted(new LinkedList<>(talkAmount)); quester.getQuestData(quest).setCitizensInteracted(new LinkedList<>(talkAmount));
} }
if (questSec.contains("citizen-ids-killed")) { if (questSec.contains("citizen-amounts-killed")) {
final List<Integer> ids = questSec.getIntegerList("citizen-ids-killed"); final List<Integer> citizensAmounts = questSec.getIntegerList("citizen-amounts-killed");
final List<Integer> num = questSec.getIntegerList("citizen-amounts-killed"); int index = 0;
quester.getQuestData(quest).citizensIdsKilled.clear(); for (final int amt : citizensAmounts) {
quester.getQuestData(quest).citizensNumKilled.clear(); if (quester.getQuestData(quest).getCitizensNumKilled().size() > 0) {
for (final int i : ids) { quester.getQuestData(quest).citizensNumKilled.set(index, amt);
quester.getQuestData(quest).citizensIdsKilled.add(i); }
quester.getQuestData(quest).citizensNumKilled.add(num.get(ids.indexOf(i))); index++;
} }
} }
if (questSec.contains("cows-milked")) { if (questSec.contains("cows-milked")) {
@ -339,20 +339,14 @@ public class SeparatedYamlStorage implements StorageImplementation {
if (questSec.contains("players-killed")) { if (questSec.contains("players-killed")) {
quester.getQuestData(quest).setPlayersKilled(questSec.getInt("players-killed")); quester.getQuestData(quest).setPlayersKilled(questSec.getInt("players-killed"));
} }
if (questSec.contains("mobs-killed")) { if (questSec.contains("mobs-killed-amounts")) {
final LinkedList<EntityType> mobs = new LinkedList<>(); final List<Integer> mobAmounts = questSec.getIntegerList("mobs-killed-amounts");
final List<Integer> amounts = questSec.getIntegerList("mobs-killed-amounts"); int index = 0;
for (final String s : questSec.getStringList("mobs-killed")) { for (final int amt : mobAmounts) {
final EntityType mob = MiscUtil.getProperMobType(s); if (quester.getQuestData(quest).getMobNumKilled().size() > 0) {
if (mob != null) { quester.getQuestData(quest).mobNumKilled.set(index, amt);
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)));
} }
index++;
} }
} }
if (questSec.contains("locations-to-reach")) { if (questSec.contains("locations-to-reach")) {