Interface CosmeticPlayer


public interface CosmeticPlayer
Represents the stored info of a player regarding cosmetics.
  • Method Details

    • getOwnerships

      Get all the items the player owns.
      Returns:
      The items the player owns
    • getOwnership

      @Nullable @Nullable CosmeticItemOwnership getOwnership(CosmeticItem item)
      Get the ownership of a given item.
      Parameters:
      item - The item to get the ownership of
      Returns:
      The ownership of the item or null if the player does not own it
    • hasOwnership

      boolean hasOwnership(CosmeticItem item)
      Checks whether the player owns (is allowed to use) a given item.
      Parameters:
      item - The item to check
      Returns:
      true if the player owns the item, false otherwise
    • removeOwnership

      boolean removeOwnership(CosmeticItemOwnership ownership)
      Remove the ownership of a given item.
      Parameters:
      ownership - The ownership to remove
      Returns:
      true if the ownership was found and removed removed, false otherwise
    • addOwnership

      boolean addOwnership(CosmeticItemOwnership ownership)
      Add a new ownership to the player.

      It may fail if the player already has an ownership for that item, and the cause of that one weights greater than the new one (see CosmeticItemOwnership.Cause.weightsGreaterThan(CosmeticItemOwnership.Cause)).

      Parameters:
      ownership - The ownership to add
      Returns:
      true if the ownership was added, false if it failed
      See Also:
    • getActive

      Collection<CosmeticItem> getActive()
      Get the active cosmetic item of the player.

      Since only one item can be active at a time per category, this method will not return multiple items of the same category.

      Returns:
      The active cosmetic items of the player
    • getActive

      @Nullable @Nullable CosmeticItem getActive(CosmeticItemCategory category)
      Get the active cosmetic item of the player for a given category.
      Parameters:
      category - The category to get the active item of
      Returns:
      The active cosmetic item of the player for the given category. null if none is set
    • setActive

      void setActive(CosmeticItem item)
      Set the active cosmetic item of the player.

      It is legal to set an active the player doesn't even have ownership to, although it will not be persisted with the next re-log.

      Parameters:
      item - The item to set as active
    • unsetActive

      void unsetActive(CosmeticItemCategory category)
      Removes the active cosmetic item of the player.
      Parameters:
      category - The category to unset the active item of
    • updatePermissiveItems

      int updatePermissiveItems()
      Update the items that are locked or free through permissions.

      The given items are cached to avoid unnecessary requests to the permission system. Call this method in case you have changed the permissions of the player related to cosmetic items.

      This method has no effect if the player is not online.

      Returns:
      The number of items that have been updated
    • save

      void save()
      Saves the current cosmetic data of the player.

      This is an async operation and thereby may not be processed immediately.