From d957222304135606195076fbc1c8af015a1afb9c Mon Sep 17 00:00:00 2001 From: markbmullins Date: Sun, 6 Dec 2020 10:45:43 -0500 Subject: [PATCH 1/3] Fixed error when opening quest journal --- src/plugins/quests/quest-journal-plugin.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/quests/quest-journal-plugin.ts b/src/plugins/quests/quest-journal-plugin.ts index 090eaf07f..c4b1eeb82 100644 --- a/src/plugins/quests/quest-journal-plugin.ts +++ b/src/plugins/quests/quest-journal-plugin.ts @@ -5,17 +5,19 @@ import { pluginActions } from '@server/game-server'; export const action: buttonAction = (details) => { const { player, buttonId } = details; + const [questData] = pluginActions.quest.filter((quest) => quest.quest.questTabId === buttonId); + const quest = questData.quest; - const quests = pluginActions.quest; - const questData = quests[Object.keys(quests).filter(questKey => quests[questKey].questTabId === buttonId)[0]]; - const playerQuest = player.quests.find(quest => quest.questId === questData.id); - let playerStage = 'NOT_STARTED'; + const [playerQuest] = player.quests.filter( + (playerQuest) => playerQuest.questId === quest.questTabId + ); - if(playerQuest && playerQuest.stage) { - playerStage = playerQuest.stage; + let playerStage = "NOT_STARTED"; + if (playerQuest && playerQuest.stage) { + playerStage = playerQuest.stage; } - let stageText = questData.stages[playerStage]; + let stageText = quest.stages[playerStage]; let color = 128; if(typeof stageText === 'function') { @@ -32,7 +34,7 @@ export const action: buttonAction = (details) => { lines = [ 'Invalid Quest Stage' ]; } - player.modifyWidget(widgets.questJournal, { childId: 2, text: '@dre@' + questData.name }); + player.modifyWidget(widgets.questJournal, { childId: 2, text: '@dre@' + quest.name }); for(let i = 0; i <= 100; i++) { if(i === 0) { From 2130181df5667ec132681da5455e6bb25b2c21ce Mon Sep 17 00:00:00 2001 From: markbmullins Date: Sun, 6 Dec 2020 10:46:47 -0500 Subject: [PATCH 2/3] Fixing formatting issues --- src/plugins/quests/quest-journal-plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/quests/quest-journal-plugin.ts b/src/plugins/quests/quest-journal-plugin.ts index c4b1eeb82..4294d73e4 100644 --- a/src/plugins/quests/quest-journal-plugin.ts +++ b/src/plugins/quests/quest-journal-plugin.ts @@ -9,12 +9,12 @@ export const action: buttonAction = (details) => { const quest = questData.quest; const [playerQuest] = player.quests.filter( - (playerQuest) => playerQuest.questId === quest.questTabId + (playerQuest) => playerQuest.questId === quest.questTabId ); let playerStage = "NOT_STARTED"; if (playerQuest && playerQuest.stage) { - playerStage = playerQuest.stage; + playerStage = playerQuest.stage; } let stageText = quest.stages[playerStage]; From 179570b5866ec8b808d2adea56a154b89088e2ff Mon Sep 17 00:00:00 2001 From: markbmullins Date: Sun, 6 Dec 2020 10:52:27 -0500 Subject: [PATCH 3/3] Added guard clause for when quest doesn't exist --- src/plugins/quests/quest-journal-plugin.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/quests/quest-journal-plugin.ts b/src/plugins/quests/quest-journal-plugin.ts index 4294d73e4..2c025f364 100644 --- a/src/plugins/quests/quest-journal-plugin.ts +++ b/src/plugins/quests/quest-journal-plugin.ts @@ -6,6 +6,9 @@ import { pluginActions } from '@server/game-server'; export const action: buttonAction = (details) => { const { player, buttonId } = details; const [questData] = pluginActions.quest.filter((quest) => quest.quest.questTabId === buttonId); + if(!questData) { + return; + } const quest = questData.quest; const [playerQuest] = player.quests.filter(