Package net.skinsrestorer.api.storage
Interface SkinStorage
public interface SkinStorage
There are three types of skins:
- Player skins
- URL skins
- Custom skins
URL skins additionally store an "index"; an index is the skin variant that was generated by MineSkin. That means when you type an url, we'll know whether to automatically choose the slim or classic variant. The user has the option to override the default "index variant" using the command /skin set url variant
A player-skin is stored using the target player's UUID. This way we can, for example, keep using the skin of "Dinnerbone" even if he changes his name to "Spoiledbone". A player-skin may be fetched again if the skin data is outdated. (By timestamp)
A custom skin is stored using the custom skin name. It will never be updated automatically.
URL skins additionally store an "index"; an index is the skin variant that was generated by MineSkin. That means when you type an url, we'll know whether to automatically choose the slim or classic variant. The user has the option to override the default "index variant" using the command /skin set url variant
A player-skin is stored using the target player's UUID. This way we can, for example, keep using the skin of "Dinnerbone" even if he changes his name to "Spoiledbone". A player-skin may be fetched again if the skin data is outdated. (By timestamp)
A custom skin is stored using the custom skin name. It will never be updated automatically.
-
Method Summary
Modifier and TypeMethodDescriptionfindOrCreateSkinData
(String input) Searches a skin in the database by name/url.findSkinData
(String input) Searches a skin in the database by name/url.getPlayerSkin
(String playerName, boolean allowExpired) Gets the skin data of a Mojang player by name using the UUID cache.getSkinDataByIdentifier
(SkinIdentifier identifier) Searches a skin in the database by its skin identifier.void
removeSkinData
(SkinIdentifier identifier) Removes a skin from the database by its skin identifier.void
setCustomSkinData
(String skinName, SkinProperty textures) Saves a custom skin to the database.void
setPlayerSkinData
(UUID uuid, String lastKnownName, SkinProperty textures, long timestamp) Saves a player skin to the database.default void
setURLSkinByResponse
(String url, MineSkinResponse response) Saves an url to the database using a MineSkinResponse object.void
setURLSkinData
(String url, String mineSkinId, SkinProperty textures, SkinVariant skinVariant) Saves an url skin to the database.void
setURLSkinIndex
(String url, SkinVariant skinVariant) Saves an url index to the database.updatePlayerSkinData
(UUID uuid) This method returns the updated skin property associated to the player skin by UUID.
-
Method Details
-
updatePlayerSkinData
This method returns the updated skin property associated to the player skin by UUID. This will always request the latest skin data from Mojang directly no matter whether it's expired or not.- Parameters:
uuid
- Player UUID- Returns:
- The skin property containing the skin data
- Throws:
DataRequestException
- If MojangAPI lookup errors (e.g. premium player not found)
-
getPlayerSkin
Optional<MojangSkinDataResult> getPlayerSkin(String playerName, boolean allowExpired) throws DataRequestException Gets the skin data of a Mojang player by name using the UUID cache. This will cache the UUID if it's not already cached and will cache the skin data.- Parameters:
playerName
- Player name to search forallowExpired
- Allow expired data to be returned- Returns:
- The skin data of the player or empty if no such player exists
- Throws:
DataRequestException
- If the data could not be retrieved
-
setPlayerSkinData
Saves a player skin to the database.- Parameters:
uuid
- Player UUIDlastKnownName
- Last known name of the playertextures
- Property objecttimestamp
- timestamp string in milliseconds
-
setURLSkinData
Saves an url skin to the database.- Parameters:
url
- URL to skinmineSkinId
- MineSkin IDtextures
- Property objectskinVariant
- Skin variant
-
setURLSkinIndex
Saves an url index to the database.- Parameters:
url
- URL to skinskinVariant
- Skin variant
-
setURLSkinByResponse
Saves an url to the database using a MineSkinResponse object.- Parameters:
url
- URL to skinresponse
- MineSkinResponse object
-
setCustomSkinData
Saves a custom skin to the database.- Parameters:
skinName
- Skin nametextures
- Property object
-
findSkinData
Searches a skin in the database by name/url.- Parameters:
input
- Skin name/url- Returns:
- InputDataResult object or empty if not found
-
findOrCreateSkinData
Optional<InputDataResult> findOrCreateSkinData(String input) throws DataRequestException, MineSkinException Searches a skin in the database by name/url. If not found, it will try to generate it based on the detected type.- Parameters:
input
- Skin name/url- Returns:
- InputDataResult object or empty if not found
- Throws:
DataRequestException
- If MojangAPI lookup errors (e.g. premium player not found)MineSkinException
-
getSkinDataByIdentifier
Searches a skin in the database by its skin identifier.- Parameters:
identifier
- Skin identifier- Returns:
- SkinProperty object or empty if not found
-
removeSkinData
Removes a skin from the database by its skin identifier.- Parameters:
identifier
- Skin identifier
-