From e0a16aac979aa129227440a05929d89940f632e9 Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Tue, 8 Mar 2022 19:41:37 +0000 Subject: Add QPlayer::getEffectiveStartedQuests method --- .../com/leonardobishop/quests/common/player/QPlayer.java | 12 ++++++++++++ .../common/player/questprogressfile/QuestProgressFile.java | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'common/src/main/java/com') 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. @@ -73,6 +75,16 @@ public class QPlayer { return questController.hasPlayerStartedQuest(this, quest); } + /** + * Gets a list of quests which the player has effectively started. This includes quests started automatically. + * + * @return list of effectively started quests + */ + public List 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.) * 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 */ -- cgit v1.2.3-70-g09d2