Workaround for missing hasReached data, fixes #825

This commit is contained in:
PikaMug 2019-06-12 14:35:23 -04:00
parent 378d822ec1
commit aae80e8903

View File

@ -1614,27 +1614,32 @@ public class Quester {
if (getQuestData(quest).locationsReached.isEmpty()) { if (getQuestData(quest).locationsReached.isEmpty()) {
return; return;
} }
int index = 0;
for (Location location : getQuestData(quest).locationsReached) { for (Location location : getQuestData(quest).locationsReached) {
try { try {
int index = getQuestData(quest).locationsReached.indexOf(location);
Location locationToReach = getCurrentStage(quest).locationsToReach.get(index); Location locationToReach = getCurrentStage(quest).locationsToReach.get(index);
double radius = getQuestData(quest).radiiToReachWithin.get(index); double radius = getQuestData(quest).radiiToReachWithin.get(index);
if (l.getX() < (locationToReach.getX() + radius) && l.getX() > (locationToReach.getX() - radius)) { if (l.getX() < (locationToReach.getX() + radius) && l.getX() > (locationToReach.getX() - radius)) {
if (l.getZ() < (locationToReach.getZ() + radius) && l.getZ() > (locationToReach.getZ() - radius)) { if (l.getZ() < (locationToReach.getZ() + radius) && l.getZ() > (locationToReach.getZ() - radius)) {
if (l.getY() < (locationToReach.getY() + radius) && l.getY() > (locationToReach.getY() - radius)) { if (l.getY() < (locationToReach.getY() + radius) && l.getY() > (locationToReach.getY() - radius)) {
if (l.getWorld().getName().equals(locationToReach.getWorld().getName())) { if (l.getWorld().getName().equals(locationToReach.getWorld().getName())) {
if (getQuestData(quest).hasReached.get(index) == false) { // TODO - Find proper cause of Github issues #646 and #825
if (index >= getQuestData(quest).hasReached.size()) {
getQuestData(quest).hasReached.add(true);
} else {
getQuestData(quest).hasReached.set(index, true); getQuestData(quest).hasReached.set(index, true);
finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null);
} }
finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null);
} }
} }
} }
} }
index++;
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below"); plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below");
plugin.getLogger().severe("index = " + getQuestData(quest).locationsReached.indexOf(location)); plugin.getLogger().warning("index = " + index);
plugin.getLogger().severe("locationsReached = " + getQuestData(quest).locationsReached.toString()); plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.toString());
plugin.getLogger().warning("hasReached = " + getQuestData(quest).hasReached.size());
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -2731,7 +2736,7 @@ public class Quester {
LinkedList<Location> locations = new LinkedList<Location>(); LinkedList<Location> locations = new LinkedList<Location>();
List<Boolean> has = questSec.getBooleanList("has-reached-location"); List<Boolean> has = questSec.getBooleanList("has-reached-location");
while (has.size() < locations.size()) { while (has.size() < locations.size()) {
// TODO - find proper cause of Github issue #646 // TODO - Find proper cause of Github issues #646 and #825
plugin.getLogger().info("Added missing has-reached-location data for Quester " + id); plugin.getLogger().info("Added missing has-reached-location data for Quester " + id);
has.add(false); has.add(false);
} }