Class PlayerQuests

java.lang.Object
com.ordwen.odailyquests.quests.player.PlayerQuests

public class PlayerQuests extends Object
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 Details

    • PlayerQuests

      public PlayerQuests(Long timestamp, Map<AbstractQuest,Progression> quests)
      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

      public Long getTimestamp()
      Gets the player's timestamp.
      Returns:
      the timestamp of the player's last quest renew.
    • increaseCategoryAchievedQuests

      public void increaseCategoryAchievedQuests(String category, org.bukkit.entity.Player player)
      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, the AllQuestsCompletedEvent 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

      public void setTotalCategoryAchievedQuests(String category, int i)
      Set total number of achieved quests for a specific category.
      Parameters:
      category - the category name.
      i - number of achieved quests to set.
    • setTotalAchievedQuestsByCategory

      public void setTotalAchievedQuestsByCategory(Map<String,Integer> totals)
      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

      public void addTotalCategoryAchievedQuests(String category, int amount)
      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

      public void removeTotalCategoryAchievedQuests(String category, int amount)
      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

      public Map<AbstractQuest,Progression> getQuests()
      Get player quests.
      Returns:
      a LinkedHashMap of quests and their progression.
    • getTotalAchievedQuestsByCategory

      public Map<String,Integer> getTotalAchievedQuestsByCategory()
      Get total achieved quests for all categories.
      Returns:
      a map of total achieved quests by category.
    • getTotalAchievedQuestsByCategory

      public int getTotalAchievedQuestsByCategory(String category)
      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.