diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2022-03-08 19:41:37 +0000 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2022-03-08 19:41:37 +0000 |
| commit | e0a16aac979aa129227440a05929d89940f632e9 (patch) | |
| tree | 422907803254db1e7affabfada1c1a654133f1a4 /common/src/main/java/com/leonardobishop | |
| parent | f61b8a7343f0dac47a4b93e185c0e05053ee4eb2 (diff) | |
Add QPlayer::getEffectiveStartedQuests method
Diffstat (limited to 'common/src/main/java/com/leonardobishop')
| -rw-r--r-- | common/src/main/java/com/leonardobishop/quests/common/player/QPlayer.java | 12 | ||||
| -rw-r--r-- | common/src/main/java/com/leonardobishop/quests/common/player/questprogressfile/QuestProgressFile.java | 5 |
2 files changed, 15 insertions, 2 deletions
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 */ |
