mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-22 11:54:39 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -41,17 +41,17 @@ import static emu.grasscutter.config.Configuration.SCRIPT;
|
||||
|
||||
@Entity(value = "quests", useDiscriminator = false)
|
||||
public class GameMainQuest {
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Transient @Getter private QuestManager questManager;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
//QuestUpdateQuestVarReq is sent in two stages...
|
||||
@Getter private List<Integer> questVarsUpdate;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter List<QuestGroupSuite> questGroupSuites;
|
||||
|
||||
@Getter int[] suggestTrackMainQuestList;
|
||||
@@ -60,25 +60,25 @@ public class GameMainQuest {
|
||||
private Map<Integer,Position> rewindPositions;
|
||||
private Map<Integer,Position> rewindRotations;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
this.questManager = player.getQuestManager();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.talks = new HashMap<>();
|
||||
//official server always has a list of 5 questVars, with default value 0
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questGroupSuites = new ArrayList<>();
|
||||
this.rewindPositions = new HashMap<>();
|
||||
this.rewindRotations = new HashMap<>();
|
||||
addAllChildQuests();
|
||||
addRewindPoints();
|
||||
}
|
||||
}
|
||||
|
||||
private void addAllChildQuests() {
|
||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(SubQuestData::getSubId).toList();
|
||||
@@ -88,10 +88,10 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
public int getQuestVar(int i) {
|
||||
return questVars[i];
|
||||
@@ -115,71 +115,71 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestByOrder(int order) {
|
||||
return this.getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() == order).toList().get(0);
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
|
||||
this.save();
|
||||
this.save();
|
||||
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
|
||||
// handoff main quest
|
||||
if(mainQuestData.getSuggestTrackMainQuestList() != null){
|
||||
if (mainQuestData.getSuggestTrackMainQuestList() != null) {
|
||||
Arrays.stream(mainQuestData.getSuggestTrackMainQuestList())
|
||||
.forEach(getQuestManager()::startMainQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
public void fail() {}
|
||||
public void cancel() {}
|
||||
|
||||
// Rewinds to the last finished/unfinished rewind quest, and returns the avatar rewind position (if it exists)
|
||||
public List<Position> rewind() {
|
||||
if(this.questManager == null) {
|
||||
if (this.questManager == null) {
|
||||
this.questManager = getOwner().getQuestManager();
|
||||
}
|
||||
List<GameQuest> sortedByOrder = new ArrayList<>(getChildQuests().values().stream().filter(q -> q.getQuestData().isRewind()).toList());
|
||||
sortedByOrder.sort((a,b) -> {
|
||||
if( a == b){
|
||||
if ( a == b) {
|
||||
return 0;
|
||||
}
|
||||
return a.getQuestData().getOrder() > b.getQuestData().getOrder() ? 1 : -1;});
|
||||
boolean didRewind = false;
|
||||
for (GameQuest quest : sortedByOrder) {
|
||||
int i = sortedByOrder.indexOf(quest);
|
||||
if( i == sortedByOrder.size()) {
|
||||
if ( i == sortedByOrder.size()) {
|
||||
didRewind = quest.rewind(null);
|
||||
} else {
|
||||
didRewind = quest.rewind(sortedByOrder.get(i+1));
|
||||
}
|
||||
if(didRewind) {
|
||||
if (didRewind) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<GameQuest> rewindQuests = getChildQuests().values().stream()
|
||||
.filter(p -> (p.getState() == QuestState.QUEST_STATE_UNFINISHED || p.getState() == QuestState.QUEST_STATE_FINISHED) && p.getQuestData().isRewind()).toList();
|
||||
for (GameQuest quest : rewindQuests) {
|
||||
if(rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
if (rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
List<Position> posAndRot = new ArrayList<>();
|
||||
posAndRot.add(0,rewindPositions.get(quest.getSubQuestId()));
|
||||
posAndRot.add(1,rewindRotations.get(quest.getSubQuestId()));
|
||||
@@ -206,17 +206,17 @@ public class GameMainQuest {
|
||||
cs.eval(bindings);
|
||||
|
||||
var rewindDataMap = ScriptLoader.getSerializer().toMap(RewindData.class, bindings.get("rewind_data"));
|
||||
for(String subId : rewindDataMap.keySet()) {
|
||||
for (String subId : rewindDataMap.keySet()) {
|
||||
RewindData questRewind = rewindDataMap.get(subId);
|
||||
if(questRewind != null) {
|
||||
if (questRewind != null) {
|
||||
RewindData.AvatarData avatarData = questRewind.getAvatar();
|
||||
if(avatarData != null) {
|
||||
if (avatarData != null) {
|
||||
String avatarPos = avatarData.getPos();
|
||||
QuestData.Guide guide = GameData.getQuestDataMap().get(Integer.valueOf(subId)).getGuide();
|
||||
if (guide != null) {
|
||||
int sceneId = guide.getGuideScene();
|
||||
ScriptSceneData fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||
if(fullGlobals != null) {
|
||||
if (fullGlobals != null) {
|
||||
ScriptSceneData.ScriptObject dummyPointScript = fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
||||
if (dummyPointScript != null) {
|
||||
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
||||
@@ -287,10 +287,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
||||
QuestData.QuestCondition condition = failCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -322,10 +322,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < finishCond.size(); i++) {
|
||||
QuestData.QuestCondition condition = finishCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFinishProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -343,14 +343,14 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
|
||||
|
||||
proto.setParentQuestState(getState().getValue())
|
||||
@@ -371,7 +371,7 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,33 +29,33 @@ import java.util.Map;
|
||||
|
||||
@Entity
|
||||
public class GameQuest {
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
private QuestState state;
|
||||
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Transient @Getter private Map<String, TriggerExcelConfigData> triggerData;
|
||||
@Getter private Map<String, Boolean> triggers;
|
||||
private transient Bindings bindings;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
this.triggerData = new HashMap<>();
|
||||
this.triggers = new HashMap<>();
|
||||
}
|
||||
@@ -66,11 +66,11 @@ public class GameQuest {
|
||||
this.state = QuestState.QUEST_STATE_UNFINISHED;
|
||||
List<QuestData.QuestCondition> triggerCond = questData.getFinishCond().stream()
|
||||
.filter(p -> p.getType() == QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE).toList();
|
||||
if(triggerCond.size() > 0) {
|
||||
if (triggerCond.size() > 0) {
|
||||
for (QuestData.QuestCondition cond : triggerCond) {
|
||||
TriggerExcelConfigData newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]);
|
||||
if(newTrigger != null) {
|
||||
if(this.triggerData == null) {
|
||||
if (newTrigger != null) {
|
||||
if (this.triggerData == null) {
|
||||
this.triggerData = new HashMap<>();
|
||||
}
|
||||
triggerData.put(newTrigger.getTriggerName(), newTrigger);
|
||||
@@ -92,7 +92,7 @@ public class GameQuest {
|
||||
getQuestData().getBeginExec().forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
|
||||
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.beginQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_BEGIN
|
||||
@@ -108,7 +108,7 @@ public class GameQuest {
|
||||
|
||||
public String getTriggerNameById(int id) {
|
||||
TriggerExcelConfigData trigger = GameData.getTriggerExcelConfigDataMap().get(id);
|
||||
if(trigger != null) {
|
||||
if (trigger != null) {
|
||||
String triggerName = trigger.getTriggerName();
|
||||
return triggerName;
|
||||
}
|
||||
@@ -116,38 +116,38 @@ public class GameQuest {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
|
||||
if (getQuestData().finishParent()) {
|
||||
// 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();
|
||||
}
|
||||
if (getQuestData().finishParent()) {
|
||||
// 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();
|
||||
}
|
||||
|
||||
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().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
getOwner().getQuestManager().triggerEvent(QuestTrigger.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.endQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_END
|
||||
@@ -155,7 +155,7 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().debug("Quest {} is finished", subQuestId);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void fail() {
|
||||
@@ -171,9 +171,9 @@ public class GameQuest {
|
||||
// Return true if ParentQuest should rewind to this childQuest
|
||||
public boolean rewind(GameQuest nextRewind) {
|
||||
if (questData.isRewind()) {
|
||||
if(nextRewind == null) {return true;}
|
||||
if (nextRewind == null) {return true;}
|
||||
// if the next isRewind subQuest is none or unstarted, reset all subQuests with order higher than this one, and restart this quest
|
||||
if(nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
if (nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
getMainQuest().getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()).forEach(q -> q.setState(QuestState.QUEST_STATE_UNSTARTED));
|
||||
this.start();
|
||||
return true;
|
||||
@@ -181,31 +181,31 @@ public class GameQuest {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import lombok.Getter;
|
||||
|
||||
public class QuestManager extends BasePlayerManager {
|
||||
|
||||
@Getter private final Player player;
|
||||
@Getter private final Player player;
|
||||
@Getter private final Int2ObjectMap<GameMainQuest> mainQuests;
|
||||
@Getter private List<GameQuest> addToQuestListUpdateNotify;
|
||||
/*
|
||||
@@ -62,17 +62,17 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
*/
|
||||
|
||||
public static long getQuestKey(int mainQuestId){
|
||||
public static long getQuestKey(int mainQuestId) {
|
||||
QuestEncryptionKey questEncryptionKey = GameData.getMainQuestEncryptionMap().get(mainQuestId);
|
||||
return questEncryptionKey != null ? questEncryptionKey.getEncryptionKey() : 0L;
|
||||
}
|
||||
public QuestManager(Player player) {
|
||||
public QuestManager(Player player) {
|
||||
|
||||
super(player);
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.addToQuestListUpdateNotify = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public void onNewPlayerCreate() {
|
||||
|
||||
@@ -86,9 +86,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
public void onLogin() {
|
||||
|
||||
List<GameMainQuest> activeQuests = getActiveMainQuests();
|
||||
for(GameMainQuest quest : activeQuests) {
|
||||
for (GameMainQuest quest : activeQuests) {
|
||||
List<Position> rewindPos = quest.rewind(); // <pos, rotation>
|
||||
if(rewindPos != null) {
|
||||
if (rewindPos != null) {
|
||||
getPlayer().getPosition().set(rewindPos.get(0));
|
||||
getPlayer().getRotation().set(rewindPos.get(1));
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
private List<GameMainQuest> addMultMainQuests(Set<Integer> mainQuestIds) {
|
||||
List<GameMainQuest> newQuests = new ArrayList<>();
|
||||
for(Integer id : mainQuestIds) {
|
||||
for (Integer id : mainQuestIds) {
|
||||
getMainQuests().put(id.intValue(),new GameMainQuest(this.player, id));
|
||||
getMainQuestById(id).save();
|
||||
newQuests.add(getMainQuestById(id));
|
||||
@@ -130,9 +130,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
Grasscutter.getLogger().debug("Decremented questGlobalVar {} value from {} to {}", variable, previousValue, previousValue - dec);
|
||||
}
|
||||
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
|
||||
public GameQuest getQuestById(int questId) {
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(questId);
|
||||
@@ -140,7 +140,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
|
||||
if (mainQuest == null) {
|
||||
return null;
|
||||
@@ -149,34 +149,34 @@ public class QuestManager extends BasePlayerManager {
|
||||
return mainQuest.getChildQuests().get(questId);
|
||||
}
|
||||
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
|
||||
getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(mainQuest));
|
||||
|
||||
@@ -200,14 +200,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
// Sub quest
|
||||
GameQuest quest = mainQuest.getChildQuestById(questId);
|
||||
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
|
||||
// Save main quest
|
||||
mainQuest.save();
|
||||
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
.filter(p -> p.getState() != QuestState.QUEST_STATE_UNSTARTED)
|
||||
.toList()));
|
||||
|
||||
@@ -230,12 +230,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
Grasscutter.getLogger().debug("Trigger Event {}, {}, {}", condType, paramStr, params);
|
||||
List<GameMainQuest> checkMainQuests = this.getMainQuests().values().stream()
|
||||
.filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
|
||||
.toList();
|
||||
switch(condType){
|
||||
switch (condType) {
|
||||
//accept Conds
|
||||
case QUEST_COND_STATE_EQUAL:
|
||||
case QUEST_COND_STATE_NOT_EQUAL:
|
||||
@@ -295,12 +295,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
default:
|
||||
Grasscutter.getLogger().error("Unhandled QuestTrigger {}", condType);
|
||||
}
|
||||
if(this.addToQuestListUpdateNotify.size() != 0){
|
||||
if (this.addToQuestListUpdateNotify.size() != 0) {
|
||||
this.getPlayer().getSession().send(new PacketQuestListUpdateNotify(this.addToQuestListUpdateNotify));
|
||||
this.addToQuestListUpdateNotify.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<QuestGroupSuite> getSceneGroupSuite(int sceneId) {
|
||||
return getMainQuests().values().stream()
|
||||
@@ -317,14 +317,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
for (GameMainQuest mainQuest : quests) {
|
||||
mainQuest.setOwner(this.getPlayer());
|
||||
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameMainQuest> getActiveMainQuests() {
|
||||
return getMainQuests().values().stream().filter(p -> !p.isFinished()).toList();
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_LUA_NOTIFY)
|
||||
public class ConditionLuaNotify extends QuestBaseHandler {
|
||||
//Wrong implementation. Example: 7010226 has no paramStr
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == Integer.parseInt(paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarEqual extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() == params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarGreater extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() > params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarLess extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() < params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_STATE_EQUAL)
|
||||
public class ConditionStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {
|
||||
/*
|
||||
@@ -22,6 +22,6 @@ public class ConditionStateEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
return checkQuest.getState().getValue() == condition.getParam()[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ADD_QUEST_PROGRESS)
|
||||
public class ContentAddQuestProgress extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
/*
|
||||
//paramStr is a lua group, params[0] may also be a lua group!
|
||||
questid = xxxxxx lua group = xxxxxxyy
|
||||
count seems relevant only for lua group
|
||||
*/
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ public class ContentCompleteAnyTalk extends QuestBaseHandler {
|
||||
return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK)
|
||||
public class ContentCompleteTalk extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(params[0] / 100);
|
||||
if (checkMainQuest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(condition.getParam()[0]);
|
||||
return talkData != null;
|
||||
|
||||
// This expression makes zero sense.
|
||||
// return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ENTER_DUNGEON)
|
||||
public class ContentEnterDungeon extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_FINISH_PLOT)
|
||||
public class ContentFinishPlot extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
MainQuestData.TalkData talkData = quest.getMainQuest().getTalks().get(Integer.valueOf(params[0]));
|
||||
GameQuest subQuest = quest.getMainQuest().getChildQuestById(params[0]);
|
||||
return talkData != null || subQuest != null;
|
||||
|
||||
@@ -9,11 +9,11 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL)
|
||||
public class ContentQuestStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {return false;}
|
||||
return checkQuest.getState().getValue() == params[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ public class ContentQuestStateNotEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ContentTriggerFire extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) {
|
||||
if(quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
if (quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
//We don't want to put a new key here
|
||||
return quest.getTriggers().get(quest.getTriggerNameById(params[0]));
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package emu.grasscutter.game.quest.enums;
|
||||
|
||||
public enum QuestState {
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
|
||||
// Used by lua
|
||||
NONE (0),
|
||||
@@ -14,13 +14,13 @@ public enum QuestState {
|
||||
FINISHED(3),
|
||||
FAILED(4);
|
||||
|
||||
private final int value;
|
||||
private final int value;
|
||||
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ public class ExecIncQuestGlobalVar extends QuestExecHandler {
|
||||
quest.getOwner().getQuestManager().incQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user