mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 13:13:06 +08:00
Load talks from MainQuestData
This commit is contained in:
parent
6869008bcc
commit
400a670856
@ -63,6 +63,10 @@ public class MainQuestData {
|
||||
|
||||
this.talks = this.talks.stream()
|
||||
.filter(Objects::nonNull).toList();
|
||||
// Apply talk data to the quest talk map.
|
||||
this.talks.forEach(talkData -> GameData.getQuestTalkMap().put(
|
||||
talkData.getId(), this.getId()));
|
||||
// Apply additional sub-quest data to sub-quests.
|
||||
Arrays.stream(this.subQuests).forEach(quest -> {
|
||||
var questData = GameData.getQuestDataMap().get(quest.getSubId());
|
||||
if (questData != null) questData.applyFrom(quest);
|
||||
|
@ -1,33 +1,28 @@
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
@ResourceType(name = "ChapterExcelConfigData.json")
|
||||
@Getter
|
||||
@Setter // TODO: remove on next API break
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public class ChapterData extends GameResource {
|
||||
// Why public? TODO: privatise next API break
|
||||
public static final Map<Integer, ChapterData> beginQuestChapterMap = new HashMap<>();
|
||||
public static final Map<Integer, ChapterData> endQuestChapterMap = new HashMap<>();
|
||||
|
||||
@Getter(onMethod_ = @Override)
|
||||
int id;
|
||||
|
||||
int beginQuestId;
|
||||
int endQuestId;
|
||||
int needPlayerLevel;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
beginQuestChapterMap.put(beginQuestId, this);
|
||||
beginQuestChapterMap.put(endQuestId, this);
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "ChapterExcelConfigData.json")
|
||||
public class ChapterData extends GameResource {
|
||||
@Getter private static final Map<Integer, ChapterData> beginQuestChapterMap
|
||||
= new HashMap<>();
|
||||
@Getter private static final Map<Integer, ChapterData> endQuestChapterMap
|
||||
= new HashMap<>();
|
||||
|
||||
@Getter(onMethod_ = @Override)
|
||||
private int id;
|
||||
private int beginQuestId;
|
||||
private int endQuestId;
|
||||
private int needPlayerLevel;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
beginQuestChapterMap.put(beginQuestId, this);
|
||||
beginQuestChapterMap.put(endQuestId, this);
|
||||
}
|
||||
}
|
||||
|
@ -94,11 +94,11 @@ public class GameQuest {
|
||||
|
||||
getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
|
||||
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)) {
|
||||
if (ChapterData.getBeginQuestChapterMap().containsKey(subQuestId)) {
|
||||
getOwner()
|
||||
.sendPacket(
|
||||
new PacketChapterStateNotify(
|
||||
ChapterData.beginQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterData.getBeginQuestChapterMap().get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_BEGIN));
|
||||
}
|
||||
|
||||
@ -178,23 +178,29 @@ public class GameQuest {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
public synchronized void finish() {
|
||||
// Check if the quest has been finished.
|
||||
if (this.state == QuestState.QUEST_STATE_FINISHED) {
|
||||
Grasscutter.getLogger().debug("Quest {} was already finished.", this.getSubQuestId());
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
|
||||
getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
|
||||
this.getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
|
||||
|
||||
if (getQuestData().isFinishParent()) {
|
||||
if (this.getQuestData().isFinishParent()) {
|
||||
// This quest finishes the questline - the main quest will also save the quest to db, so we
|
||||
// don't have to call save() here
|
||||
getMainQuest().finish();
|
||||
this.getMainQuest().finish();
|
||||
}
|
||||
|
||||
getQuestData()
|
||||
this.getQuestData()
|
||||
.getFinishExec()
|
||||
.forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
// Some subQuests have conditions that subQuests are finished (even from different MainQuests)
|
||||
getOwner()
|
||||
this.getOwner()
|
||||
.getQuestManager()
|
||||
.queueEvent(
|
||||
QuestContent.QUEST_CONTENT_QUEST_STATE_EQUAL,
|
||||
@ -203,25 +209,25 @@ public class GameQuest {
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
getOwner()
|
||||
this.getOwner()
|
||||
.getQuestManager()
|
||||
.queueEvent(QuestContent.QUEST_CONTENT_FINISH_PLOT, this.subQuestId, 0);
|
||||
getOwner()
|
||||
this.getOwner()
|
||||
.getQuestManager()
|
||||
.queueEvent(
|
||||
QuestCond.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(), 0, 0, 0);
|
||||
getOwner()
|
||||
this.getOwner()
|
||||
.getScene()
|
||||
.triggerDungeonEvent(DungeonPassConditionType.DUNGEON_COND_FINISH_QUEST, getSubQuestId());
|
||||
|
||||
getOwner().getProgressManager().tryUnlockOpenStates();
|
||||
this.getOwner().getProgressManager().tryUnlockOpenStates();
|
||||
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest
|
||||
if (ChapterData.getEndQuestChapterMap().containsKey(subQuestId)) {
|
||||
this.getMainQuest()
|
||||
.getOwner()
|
||||
.sendPacket(
|
||||
new PacketChapterStateNotify(
|
||||
ChapterData.endQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterData.getEndQuestChapterMap().get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_END));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user