Interface CosmeticPlayer
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddOwnership(CosmeticItemOwnership ownership) Add a new ownership to the player.Get the active cosmetic item of the player.@Nullable CosmeticItemgetActive(CosmeticItemCategory category) Get the active cosmetic item of the player for a given category.@Nullable CosmeticItemOwnershipgetOwnership(CosmeticItem item) Get the ownership of a given item.Get all the items the player owns.@Nullable ActionDatagetPlayActionData(CosmeticItemCategory category) Get the action data that should be played when the event of the category occurs.booleanhasOwnership(CosmeticItem item) Checks whether the player owns (is allowed to use) a given item.booleanisBroken()Get whether there was an error while loading the player's data.booleanremoveOwnership(CosmeticItemOwnership ownership) Remove the ownership of a given item.voidsave()Saves the current cosmetic data of the player.voidsetActive(CosmeticItem item) Set the active cosmetic item of the player.voidunsetActive(CosmeticItemCategory category) Removes the active cosmetic item of the player.intUpdate the items that are locked or free through permissions.
-
Method Details
-
getOwnerships
Collection<CosmeticItemOwnership> getOwnerships()Get all the items the player owns.- Returns:
- The items the player owns
-
getOwnership
Get the ownership of a given item.- Parameters:
item- The item to get the ownership of- Returns:
- The ownership of the item or
nullif the player does not own it
-
hasOwnership
Checks whether the player owns (is allowed to use) a given item.- Parameters:
item- The item to check- Returns:
trueif the player owns the item,falseotherwise
-
removeOwnership
Remove the ownership of a given item.- Parameters:
ownership- The ownership to remove- Returns:
trueif the ownership was found and removed removed,falseotherwise
-
addOwnership
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:
trueif the ownership was added,falseif 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
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.
nullif none is set
-
setActive
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
-
getPlayActionData
Get the action data that should be played when the event of the category occurs.If the active's item behavior is
CosmeticItemBehaviour.SET_ACTIVE, it will simply returnCosmeticItem.getActionData()of the active item. In the case ofCosmeticItemBehaviour.PLAY_RANDOM, it will return a random action data of one of the owned items in the category.- Parameters:
category- The category to get the play action data of- Returns:
- The action data to play or
nullif none is set
-
unsetActive
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
-
isBroken
boolean isBroken()Get whether there was an error while loading the player's data.This is a safety measure to avoid overriding player data. It is recommended to not handle this case in your code.
- Returns:
trueif there was an error while loading the data,falseotherwise
-
save
void save()Saves the current cosmetic data of the player.This is an async operation and thereby may not be processed immediately.
It may not actually do something if
isBroken()istrue.
-