Package valorless.valorlessutils.cache
Class SkinCache
java.lang.Object
valorless.valorlessutils.cache.SkinCache
- All Implemented Interfaces:
org.bukkit.event.Listener
A cache that maps player usernames to their
PlayerProfiles, including skin data.
The cache is loaded from disk on initialization, populated with currently online players, and persisted back to disk on shutdown. It is kept up-to-date as players join the server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCache()Returns a shallow copy of the skin cache.static org.bukkit.profile.PlayerProfilegetProfile(String username) Gets thePlayerProfilefor the given player username.static URLGets the skinURLfor the given player username.static voidinit()Initializes the SkinCache by registering the event listener, loading the cache from disk, and adding all currently online players to the cache.static booleanremoveProfile(String username) Removes a player'sPlayerProfilefrom the cache.static voidshutdown()Saves the skin cache to theskins.ymlfile and logs the result.
-
Constructor Details
-
SkinCache
public SkinCache()
-
-
Method Details
-
getCache
Returns a shallow copy of the skin cache.- Returns:
- a
HashMapcopy mapping player usernames to theirPlayerProfiles
-
init
Initializes the SkinCache by registering the event listener, loading the cache from disk, and adding all currently online players to the cache.This method is for internal use only and should not be called manually.
-
shutdown
Saves the skin cache to theskins.ymlfile and logs the result.If the cache file or its parent directory does not exist, they will be created. This method is called when the plugin is disabled.
This method is for internal use only and should not be called manually.
-
getProfile
Gets thePlayerProfilefor the given player username.- Parameters:
username- the name of the player whose profile is to be retrieved- Returns:
- the
PlayerProfileof the specified player, ornullif not found in the cache
-
getSkin
Gets the skinURLfor the given player username.- Parameters:
username- the name of the player whose skin URL is to be retrieved- Returns:
- the
URLof the player's skin, ornullif not found in the cache
-
removeProfile
Removes a player'sPlayerProfilefrom the cache.- Parameters:
username- the name of the player whose profile is to be removed- Returns:
trueif the profile was successfully removed,falseif it was not found in the cache
-