diff options
Diffstat (limited to 'common/src')
2 files changed, 31 insertions, 6 deletions
diff --git a/common/src/main/java/com/leonardobishop/quests/common/enums/QuestStartResult.java b/common/src/main/java/com/leonardobishop/quests/common/enums/QuestStartResult.java index 28d8a43c..4c493bf3 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/enums/QuestStartResult.java +++ b/common/src/main/java/com/leonardobishop/quests/common/enums/QuestStartResult.java @@ -1,13 +1,28 @@ package com.leonardobishop.quests.common.enums; public enum QuestStartResult { - QUEST_SUCCESS, //0 + QUEST_SUCCESS(true), //0 QUEST_LIMIT_REACHED, //1 QUEST_ALREADY_COMPLETED, //2 QUEST_COOLDOWN, //3 QUEST_LOCKED, //4 - QUEST_ALREADY_STARTED, //5 + QUEST_ALREADY_STARTED(true), //5 QUEST_NO_PERMISSION, //6 NO_PERMISSION_FOR_CATEGORY, //7 - OTHER //8 + OTHER; //8 + + private final boolean playerStartedQuest; + + QuestStartResult() { + this(false); + } + + QuestStartResult(boolean playerStartedQuest) { + this.playerStartedQuest = playerStartedQuest; + } + + public boolean hasPlayerStartedQuest() { + return playerStartedQuest; + } + } diff --git a/common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java b/common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java index 7b91903c..6a6d71d0 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java +++ b/common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java @@ -92,7 +92,7 @@ public class QuestProgressFile { COMPLETED_BEFORE("completedBefore"), STARTED("started"); - private String legacy; + private final String legacy; QuestsProgressFilter(String legacy) { this.legacy = legacy; @@ -197,10 +197,10 @@ public class QuestProgressFile { } /** - * Get the {@link QuestProgress} for a specified {@link Quest}, and generates a new one if it does not exist. + * Get the {@link QuestProgress} for a specified {@link Quest}. Generates a new one if it does not exist. * * @param quest the quest to get progress for - * @return {@link QuestProgress} or null if the quest does not exist + * @return {@link QuestProgress} or a blank generated one if the quest does not exist */ public QuestProgress getQuestProgress(Quest quest) { if (questProgress.containsKey(quest.getId())) { @@ -211,6 +211,16 @@ public class QuestProgressFile { } /** + * Tests whether or not the player has a specified {@link Quest} started. + * + * @param quest the quest to check for + * @return true if player has the quest started + */ + public boolean hasQuestStarted(Quest quest) { + return questProgress.containsKey(quest.getId()) && questProgress.get(quest.getId()).isStarted(); + } + + /** * Generate a new blank {@link QuestProgress} for a specified {@code quest}. * * @param quest the quest to generate progress for |
