Class AdvancementManager

java.lang.Object
eu.endercentral.crazy_advancements.manager.AdvancementManager

public final class AdvancementManager extends Object
Represents a Manager that manages Players and Advancements
Author:
Axel
  • Constructor Details

    • AdvancementManager

      public AdvancementManager(NameKey name, Player... players)
      Constructor for creating Advancement Managers
      Parameters:
      name - The Name of the Manager
      players - All players that should be in the new manager from the start, can be changed at any time
  • Method Details

    • getAccessibleManager

      public static AdvancementManager getAccessibleManager(NameKey name)
      Gets an accessible Advancement Manager by it's Name
      Parameters:
      name - The Name of the Manager
      Returns:
      the Manager or null if no matching Manager is found
    • getAccessibleManagers

      public static Collection<AdvancementManager> getAccessibleManagers()
      Gets a list of all accessible Advancement Managers
      Returns:
      A list of all accessible Advancement Managers
    • getName

      public NameKey getName()
      Returns the Name of this Manager
      Returns:
      The Name
    • addPlayer

      public void addPlayer(Player player)
      Adds a player to the manager
      Parameters:
      player - Player to add
    • removePlayer

      public void removePlayer(Player player)
      Removes a player from the manager
      Parameters:
      player - Player to remove
    • getPlayers

      public ArrayList<Player> getPlayers()
      Get a list of players in the Manager
      Returns:
      All players that have been added to the manager
    • addAdvancement

      public void addAdvancement(Advancement... addedAdvancements)
      Adds advancements to the Manager
      Duplicates will be discarded
      Parameters:
      addedAdvancements - An array of all advancements that should be added
    • updateAdvancement

      public void updateAdvancement(Advancement... updatedAdvancements)
      Updates advancements in this manager
      Parameters:
      updatedAdvancements - The advancements that should be updated
    • removeAdvancement

      public void removeAdvancement(Advancement... removedAdvancements)
      Removes an advancement from the Manager
      Parameters:
      removedAdvancements - An array of advancements that should be removed
    • getAdvancements

      public ArrayList<Advancement> getAdvancements()
      Gets a list of Advancements in the Manager
      Returns:
      The list of Advancements
    • getAdvancements

      public ArrayList<Advancement> getAdvancements(String namespace)
      Gets a list of Advancements with a certain namespace
      Parameters:
      namespace - Namespace to check
      Returns:
      A list of all advancements in the manager with a specified namespace
    • getAdvancement

      public Advancement getAdvancement(NameKey name)
      Gets an Advancement with a specified Name
      Parameters:
      name - Name to check
      Returns:
      An advancement matching the given name or null if it doesn't exist in the AdvancementManager
    • makeAccessible

      public void makeAccessible()
      Makes the AdvancementManager accessible to commands and other plugins using it's Name
      There can only be one Manager per Name
    • resetAccessible

      public void resetAccessible()
      Resets Accessibility-Status
    • updateTab

      public void updateTab(Player player, NameKey tab)
      Updates all Advancements in a Tab
      If you have Advancements in different tabs
      Parameters:
      player - The target Player
      tab - The tab to update
    • updateProgress

      public void updateProgress(Player player, Advancement... advancements)
      Updates Advancement Progress for a Player
      Parameters:
      player - The target Player
      advancements - An array of Advancements that need their progress updated
    • updateVisibility

      public void updateVisibility(Player player)
      Updates Visibility for Advancements in this Manager
      Parameters:
      player - The target Player
    • grantAdvancement

      public GenericResult grantAdvancement(Player player, Advancement advancement)
      Grants an advancement
      Parameters:
      player - Reciever
      advancement - Advancement to grant
      Returns:
      The Result of this operation
    • grantAdvancement

      public GenericResult grantAdvancement(UUID uuid, Advancement advancement)
      Grants an advancement, also works with offline players
      Parameters:
      uuid - Receiver UUID
      advancement - Advancement to grant
      Returns:
      The Result of this operation
    • revokeAdvancement

      public GenericResult revokeAdvancement(Player player, Advancement advancement)
      Revokes an advancement
      Parameters:
      player - Receiver
      advancement - Advancement to revoke
      Returns:
      The Result of this operation
    • revokeAdvancement

      public GenericResult revokeAdvancement(UUID uuid, Advancement advancement)
      Revokes an advancement, also works with offline players
      Parameters:
      uuid - Receiver UUID
      advancement - Advancement to revoke
      Returns:
      The Result of this operation
    • grantCriteria

      public GrantCriteriaResult grantCriteria(Player player, Advancement advancement, String... criteria)
      Grants criteria for an advancement
      Parameters:
      player - Receiver
      advancement - The Advancement
      criteria - Array of criteria to grant
      Returns:
      The Result of this operation
    • grantCriteria

      public GrantCriteriaResult grantCriteria(UUID uuid, Advancement advancement, String... criteria)
      Grans criteria for an advancement, also works with offline players
      Parameters:
      uuid - Receiver
      advancement - The Advancement
      criteria - Array of criteria to grant
      Returns:
      The Result of this operation
    • revokeCriteria

      public GenericResult revokeCriteria(Player player, Advancement advancement, String... criteria)
      Revokes criteria for an advancement
      Parameters:
      player - Receiver
      advancement - The Advancement
      criteria - Array of criteria to revoke
      Returns:
      The Result of this operation
    • revokeCriteria

      public GenericResult revokeCriteria(UUID uuid, Advancement advancement, String... criteria)
      Revokes criteria for an advancement, also works with offline players
      Parameters:
      uuid - Receiver
      advancement - The Advancement
      criteria - Array of criteria to revoke
      Returns:
      The Result of this operation
    • setCriteriaProgress

      public SetCriteriaResult setCriteriaProgress(Player player, Advancement advancement, int criteriaProgress)
      Sets the criteria progress for an advancement
      Only works for Advancements with CriteriaType Number and will return SetCriteriaResult INVALID if it doesn't match
      Parameters:
      player - Receiver
      advancement - The Advancement
      criteriaProgress - Amount of progress
      Returns:
      The Result of this operation
    • setCriteriaProgress

      public SetCriteriaResult setCriteriaProgress(UUID uuid, Advancement advancement, int criteriaProgress)
      Sets the criteria progress for an advancement, also works with offline players
      Only works for Advancements with CriteriaType NUMBER and will return SetCriteriaResult INVALID if it doesn't match
      Parameters:
      uuid - Receiver
      advancement - The Advancement
      criteriaProgress - Array of criteria to revoke
      Returns:
      The Result of this operation
    • getCriteriaProgress

      public int getCriteriaProgress(Player player, Advancement advancement)
      Gets the Criteria Progress
      Parameters:
      player - The target Player
      advancement - The Advancement
      Returns:
      The criteria progress
    • getCriteriaProgress

      public int getCriteriaProgress(UUID uuid, Advancement advancement)
      Gets the Criteria Progress
      Parameters:
      uuid - The target Player
      advancement - The Advancement
      Returns:
      The criteria progress
    • createNewSave

      public SaveFile createNewSave(Player player, Advancement... advancements)
      Gets the Progress as JSON
      Parameters:
      player - Player to check
      advancements - A list of advancements that will have their progress saved- Leave empty if all Advancements should be saved
      Returns:
      A JSON String representation of the progress for a player
    • createNewSave

      public SaveFile createNewSave(UUID uuid, Advancement... advancements)
      Gets the Progress as JSON
      Parameters:
      uuid - UUID of Player to check
      advancements - A list of advancements that will have their progress saved- Leave empty if all Advancements should be saved
      Returns:
      A JSON String representation of the progress for a player
    • saveProgress

      public void saveProgress(Player player, Advancement... advancements)
      Saves the progress in this Advancement Managers file
      Parameters:
      player - Player to save
      advancements - A list of advancements that will have their progress saved- Leave empty if all Advancements should be saved
    • saveProgress

      public void saveProgress(UUID uuid, Advancement... advancements)
      Saves the progress in this Advancement Managers file
      Parameters:
      uuid - UUID of Player to save
      advancements - A list of advancements that will have their progress saved- Leave empty if all Advancements should be saved
    • loadProgress

      public void loadProgress(Player player, Advancement... advancements)
      Loads the progress for Advancements in this Manager
      Parameters:
      player - Player to load
      advancements - A list of advancements that will have their progress loaded - Leave empty if all Advancements should be loaded
    • loadProgress

      public void loadProgress(UUID uuid, Advancement... advancements)
      Loads the progress for Advancements in this Manager
      Parameters:
      uuid - UUID of Player to load
      advancements - A list of advancements that will have their progress loaded - Leave empty if all Advancements should be loaded
    • loadProgress

      public void loadProgress(Player player, SaveFile saveFile, Advancement... advancements)
      Loads the progress for Advancements in this Manager
      Parameters:
      player - Player to load
      saveFile - The Save File to be loaded from
      advancements - A list of advancements that will have their progress loaded - Leave empty if all Advancements should be loaded
    • loadProgress

      public void loadProgress(UUID uuid, SaveFile saveFile, Advancement... advancements)
      Loads the progress for Advancements in this Manager
      Parameters:
      uuid - UUID of Player to load
      saveFile - The Save File to be loaded from
      advancements - A list of advancements that will have their progress loaded - Leave empty if all Advancements should be loaded
    • unloadProgress

      public void unloadProgress(Player player, Advancement... advancements)
      Unloads progress for Advancements in this Manager
      Parameters:
      player - Player to unload
      advancements - A list of advancements that will have their progress unloaded - Leave empty if all Advancements should be unloaded
    • unloadProgress

      public void unloadProgress(UUID uuid, Advancement... advancements)
      Unloads progress for Advancements in this Manager
      Parameters:
      uuid - UUID of Player to unload
      advancements - A list of advancements that will have their progress unloaded - Leave empty if all Advancements should be unloaded
    • unloadVisibilityStatus

      public void unloadVisibilityStatus(Player player, Advancement... advancements)
      Unloads the Visibility Status for Advancements in this Manager
      Parameters:
      player - Player to unload
      advancements - A list of advancements that will have their Visibility Status unloaded - Leave empty if all Advancements should be unloaded
    • unloadVisibilityStatus

      public void unloadVisibilityStatus(UUID uuid, Advancement... advancements)
      Unloads the Visibility Status for Advancements in this Manager
      Parameters:
      uuid - UUID of Player to unload
      advancements - A list of advancements that will have their Visibility Status unloaded - Leave empty if all Advancements should be unloaded