Skip to content

Commit

Permalink
Fix QuestEncryptionKeys Path (Grasscutters#1696)
Browse files Browse the repository at this point in the history
* Fix QuestEncryptionKeys Path

* Load resources QuestEncryptionKeys
  • Loading branch information
omg-xtao committed Aug 23, 2022
1 parent 1dd84d6 commit 5db73d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/emu/grasscutter/data/DataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static void checkAndCopyData(String name) {

if (!Utils.fileExists(filePath)) {
// Check if file is in subdirectory
if (name.indexOf("/") != -1) {
if (name.contains("/")) {
String[] path = name.split("/");

String folder = "";
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/emu/grasscutter/data/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,18 @@ private static void loadQuests() {
}

try {
List<QuestEncryptionKey> keys = DataLoader.loadList("QuestEncryptionKeys.json", QuestEncryptionKey.class);

List<QuestEncryptionKey> keys;
Int2ObjectMap<QuestEncryptionKey> questEncryptionMap = GameData.getMainQuestEncryptionMap();
keys.forEach(key -> questEncryptionMap.put(key.getMainQuestId(), key));
String path = "QuestEncryptionKeys.json";
if (Utils.fileExists(RESOURCE(path))) {
keys = JsonUtils.loadToList(RESOURCE(path), QuestEncryptionKey.class);
keys.forEach(key -> questEncryptionMap.put(key.getMainQuestId(), key));
}
if (Utils.fileExists(DATA(path))) {
keys = DataLoader.loadList(path, QuestEncryptionKey.class);
keys.forEach(key -> questEncryptionMap.put(key.getMainQuestId(), key));
}
Grasscutter.getLogger().debug("Loaded {} quest keys.", questEncryptionMap.size());
} catch (FileNotFoundException | NullPointerException ignored) {
Grasscutter.getLogger().warn("Unable to load quest keys - ./resources/QuestEncryptionKeys.json not found.");
} catch (Exception e) {
Grasscutter.getLogger().error("Unable to load quest keys.", e);
}
Expand Down

0 comments on commit 5db73d2

Please sign in to comment.