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>() {
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>() {
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() {
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() {
return mobNumKilled;
}

View File

@ -2239,11 +2239,11 @@ public class Quester implements Comparable<Quester> {
* @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<Quester> {
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<Quester> {
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<Quester> {
}
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<Quester> {
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<String> 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()) {

View File

@ -320,14 +320,14 @@ public class SeparatedYamlStorage implements StorageImplementation {
final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to");
quester.getQuestData(quest).setCitizensInteracted(new LinkedList<>(talkAmount));
}
if (questSec.contains("citizen-ids-killed")) {
final List<Integer> ids = questSec.getIntegerList("citizen-ids-killed");
final List<Integer> 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<Integer> 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<EntityType> mobs = new LinkedList<>();
final List<Integer> 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<Integer> 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")) {