Class PlayerManager

java.lang.Object
nl.minetopiasdb.api.playerdata.PlayerManager

public class PlayerManager extends Object
Class for managing playerdata.
  • Constructor Details

    • PlayerManager

      public PlayerManager()
  • Method Details

    • getInstance

      public static PlayerManager getInstance()
      Get the instance of PlayerManager.
      Returns:
      instance of PlayerManager.
    • getOnlinePlayers

      public Collection<OnlineSDBPlayer> getOnlinePlayers()
      Get all the currently online SDBPlayers
      Returns:
      Collection of the online SDBPlayers.
    • getPlayer

      public static SDBPlayer getPlayer(UUID uuid)
      Get a SDBPlayer instance for the requested player. Will return a SDBPlayer for an online or offline player.
      Parameters:
      uuid - UUID of the player
      Returns:
      SDBPlayer instance for given UUID
    • getOnlinePlayer

      public static OnlineSDBPlayer getOnlinePlayer(UUID uuid)
      Get an OnlineSDBPlayer instance for the requested player. Will return a OnlineSDBPlayer for an online player.
      Parameters:
      uuid - UUID of the online player
      Returns:
      OnlineSDBPlayer instance for given UUID
    • getOfflinePlayer

      public static OfflineSDBPlayer getOfflinePlayer(UUID uuid)
      Get an OfflineSDBPlayer instance for the requested player. Will return a OfflineSDBPlayer for an offline player.
      Parameters:
      uuid - UUID of the offline player
      Returns:
      OfflineSDBPlayer instance for given UUID
    • isInDatabase

      public boolean isInDatabase(UUID uuid)
      Check if given UUID is in the playerdata database.
      Parameters:
      uuid - UUID that needs to be checked.
      Returns:
      true if UUID is found in the database.
    • addDefaults

      public void addDefaults(UUID uuid)
      Add default userdata for given UUID.
      Parameters:
      uuid - uuid that needs userdata.
    • loadPlayer

      public void loadPlayer(UUID uuid)
      Load playerdata from the database and put it in the cache.
      Parameters:
      uuid - UUID of player
    • quit

      public void quit(UUID uuid)
      Remove a player from the OnlineSDBPlayer cache
      Parameters:
      uuid - UUID of player that needs to be removed
    • getChangedUsers

      public List<UUID> getChangedUsers()
      Get a list with all the UUIDs that have playerdata changes
      Returns:
      list with UUIDs that have playerdata changes
    • manageSet

      public void manageSet(UUID who, String path, Object value)
      Add all the playerdata changes of provided UUID to the database.
      Parameters:
      who - UUID of the player
      path - path of the changed playerdata
      value - new value of playerdata
    • pushSetsToDatabase

      public void pushSetsToDatabase(UUID uuid)
      Push all the changes to this UUID to the database.
      Parameters:
      uuid - UUID of player
    • isLoading

      public boolean isLoading(UUID uuid)
      Check if a player his data is still loading (if he just joined there is a slight delay between the join and his data being fully loaded.)
      Parameters:
      uuid - player who needs to be checked
      Returns:
      true if his data is currently loaded
    • setLoading

      public void setLoading(UUID uuid)
      Set the player as 'loading'.
      Parameters:
      uuid - player who needs to be set as loading.
    • stopLoading

      public void stopLoading(UUID uuid)
      Removes the player from the 'loading' list which can be checked with the isLoading() method
      Parameters:
      uuid - player who needs to be removed from the loading list.
    • isOfflineCached

      public boolean isOfflineCached(UUID uuid)
      Check if the given player is in the offline SDBPlayer cache.
      Parameters:
      uuid - player who needs to be checked
      Returns:
      true if given player is in offline SDBPlayer cache.
    • removeFromOfflineCache

      public void removeFromOfflineCache(UUID uuid)
      Remove a player from the offline SDBPlayer cache.
      Parameters:
      uuid - player who needs to be removed from the offline SDBPlayer cache.
    • clearOfflineCache

      public void clearOfflineCache()
      Clear the offline player cache
    • removeFromChangeCache

      public void removeFromChangeCache(UUID uuid)
      Remove a player from the changes cache.
      Parameters:
      uuid - uuid of player
    • swap

      public void swap(UUID source, UUID target)
      Swap data from Player 1 to Player 2
      Parameters:
      source - source player
      target - target player