Avoid constant out of range exceptions when a players' current quest/stages lists get out of sync. Not sure why this happens, though.

This commit is contained in:
Nathan Wolf 2015-12-14 17:15:54 -08:00
parent 322c2d908a
commit 23304e0b1d

View File

@ -2578,7 +2578,10 @@ public class Quester {
List<String> questNames = data.getStringList("currentQuests"); List<String> questNames = data.getStringList("currentQuests");
List<Integer> questStages = data.getIntegerList("currentStages"); List<Integer> questStages = data.getIntegerList("currentStages");
for (int i = 0; i < questNames.size(); i++) { // These appear to differ sometimes? That seems bad.
int maxSize = Math.min(questNames.size(), questStages.size());
for (int i = 0; i < maxSize; i++) {
if (plugin.getQuest(questNames.get(i)) != null) { if (plugin.getQuest(questNames.get(i)) != null) {
currentQuests.put(plugin.getQuest(questNames.get(i)), questStages.get(i)); currentQuests.put(plugin.getQuest(questNames.get(i)), questStages.get(i));
} }