Class PlayerQuests
java.lang.Object
com.ordwen.odailyquests.quests.player.PlayerQuests
Represents the player's quests and their associated data.
This class keeps track of the quests a player has completed, including the total number of completed quests, quests achieved in each category, and handles quest progression and rerolling of quests.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerQuests
(Long timestamp, Map<AbstractQuest, Progression> quests) Constructs a new PlayerQuests object with the provided timestamp and a map of quests with their progress. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTotalAchievedQuests
(int i) Add number of achieved quests.void
addTotalCategoryAchievedQuests
(String category, int amount) Add the number of achieved quests for a specific category.void
Decreases the number of achieved quests by 1.int
Get number of achieved quests.Get player quests.Gets the player's timestamp.int
Get total number of achieved quests.Get total achieved quests for all categories.int
getTotalAchievedQuestsByCategory
(String category) Get the number of total achieved quests for a specific category.void
increaseCategoryAchievedQuests
(String category, org.bukkit.entity.Player player) Increases the number of achieved quests for a given category.void
removeTotalAchievedQuests
(int i) Remove number of achieved quests.void
removeTotalCategoryAchievedQuests
(String category, int amount) Subtract the number of achieved quests for a specific category.boolean
rerollQuest
(int index, org.bukkit.entity.Player player) Rerolls a quest for the player.void
setAchievedQuests
(int i) Set number of achieved quests.void
setTotalAchievedQuests
(int i) Set total number of achieved quests.void
setTotalAchievedQuestsByCategory
(Map<String, Integer> totals) Set total achieved quests for all categories.void
setTotalCategoryAchievedQuests
(String category, int i) Set total number of achieved quests for a specific category.
-
Constructor Details
-
PlayerQuests
Constructs a new PlayerQuests object with the provided timestamp and a map of quests with their progress.- Parameters:
timestamp
- the last time the player's quests were renewed.quests
- a map of quests and their respective progression.
-
-
Method Details
-
getTimestamp
Gets the player's timestamp.- Returns:
- the timestamp of the player's last quest renew.
-
increaseCategoryAchievedQuests
Increases the number of achieved quests for a given category.If all quests from the category are completed, the
AllCategoryQuestsCompletedEvent
is triggered. If the player has completed all quests, theAllQuestsCompletedEvent
is triggered.- Parameters:
category
- the category of the quest completed.player
- the player who achieved the quest.
-
rerollQuest
public boolean rerollQuest(int index, org.bukkit.entity.Player player) Rerolls a quest for the player.A quest is rerolled only if it has not been achieved, and a new quest is assigned from the same category.
If the player has achieved the quest, rerolling is prevented, and a message is sent to the player.
- Parameters:
index
- the index of the quest to reroll.player
- the player for whom the quest is being rerolled.- Returns:
true
if the reroll was successful,false
otherwise.
-
decreaseAchievedQuests
public void decreaseAchievedQuests()Decreases the number of achieved quests by 1. -
setAchievedQuests
public void setAchievedQuests(int i) Set number of achieved quests.- Parameters:
i
- number of achieved quests to set.
-
setTotalAchievedQuests
public void setTotalAchievedQuests(int i) Set total number of achieved quests.- Parameters:
i
- total number of achieved quests to set.
-
setTotalCategoryAchievedQuests
Set total number of achieved quests for a specific category.- Parameters:
category
- the category name.i
- number of achieved quests to set.
-
setTotalAchievedQuestsByCategory
Set total achieved quests for all categories.- Parameters:
totals
- a map of total achieved quests by category.
-
addTotalAchievedQuests
public void addTotalAchievedQuests(int i) Add number of achieved quests.- Parameters:
i
- number of achieved quests to add.
-
addTotalCategoryAchievedQuests
Add the number of achieved quests for a specific category.- Parameters:
category
- the category name.amount
- the number of quests to add.
-
removeTotalAchievedQuests
public void removeTotalAchievedQuests(int i) Remove number of achieved quests.- Parameters:
i
- number of achieved quests to remove.
-
removeTotalCategoryAchievedQuests
Subtract the number of achieved quests for a specific category.- Parameters:
category
- the category name.amount
- the number of quests to subtract.
-
getAchievedQuests
public int getAchievedQuests()Get number of achieved quests. -
getTotalAchievedQuests
public int getTotalAchievedQuests()Get total number of achieved quests. -
getQuests
Get player quests.- Returns:
- a LinkedHashMap of quests and their progression.
-
getTotalAchievedQuestsByCategory
Get total achieved quests for all categories.- Returns:
- a map of total achieved quests by category.
-
getTotalAchievedQuestsByCategory
Get the number of total achieved quests for a specific category.- Parameters:
category
- the category name.- Returns:
- the number of total achieved quests for the specified category.
-