mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 08:42:53 +08:00
Apply additional data from specific main quest lines
This commit is contained in:
parent
0d680a6310
commit
1a8d7e901a
@ -83,7 +83,7 @@ public class DataLoader {
|
||||
}
|
||||
|
||||
public static <T> List<T> loadList(String resourcePath, Class<T> classType) throws IOException {
|
||||
try (InputStreamReader reader = loadReader(resourcePath)) {
|
||||
try (var reader = loadReader(resourcePath)) {
|
||||
return JsonUtils.loadToList(reader, classType);
|
||||
}
|
||||
}
|
||||
|
@ -489,16 +489,14 @@ public final class ResourceLoader {
|
||||
}
|
||||
|
||||
private static void loadQuests() {
|
||||
try {
|
||||
Files.list(getResourcePath("BinOutput/Quest/"))
|
||||
.forEach(
|
||||
path -> {
|
||||
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);
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
mainQuest.onLoad(); // Load the quest data.
|
||||
} catch (IOException ignored) { }
|
||||
});
|
||||
} catch (IOException e) {
|
||||
Grasscutter.getLogger().error("Quest data missing");
|
||||
@ -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);
|
||||
|
@ -1,7 +1,10 @@
|
||||
package emu.grasscutter.data.binout;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.game.quest.enums.QuestType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
@ -54,12 +57,18 @@ public class MainQuestData {
|
||||
|
||||
public void onLoad() {
|
||||
this.talks = talks.stream().filter(Objects::nonNull).toList();
|
||||
Arrays.stream(this.subQuests).forEach(quest -> {
|
||||
var questData = GameData.getQuestDataMap().get(quest.getSubId());
|
||||
if (questData != null) questData.applyFrom(quest);
|
||||
});
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SubQuestData {
|
||||
private int subId;
|
||||
private int order;
|
||||
private boolean isRewind;
|
||||
private boolean finishParent;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -5,6 +5,7 @@ import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.game.quest.enums.*;
|
||||
import java.util.ArrayList;
|
||||
@ -69,7 +70,12 @@ public class QuestData extends GameResource {
|
||||
|
||||
if (this.gainItems == null) this.gainItems = Collections.emptyList();
|
||||
|
||||
addToCache();
|
||||
this.addToCache();
|
||||
}
|
||||
|
||||
public void applyFrom(MainQuestData.SubQuestData additionalData) {
|
||||
this.isRewind = additionalData.isRewind();
|
||||
this.finishParent = additionalData.isFinishParent();
|
||||
}
|
||||
|
||||
private void addToCache() {
|
||||
|
Loading…
Reference in New Issue
Block a user