Apply additional data from specific main quest lines

This commit is contained in:
KingRainbow44
2023-04-24 01:44:58 -04:00
parent 0d680a6310
commit 1a8d7e901a
4 changed files with 258 additions and 243 deletions

View File

@@ -489,17 +489,15 @@ public final class ResourceLoader {
}
private static void loadQuests() {
try {
Files.list(getResourcePath("BinOutput/Quest/"))
.forEach(
path -> {
try {
val mainQuest = JsonUtils.loadToClass(path, MainQuestData.class);
GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest);
} catch (IOException e) {
try (var files = Files.list(getResourcePath("BinOutput/Quest/"))) {
files.forEach(path -> {
try {
val mainQuest = JsonUtils.loadToClass(path, MainQuestData.class);
GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest);
}
});
mainQuest.onLoad(); // Load the quest data.
} catch (IOException ignored) { }
});
} catch (IOException e) {
Grasscutter.getLogger().error("Quest data missing");
return;
@@ -507,17 +505,19 @@ public final class ResourceLoader {
try {
val questEncryptionMap = GameData.getMainQuestEncryptionMap();
String path = "QuestEncryptionKeys.json";
var path = "QuestEncryptionKeys.json";
try {
JsonUtils.loadToList(getResourcePath(path), QuestEncryptionKey.class)
.forEach(key -> questEncryptionMap.put(key.getMainQuestId(), key));
} catch (IOException | NullPointerException ignored) {
}
try {
DataLoader.loadList(path, QuestEncryptionKey.class)
.forEach(key -> questEncryptionMap.put(key.getMainQuestId(), key));
} catch (IOException | NullPointerException ignored) {
}
Grasscutter.getLogger().debug("Loaded {} quest keys.", questEncryptionMap.size());
} catch (Exception e) {
Grasscutter.getLogger().error("Unable to load quest keys.", e);