summaryrefslogtreecommitdiffstats
path: root/common/src/main/java/com
diff options
context:
space:
mode:
authorKrakenied <Krakenied1@gmail.com>2022-12-12 18:09:13 +0100
committerKrakenied <Krakenied1@gmail.com>2022-12-17 18:01:31 +0100
commit606f421a376493b7de65291d6cebda90bed4a5f8 (patch)
tree295108f1dcd823e5f3257c175b65424918767f02 /common/src/main/java/com
parentbf20ca900b8a581ed84d97697572753c169c541b (diff)
Optimize debug logging a little more
More improvements (https://github.com/LMBishop/Quests/issues/452)
Diffstat (limited to 'common/src/main/java/com')
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/enums/QuestStartResult.java21
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java16
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