Class SkinCache

java.lang.Object
valorless.havenbags.database.SkinCache
All Implemented Interfaces:
org.bukkit.event.Listener

public class SkinCache extends Object implements org.bukkit.event.Listener
This class is used to cache player skins and profiles. It listens for player join events to update the cache and saves the cache to a file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static valorless.valorlessutils.config.Config
    The configuration object for the skin cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Cleans up the cache by removing players who have no bags.
    static HashMap<String,org.bukkit.profile.PlayerProfile>
    Returns the cache of player profiles.
    static org.bukkit.profile.PlayerProfile
    Gets the PlayerProfile for a given player name.
    static URL
    getSkin(String player)
    Gets the skin URL for a given player name.
    static void
    Initializes the SkinCache by registering the event listener and loading the cache.
    void
    onPlayerJoin(org.bukkit.event.player.PlayerJoinEvent e)
    Event handler for player join events.
    static void
    Saves the skin cache to the skins.yml file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • config

      protected static valorless.valorlessutils.config.Config config
      The configuration object for the skin cache. This is a static Config object that is used to read and write the skins.yml file.
  • Constructor Details

    • SkinCache

      public SkinCache()
  • Method Details

    • getCache

      public static HashMap<String,org.bukkit.profile.PlayerProfile> getCache()
      Returns the cache of player profiles. The cache is a HashMap where the key is the player's name and the value is their PlayerProfile.
      Returns:
      HashMap<String, PlayerProfile> - The cache of player profiles.
    • init

      public static void init()
      Initializes the SkinCache by registering the event listener and loading the cache. This method should be called when the plugin is enabled.
    • shutdown

      public static void shutdown()
      Saves the skin cache to the skins.yml file. This method is called on shutdown to ensure the cache is saved.
    • cleanup

      public static void cleanup()
      Cleans up the cache by removing players who have no bags. This is called on shutdown to ensure the cache only contains players with bags.
    • onPlayerJoin

      public void onPlayerJoin(org.bukkit.event.player.PlayerJoinEvent e)
      Event handler for player join events. When a player joins, their profile is added to the cache.
      Parameters:
      e - The PlayerJoinEvent that is triggered when a player joins the server.
    • getProfile

      public static org.bukkit.profile.PlayerProfile getProfile(String player)
      Gets the PlayerProfile for a given player name.
      Parameters:
      player - The name of the player whose profile is to be retrieved.
      Returns:
      PlayerProfile - The PlayerProfile of the specified player, or null if not found.
    • getSkin

      public static URL getSkin(String player)
      Gets the skin URL for a given player name.
      Parameters:
      player - The name of the player whose skin URL is to be retrieved.
      Returns:
      URL - The URL of the player's skin, or null if not found.