summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java2
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java12
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java5
3 files changed, 16 insertions, 3 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java
index 07fc5c53..c2bd60de 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java
@@ -96,7 +96,7 @@ public class QuestsPlaceholders extends PlaceholderExpansion implements Cacheabl
case "started":
case "s":
//TODO cache started quests somewhere, or make a effective started method
- final List<Quest> listStarted = plugin.getQuestManager().getQuests().values().stream().filter(qPlayer::hasStartedQuest).collect(Collectors.toList());
+ final List<Quest> listStarted = qPlayer.getEffectiveStartedQuests();
result = (args.length == 1 ? String.valueOf(listStarted.size()) : parseList(listStarted, args[1], split));
break;
case "categories":
diff --git a/common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java b/common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java
index d8b40cce..3e775dca 100644
--- a/common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java
+++ b/common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java
@@ -8,8 +8,10 @@ import com.leonardobishop.quests.common.questcontroller.QuestController;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.List;
import java.util.Objects;
import java.util.UUID;
+import java.util.stream.Collectors;
/**
* Represents a player.
@@ -74,6 +76,16 @@ public class QPlayer {
}
/**
+ * Gets a list of quests which the player has effectively started. This includes quests started automatically.
+ *
+ * @return list of effectively started quests
+ */
+ public List<Quest> getEffectiveStartedQuests() {
+ // TODO this can be better
+ return plugin.getQuestManager().getQuests().values().stream().filter(q -> questController.hasPlayerStartedQuest(this, q)).collect(Collectors.toList());
+ }
+
+ /**
* Attempt to start a quest for the player. This will also play all effects (such as titles, messages etc.)
*
* Warning: will fail if the player is not online.
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 f390c2bd..4a740ee3 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
@@ -39,9 +39,10 @@ public class QuestProgressFile {
}
/**
- * Gets all started quests.
+ * Gets all manually started quests.
* Note: if quest autostart is enabled then this may produce unexpected results as quests are
- * not "started" by the player if autostart is true. Consider {@link QPlayer#hasStartedQuest(Quest)} instead.
+ * not "started" by the player if autostart is true. Consider {@link QPlayer#hasStartedQuest(Quest)}
+ * or {@link QPlayer#getEffectiveStartedQuests()} instead.
*
* @return list of started quests
*/