Check if a sub-quest's data exists before invoking it

This commit is contained in:
KingRainbow44 2023-04-29 20:40:33 -04:00
parent 9bbdc11334
commit b77c75a296
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -78,8 +78,16 @@ public class GameMainQuest {
Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()) Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests())
.map(SubQuestData::getSubId) .map(SubQuestData::getSubId)
.toList(); .toList();
for (Integer subQuestId : subQuestIds) { for (var subQuestId : subQuestIds) {
QuestData questConfig = GameData.getQuestDataMap().get(subQuestId); QuestData questConfig = GameData.getQuestDataMap().get((int) subQuestId);
if (questConfig == null) {
Grasscutter.getLogger()
.error(
"Quest {} not found in QuestData. Please check MainQuestData and QuestData.",
subQuestId);
continue;
}
this.childQuests.put(subQuestId, new GameQuest(this, questConfig)); this.childQuests.put(subQuestId, new GameQuest(this, questConfig));
} }
} }