diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index 2b40818e1..75b840202 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -12,7 +12,7 @@ import emu.grasscutter.data.custom.AbilityEmbryoEntry; import emu.grasscutter.data.custom.AbilityModifier; import emu.grasscutter.data.custom.AbilityModifierEntry; import emu.grasscutter.data.custom.OpenConfigEntry; -import emu.grasscutter.data.custom.QuestConfig; +import emu.grasscutter.data.custom.MainQuestData; import emu.grasscutter.data.custom.ScenePointEntry; import emu.grasscutter.data.def.*; import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; @@ -28,7 +28,7 @@ public class GameData { private static final Map abilityModifiers = new HashMap<>(); private static final Map openConfigEntries = new HashMap<>(); private static final Map scenePointEntries = new HashMap<>(); - private static final Int2ObjectMap questConfigs = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap mainQuestData = new Int2ObjectOpenHashMap<>(); // ExcelConfigs private static final Int2ObjectMap playerLevelDataMap = new Int2ObjectOpenHashMap<>(); @@ -70,6 +70,7 @@ public class GameData { private static final Int2ObjectMap worldLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dailyDungeonDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dungeonDataMap = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap questDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap shopGoodsDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap combineDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap rewardPreviewDataMap = new Int2ObjectOpenHashMap<>(); @@ -124,8 +125,8 @@ public class GameData { return getScenePointEntries().get(sceneId + "_" + pointId); } - public static Int2ObjectMap getQuestConfigs() { - return questConfigs; + public static Int2ObjectMap getMainQuestDataMap() { + return mainQuestData; } public static Int2ObjectMap getAvatarDataMap() { @@ -337,4 +338,8 @@ public class GameData { public static Int2ObjectMap getTowerScheduleDataMap(){ return towerScheduleDataMap; } + + public static Int2ObjectMap getQuestDataMap() { + return questDataMap; + } } diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 5c2ac1ee6..4b940c44d 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -24,9 +24,7 @@ import emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction; import emu.grasscutter.data.custom.AbilityModifier.AbilityModifierActionType; import emu.grasscutter.data.custom.AbilityModifierEntry; import emu.grasscutter.data.custom.OpenConfigEntry; -import emu.grasscutter.data.custom.QuestConfig; -import emu.grasscutter.data.custom.QuestConfigData; -import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData; +import emu.grasscutter.data.custom.MainQuestData; import emu.grasscutter.data.custom.ScenePointEntry; import emu.grasscutter.game.world.SpawnDataEntry.*; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -407,24 +405,19 @@ public class ResourceLoader { } for (File file : folder.listFiles()) { - QuestConfigData mainQuest = null; + MainQuestData mainQuest = null; try (FileReader fileReader = new FileReader(file)) { - mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, QuestConfigData.class); + mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, MainQuestData.class); } catch (Exception e) { e.printStackTrace(); continue; } - if (mainQuest.getSubQuests() != null) { - for (SubQuestConfigData subQuest : mainQuest.getSubQuests()) { - QuestConfig quest = new QuestConfig(mainQuest, subQuest); - GameData.getQuestConfigs().put(quest.getId(), quest); - } - } + GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest); } - Grasscutter.getLogger().info("Loaded " + GameData.getQuestConfigs().size() + " Quest Configs"); + Grasscutter.getLogger().info("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas."); } // BinOutput configs diff --git a/src/main/java/emu/grasscutter/data/custom/MainQuestData.java b/src/main/java/emu/grasscutter/data/custom/MainQuestData.java new file mode 100644 index 000000000..e405e3598 --- /dev/null +++ b/src/main/java/emu/grasscutter/data/custom/MainQuestData.java @@ -0,0 +1,53 @@ +package emu.grasscutter.data.custom; + +import emu.grasscutter.game.quest.enums.LogicType; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.enums.QuestType; + +public class MainQuestData { + private int id; + private int series; + private QuestType type; + + private long titleTextMapHash; + private int[] suggestTrackMainQuestList; + private int[] rewardIdList; + + private SubQuestData[] subQuests; + + public int getId() { + return id; + } + + public int getSeries() { + return series; + } + + public QuestType getType() { + return type; + } + + public long getTitleTextMapHash() { + return titleTextMapHash; + } + + public int[] getSuggestTrackMainQuestList() { + return suggestTrackMainQuestList; + } + + public int[] getRewardIdList() { + return rewardIdList; + } + + public SubQuestData[] getSubQuests() { + return subQuests; + } + + public static class SubQuestData { + private int subId; + + public int getSubId() { + return subId; + } + } +} diff --git a/src/main/java/emu/grasscutter/data/custom/QuestConfig.java b/src/main/java/emu/grasscutter/data/custom/QuestConfig.java deleted file mode 100644 index 8674ff7ab..000000000 --- a/src/main/java/emu/grasscutter/data/custom/QuestConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package emu.grasscutter.data.custom; - -import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData; - -public class QuestConfig { - private final QuestConfigData mainQuest; - private final SubQuestConfigData subQuest; - - public QuestConfig(QuestConfigData mainQuest, SubQuestConfigData subQuest) { - this.mainQuest = mainQuest; - this.subQuest = subQuest; - } - - public int getId() { - return subQuest.getSubId(); - } - - public QuestConfigData getMainQuest() { - return mainQuest; - } - - public SubQuestConfigData getSubQuest() { - return subQuest; - } -} diff --git a/src/main/java/emu/grasscutter/data/custom/QuestConfigData.java b/src/main/java/emu/grasscutter/data/custom/QuestConfigData.java deleted file mode 100644 index 3ede024f2..000000000 --- a/src/main/java/emu/grasscutter/data/custom/QuestConfigData.java +++ /dev/null @@ -1,104 +0,0 @@ -package emu.grasscutter.data.custom; - -import emu.grasscutter.game.quest.enums.LogicType; -import emu.grasscutter.game.quest.enums.QuestTriggerType; -import emu.grasscutter.game.quest.enums.QuestType; - -public class QuestConfigData { - private int id; - private int series; - private QuestType type; - - private long titleTextMapHash; - private int[] suggestTrackMainQuestList; - private int[] rewardIdList; - - private SubQuestConfigData[] subQuests; - - public int getId() { - return id; - } - - public int getSeries() { - return series; - } - - public QuestType getType() { - return type; - } - - public long getTitleTextMapHash() { - return titleTextMapHash; - } - - public int[] getSuggestTrackMainQuestList() { - return suggestTrackMainQuestList; - } - - public int[] getRewardIdList() { - return rewardIdList; - } - - public SubQuestConfigData[] getSubQuests() { - return subQuests; - } - - public class SubQuestConfigData { - private int subId; - private int mainId; - - private LogicType acceptCondComb; - private QuestCondition[] acceptCond; - - private LogicType finishCondComb; - private QuestCondition[] finishCond; - - private LogicType failCondComb; - private QuestCondition[] failCond; - - public int getSubId() { - return subId; - } - - public int getMainId() { - return mainId; - } - - public LogicType getAcceptCondComb() { - return acceptCondComb; - } - - public QuestCondition[] getAcceptCond() { - return acceptCond; - } - - public LogicType getFinishCondComb() { - return finishCondComb; - } - - public QuestCondition[] getFinishCond() { - return finishCond; - } - - public LogicType getFailCondComb() { - return failCondComb; - } - - public QuestCondition[] getFailCond() { - return failCond; - } - } - - public class QuestCondition { - private QuestTriggerType type; - private int[] param; - - public QuestTriggerType getType() { - return type; - } - - public int[] getParam() { - return param; - } - } -} diff --git a/src/main/java/emu/grasscutter/data/def/QuestData.java b/src/main/java/emu/grasscutter/data/def/QuestData.java new file mode 100644 index 000000000..31ac2ce7e --- /dev/null +++ b/src/main/java/emu/grasscutter/data/def/QuestData.java @@ -0,0 +1,115 @@ +package emu.grasscutter.data.def; + +import java.util.Arrays; +import java.util.List; + +import emu.grasscutter.data.GameResource; +import emu.grasscutter.data.ResourceType; +import emu.grasscutter.game.quest.enums.LogicType; +import emu.grasscutter.game.quest.enums.QuestTrigger; + +@ResourceType(name = "QuestExcelConfigData.json") +public class QuestData extends GameResource { + private int SubId; + private int MainId; + private int Order; + private long DescTextMapHash; + + private LogicType AcceptCondComb; + private QuestCondition[] acceptConditons; + private LogicType FinishCondComb; + private QuestCondition[] finishConditons; + private LogicType FailCondComb; + private QuestCondition[] failConditons; + + private List AcceptCond; + private List FinishCond; + private List FailCond; + private List BeginExec; + private List FinishExec; + private List FailExec; + + public int getId() { + return SubId; + } + + public int getMainId() { + return MainId; + } + + public int getOrder() { + return Order; + } + + public long getDescTextMapHash() { + return DescTextMapHash; + } + + public LogicType getAcceptCondComb() { + return AcceptCondComb; + } + + public QuestCondition[] getAcceptCond() { + return acceptConditons; + } + + public LogicType getFinishCondComb() { + return FinishCondComb; + } + + public QuestCondition[] getFinishCond() { + return finishConditons; + } + + public LogicType getFailCondComb() { + return FailCondComb; + } + + public QuestCondition[] getFailCond() { + return failConditons; + } + + public void onLoad() { + this.acceptConditons = AcceptCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new); + AcceptCond = null; + this.finishConditons = FinishCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new); + FinishCond = null; + this.failConditons = FailCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new); + FailCond = null; + } + + public class QuestParam { + QuestTrigger Type; + int[] Param; + String count; + } + + public class QuestExecParam { + QuestTrigger Type; + String[] Param; + String count; + } + + public static class QuestCondition { + private QuestTrigger type; + private int[] param; + private String count; + + public QuestCondition(QuestParam param) { + this.type = param.Type; + this.param = param.Param; + } + + public QuestTrigger getType() { + return type; + } + + public int[] getParam() { + return param; + } + + public String getCount() { + return count; + } + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java b/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java index 1ceda3356..bf88b8efe 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java @@ -10,7 +10,6 @@ import dev.morphia.annotations.Id; import dev.morphia.annotations.Indexed; import dev.morphia.annotations.Transient; import emu.grasscutter.data.GameData; -import emu.grasscutter.data.custom.QuestConfig; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.quest.enums.ParentQuestState; diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index d3a240a07..b242166eb 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -2,9 +2,11 @@ package emu.grasscutter.game.quest; import dev.morphia.annotations.Entity; import dev.morphia.annotations.Transient; -import emu.grasscutter.data.custom.QuestConfig; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; -import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData; +import emu.grasscutter.data.GameData; +import emu.grasscutter.data.custom.MainQuestData; +import emu.grasscutter.data.custom.MainQuestData.SubQuestData; +import emu.grasscutter.data.def.QuestData; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.quest.enums.LogicType; import emu.grasscutter.game.quest.enums.QuestState; @@ -16,7 +18,7 @@ import emu.grasscutter.utils.Utils; @Entity public class GameQuest { @Transient private GameMainQuest mainQuest; - @Transient private QuestConfig config; + @Transient private QuestData questData; private int questId; private int mainQuestId; @@ -32,21 +34,21 @@ public class GameQuest { @Deprecated // Morphia only. Do not use. public GameQuest() {} - public GameQuest(GameMainQuest mainQuest, QuestConfig config) { + public GameQuest(GameMainQuest mainQuest, QuestData questData) { this.mainQuest = mainQuest; - this.questId = config.getId(); - this.mainQuestId = config.getMainQuest().getId(); - this.config = config; + this.questId = questData.getId(); + this.mainQuestId = questData.getMainId(); + this.questData = questData; this.acceptTime = Utils.getCurrentSeconds(); this.startTime = this.acceptTime; this.state = QuestState.QUEST_STATE_UNFINISHED; - if (config.getSubQuest().getFinishCond() != null) { - this.finishProgressList = new int[config.getSubQuest().getFinishCond().length]; + if (questData.getFinishCond()!= null) { + this.finishProgressList = new int[questData.getFinishCond().length]; } - if (config.getSubQuest().getFailCond() != null) { - this.failProgressList = new int[config.getSubQuest().getFailCond().length]; + if (questData.getFailCond() != null) { + this.failProgressList = new int[questData.getFailCond().length]; } this.mainQuest.getChildQuests().put(this.questId, this); @@ -72,13 +74,13 @@ public class GameQuest { return mainQuestId; } - public QuestConfig getConfig() { - return config; + public QuestData getData() { + return questData; } - public void setConfig(QuestConfig config) { + public void setConfig(QuestData config) { if (this.getQuestId() != config.getId()) return; - this.config = config; + this.questData = config; } public QuestState getState() { @@ -148,16 +150,23 @@ public class GameQuest { public boolean tryAcceptQuestLine() { try { - for (SubQuestConfigData questData : getConfig().getMainQuest().getSubQuests()) { - GameQuest quest = getMainQuest().getChildQuestById(questData.getSubId()); + MainQuestData questConfig = GameData.getMainQuestDataMap().get(this.getMainQuestId()); + for (SubQuestData subQuest : questConfig.getSubQuests()) { + GameQuest quest = getMainQuest().getChildQuestById(subQuest.getSubId()); if (quest == null) { + QuestData questData = GameData.getQuestDataMap().get(subQuest.getSubId()); + + if (questData == null) { + continue; + } + int[] accept = new int[questData.getAcceptCond().length]; // TODO for (int i = 0; i < questData.getAcceptCond().length; i++) { QuestCondition condition = questData.getAcceptCond()[i]; - boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition); + boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition, condition.getParam()); accept[i] = result ? 1 : 0; } @@ -165,7 +174,7 @@ public class GameQuest { boolean shouldAccept = LogicType.calculate(questData.getAcceptCondComb(), accept); if (shouldAccept) { - this.getOwner().getQuestManager().addQuest(questData.getSubId()); + this.getOwner().getQuestManager().addQuest(questData.getId()); } } } diff --git a/src/main/java/emu/grasscutter/game/quest/QuestManager.java b/src/main/java/emu/grasscutter/game/quest/QuestManager.java index 76c098b07..548e8241a 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestManager.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestManager.java @@ -9,12 +9,11 @@ import java.util.function.Consumer; import java.util.function.Function; import emu.grasscutter.data.GameData; -import emu.grasscutter.data.custom.QuestConfig; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; -import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData; +import emu.grasscutter.data.def.QuestData; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.enums.LogicType; import emu.grasscutter.game.quest.enums.QuestState; import emu.grasscutter.server.packet.send.PacketFinishedParentQuestUpdateNotify; @@ -46,12 +45,12 @@ public class QuestManager { } public GameQuest getQuestById(int questId) { - QuestConfig questConfig = GameData.getQuestConfigs().get(questId); + QuestData questConfig = GameData.getQuestDataMap().get(questId); if (questConfig == null) { return null; } - GameMainQuest mainQuest = getQuests().get(questConfig.getMainQuest().getId()); + GameMainQuest mainQuest = getQuests().get(questConfig.getMainId()); if (mainQuest == null) { return null; @@ -79,8 +78,8 @@ public class QuestManager { } } - public GameMainQuest addMainQuest(QuestConfig questConfig) { - GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainQuest().getId()); + public GameMainQuest addMainQuest(QuestData questConfig) { + GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId()); getQuests().put(mainQuest.getParentQuestId(), mainQuest); getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(mainQuest)); @@ -89,13 +88,13 @@ public class QuestManager { } public GameQuest addQuest(int questId) { - QuestConfig questConfig = GameData.getQuestConfigs().get(questId); + QuestData questConfig = GameData.getQuestDataMap().get(questId); if (questConfig == null) { return null; } // Main quest - GameMainQuest mainQuest = this.getMainQuestById(questConfig.getMainQuest().getId()); + GameMainQuest mainQuest = this.getMainQuestById(questConfig.getMainId()); // Create main quest if it doesnt exist if (mainQuest == null) { @@ -122,11 +121,11 @@ public class QuestManager { return quest; } - public void triggerEvent(QuestTriggerType condType, int... params) { + public void triggerEvent(QuestTrigger condType, int... params) { Set changedQuests = new HashSet<>(); this.forEachActiveQuest(quest -> { - SubQuestConfigData data = quest.getConfig().getSubQuest(); + QuestData data = quest.getData(); for (int i = 0; i < data.getFinishCond().length; i++) { if (quest.getFinishProgressList()[i] == 1) { @@ -150,7 +149,7 @@ public class QuestManager { }); for (GameQuest quest : changedQuests) { - LogicType logicType = quest.getConfig().getSubQuest().getFailCondComb(); + LogicType logicType = quest.getData().getFailCondComb(); int[] progress = quest.getFinishProgressList(); // Handle logical comb @@ -174,7 +173,7 @@ public class QuestManager { for (GameQuest quest : mainQuest.getChildQuests().values()) { quest.setMainQuest(mainQuest); - quest.setConfig(GameData.getQuestConfigs().get(quest.getQuestId())); + quest.setConfig(GameData.getQuestDataMap().get(quest.getQuestId())); } this.getQuests().put(mainQuest.getParentQuestId(), mainQuest); diff --git a/src/main/java/emu/grasscutter/game/quest/QuestValue.java b/src/main/java/emu/grasscutter/game/quest/QuestValue.java index 3042ad5de..42b868fc8 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestValue.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestValue.java @@ -3,9 +3,9 @@ package emu.grasscutter.game.quest; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; @Retention(RetentionPolicy.RUNTIME) public @interface QuestValue { - QuestTriggerType value(); + QuestTrigger value(); } diff --git a/src/main/java/emu/grasscutter/game/quest/ServerQuestHandler.java b/src/main/java/emu/grasscutter/game/quest/ServerQuestHandler.java index 1c269de90..36c929ab3 100644 --- a/src/main/java/emu/grasscutter/game/quest/ServerQuestHandler.java +++ b/src/main/java/emu/grasscutter/game/quest/ServerQuestHandler.java @@ -4,11 +4,9 @@ import java.util.Set; import org.reflections.Reflections; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -import emu.grasscutter.net.packet.Opcodes; -import emu.grasscutter.server.game.GameServer; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -62,7 +60,7 @@ public class ServerQuestHandler { public boolean triggerCondition(GameQuest quest, QuestCondition condition, int... params) { QuestBaseHandler handler = condHandlers.get(condition.getType().getValue()); - if (handler == null || quest.getConfig() == null) { + if (handler == null || quest.getData() == null) { return false; } @@ -72,7 +70,7 @@ public class ServerQuestHandler { public boolean triggerContent(GameQuest quest, QuestCondition condition, int... params) { QuestBaseHandler handler = contHandlers.get(condition.getType().getValue()); - if (handler == null || quest.getConfig() == null) { + if (handler == null || quest.getData() == null) { return false; } @@ -82,7 +80,7 @@ public class ServerQuestHandler { public boolean triggerExec(GameQuest quest, QuestCondition condition, int... params) { QuestBaseHandler handler = execHandlers.get(condition.getType().getValue()); - if (handler == null || quest.getConfig() == null) { + if (handler == null || quest.getData() == null) { return false; } diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/BaseCondition.java b/src/main/java/emu/grasscutter/game/quest/conditions/BaseCondition.java index 903773f0e..d94e60c22 100644 --- a/src/main/java/emu/grasscutter/game/quest/conditions/BaseCondition.java +++ b/src/main/java/emu/grasscutter/game/quest/conditions/BaseCondition.java @@ -1,12 +1,12 @@ package emu.grasscutter.game.quest.conditions; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.QuestValue; import emu.grasscutter.game.quest.GameQuest; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -@QuestValue(QuestTriggerType.QUEST_CONTENT_NONE) +@QuestValue(QuestTrigger.QUEST_CONTENT_NONE) public class BaseCondition extends QuestBaseHandler { @Override diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionPlayerLevelEqualGreater.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionPlayerLevelEqualGreater.java index f5df2b13c..3e3db87fb 100644 --- a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionPlayerLevelEqualGreater.java +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionPlayerLevelEqualGreater.java @@ -1,17 +1,17 @@ package emu.grasscutter.game.quest.conditions; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.QuestValue; import emu.grasscutter.game.quest.GameQuest; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -@QuestValue(QuestTriggerType.QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER) +@QuestValue(QuestTrigger.QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER) public class ConditionPlayerLevelEqualGreater extends QuestBaseHandler { @Override public boolean execute(GameQuest quest, QuestCondition condition, int... params) { - return quest.getOwner().getLevel() >= condition.getParam()[0]; + return quest.getOwner().getLevel() >= params[0]; } } diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateEqual.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateEqual.java index 71b44c967..37ecc6d30 100644 --- a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateEqual.java +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateEqual.java @@ -1,20 +1,20 @@ package emu.grasscutter.game.quest.conditions; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.QuestValue; import emu.grasscutter.game.quest.GameQuest; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -@QuestValue(QuestTriggerType.QUEST_COND_STATE_EQUAL) +@QuestValue(QuestTrigger.QUEST_COND_STATE_EQUAL) public class ConditionStateEqual extends QuestBaseHandler { @Override public boolean execute(GameQuest quest, QuestCondition condition, int... params) { - GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]); + GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(params[0]); if (checkQuest != null) { - return checkQuest.getState().getValue() == condition.getParam()[1]; + return checkQuest.getState().getValue() == params[1]; } return false; diff --git a/src/main/java/emu/grasscutter/game/quest/content/BaseContent.java b/src/main/java/emu/grasscutter/game/quest/content/BaseContent.java index 820d6f133..ce700896d 100644 --- a/src/main/java/emu/grasscutter/game/quest/content/BaseContent.java +++ b/src/main/java/emu/grasscutter/game/quest/content/BaseContent.java @@ -1,12 +1,12 @@ package emu.grasscutter.game.quest.content; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.QuestValue; import emu.grasscutter.game.quest.GameQuest; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -@QuestValue(QuestTriggerType.QUEST_CONTENT_NONE) +@QuestValue(QuestTrigger.QUEST_CONTENT_NONE) public class BaseContent extends QuestBaseHandler { @Override diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java index aad196306..3423519ec 100644 --- a/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java @@ -1,12 +1,12 @@ package emu.grasscutter.game.quest.content; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.QuestValue; import emu.grasscutter.game.quest.GameQuest; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.handlers.QuestBaseHandler; -@QuestValue(QuestTriggerType.QUEST_CONTENT_COMPLETE_TALK) +@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK) public class ContentCompleteTalk extends QuestBaseHandler { @Override diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestTriggerType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestTrigger.java similarity index 99% rename from src/main/java/emu/grasscutter/game/quest/enums/QuestTriggerType.java rename to src/main/java/emu/grasscutter/game/quest/enums/QuestTrigger.java index cf8dabdba..def3a399d 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestTriggerType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestTrigger.java @@ -1,6 +1,6 @@ package emu.grasscutter.game.quest.enums; -public enum QuestTriggerType { +public enum QuestTrigger { QUEST_COND_NONE (0), QUEST_COND_STATE_EQUAL (1), QUEST_COND_STATE_NOT_EQUAL (2), @@ -225,7 +225,7 @@ public enum QuestTriggerType { private final int value; - QuestTriggerType(int id) { + QuestTrigger(int id) { this.value = id; } diff --git a/src/main/java/emu/grasscutter/game/quest/handlers/QuestBaseHandler.java b/src/main/java/emu/grasscutter/game/quest/handlers/QuestBaseHandler.java index 68bf88361..5a3514200 100644 --- a/src/main/java/emu/grasscutter/game/quest/handlers/QuestBaseHandler.java +++ b/src/main/java/emu/grasscutter/game/quest/handlers/QuestBaseHandler.java @@ -1,6 +1,6 @@ package emu.grasscutter.game.quest.handlers; -import emu.grasscutter.data.custom.QuestConfigData.QuestCondition; +import emu.grasscutter.data.def.QuestData.QuestCondition; import emu.grasscutter.game.quest.GameQuest; public abstract class QuestBaseHandler { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java index 515552289..82248c98c 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java @@ -1,7 +1,7 @@ package emu.grasscutter.server.packet.recv; import emu.grasscutter.game.inventory.GameItem; -import emu.grasscutter.game.quest.enums.QuestTriggerType; +import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.NpcTalkReqOuterClass.NpcTalkReq; @@ -16,7 +16,7 @@ public class HandlerNpcTalkReq extends PacketHandler { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { NpcTalkReq req = NpcTalkReq.parseFrom(payload); - session.getPlayer().getQuestManager().triggerEvent(QuestTriggerType.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId()); + session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId()); session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId())); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java index b2ea3d577..fa2e8ab81 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java @@ -1,9 +1,6 @@ package emu.grasscutter.server.packet.send; -import emu.grasscutter.data.GameData; -import emu.grasscutter.data.custom.QuestConfig; import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.quest.GameMainQuest; import emu.grasscutter.game.quest.GameQuest; import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.PacketOpcodes; diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index 8b28c027e..5b0f563ee 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -19,10 +19,11 @@ import emu.grasscutter.command.Command; import emu.grasscutter.command.CommandMap; import emu.grasscutter.data.GameData; import emu.grasscutter.data.ResourceLoader; -import emu.grasscutter.data.custom.QuestConfig; +import emu.grasscutter.data.custom.MainQuestData; import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.MonsterData; +import emu.grasscutter.data.def.QuestData; import emu.grasscutter.data.def.SceneData; import emu.grasscutter.utils.Utils; @@ -149,13 +150,16 @@ final class ToolsWithLanguageOption { writer.println(data.getId() + " : " + data.getScriptData()); } + writer.println(); + writer.println("// Quests"); - list = new ArrayList<>(GameData.getQuestConfigs().keySet()); + list = new ArrayList<>(GameData.getQuestDataMap().keySet()); Collections.sort(list); for (Integer id : list) { - QuestConfig data = GameData.getQuestConfigs().get(id); - writer.println(data.getId() + " : " + map.get(data.getMainQuest().getTitleTextMapHash())); + QuestData data = GameData.getQuestDataMap().get(id); + MainQuestData mainQuest = GameData.getMainQuestDataMap().get(data.getMainId()); + writer.println(data.getId() + " : " + map.get(mainQuest.getTitleTextMapHash()) + " - " + map.get(data.getDescTextMapHash())); } writer.println();