From 1634a5c6964f8f11b1407028717906f519844e60 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Tue, 2 May 2023 22:45:27 -0400 Subject: [PATCH] Clean-up (while attempting to fix) --- .../emu/grasscutter/game/quest/GameQuest.java | 24 +++++++++++-------- .../grasscutter/game/quest/QuestManager.java | 11 ++++++--- .../quest/exec/ExecChangeAvatarElemet.java | 6 ++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index 1d5ae6ebc..911b566cd 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -64,27 +64,30 @@ public class GameQuest { } public void start() { - clearProgress(false); + this.clearProgress(false); this.acceptTime = Utils.getCurrentSeconds(); this.startTime = this.acceptTime; this.startGameDay = getOwner().getWorld().getTotalGameTimeDays(); this.state = QuestState.QUEST_STATE_UNFINISHED; + val triggerCond = questData.getFinishCond().stream() .filter(p -> p.getType() == QuestContent.QUEST_CONTENT_TRIGGER_FIRE) .toList(); if (triggerCond.size() > 0) { for (val cond : triggerCond) { - TriggerExcelConfigData newTrigger = - GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]); + var newTrigger = GameData.getTriggerExcelConfigDataMap() + .get(cond.getParam()[0]); if (newTrigger != null) { if (this.triggerData == null) { this.triggerData = new HashMap<>(); } + triggerData.put(newTrigger.getTriggerName(), newTrigger); triggers.put(newTrigger.getTriggerName(), false); - SceneGroup group = SceneGroup.of(newTrigger.getGroupId()).load(newTrigger.getSceneId()); - getOwner() + var group = SceneGroup.of(newTrigger.getGroupId()) + .load(newTrigger.getSceneId()); + this.getOwner() .getWorld() .getSceneById(newTrigger.getSceneId()) .loadTriggerFromGroup(group, newTrigger.getTriggerName()); @@ -92,10 +95,10 @@ public class GameQuest { } } - getOwner().sendPacket(new PacketQuestListUpdateNotify(this)); + this.getOwner().sendPacket(new PacketQuestListUpdateNotify(this)); if (ChapterData.getBeginQuestChapterMap().containsKey(subQuestId)) { - getOwner() + this.getOwner() .sendPacket( new PacketChapterStateNotify( ChapterData.getBeginQuestChapterMap().get(subQuestId).getId(), @@ -106,10 +109,11 @@ public class GameQuest { // different MainQuests) this.triggerStateEvents(); - getQuestData() + this.getQuestData() .getBeginExec() - .forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam())); - getOwner().getQuestManager().checkQuestAlreadyFullfilled(this); + .forEach(e -> getOwner().getServer().getQuestSystem() + .triggerExec(this, e, e.getParam())); + this.getOwner().getQuestManager().checkQuestAlreadyFullfilled(this); Grasscutter.getLogger().debug("Quest {} is started", subQuestId); this.save(); diff --git a/src/main/java/emu/grasscutter/game/quest/QuestManager.java b/src/main/java/emu/grasscutter/game/quest/QuestManager.java index 8d8322ad7..df5b5d337 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestManager.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestManager.java @@ -33,7 +33,7 @@ import static emu.grasscutter.config.Configuration.GAME_OPTIONS; public class QuestManager extends BasePlayerManager { @Getter private final Player player; @Getter private final Int2ObjectMap mainQuests; - @Transient @Getter private final IntList loggedQuests; + @Transient @Getter private final List loggedQuests; private long lastHourCheck = 0; private long lastDayCheck = 0; @@ -109,7 +109,7 @@ public class QuestManager extends BasePlayerManager { this.player = player; this.mainQuests = new Int2ObjectOpenHashMap<>(); - this.loggedQuests = new IntArrayList(); + this.loggedQuests = new ArrayList<>(); if (DEBUG) { this.loggedQuests.addAll(List.of( @@ -122,9 +122,13 @@ public class QuestManager extends BasePlayerManager { 46904, // Quest which is required to be started, but not completed for 31101's talks to begin. // This quest is related to obtaining your first Anemoculus. - 35104 // Quest which is required to be finished for 46904 to begin. + 35104, // Quest which is required to be finished for 46904 to begin. // This quest requires 31101 not be finished. // This quest should be accepted when the account is created. + + // These quests currently have bugged triggers. + 30700, // Quest which is responsible for unlocking Crash Course. + 30800 // Quest which is responsible for unlocking Sparks Amongst the Pages. )); } } @@ -396,6 +400,7 @@ public class QuestManager extends BasePlayerManager { public void queueEvent(QuestContent condType, String paramStr, int... params) { eventExecutor.submit(() -> triggerEvent(condType, paramStr, params)); } + public void queueEvent(QuestCond condType, String paramStr, int... params) { eventExecutor.submit(() -> triggerEvent(condType, paramStr, params)); } diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecChangeAvatarElemet.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecChangeAvatarElemet.java index 6e76bced3..1472e7c8a 100644 --- a/src/main/java/emu/grasscutter/game/quest/exec/ExecChangeAvatarElemet.java +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecChangeAvatarElemet.java @@ -9,7 +9,7 @@ import emu.grasscutter.game.quest.enums.QuestExec; import emu.grasscutter.game.quest.handlers.QuestExecHandler; import lombok.val; -/** Changes the main avatar's element. First parameter is the elementType id */ +/** Changes the main avatar's element. First parameter is the elementType ID. */ @QuestValueExec(QuestExec.QUEST_EXEC_CHANGE_AVATAR_ELEMET) public class ExecChangeAvatarElemet extends QuestExecHandler { @Override @@ -25,8 +25,8 @@ public class ExecChangeAvatarElemet extends QuestExecHandler { } Grasscutter.getLogger() - .info( - "Changing avatar element to {} for quest {}", + .debug( + "Changing avatar element to {} for quest {}.", targetElement.name(), quest.getSubQuestId()); return mainAvatar.changeElement(targetElement);