Class PlayerAccounts

java.lang.Object
com.sucy.skill.api.player.PlayerAccounts

public class PlayerAccounts extends Object
Represents the collection of accounts owned by a single player. Most of the time, this class won't be used by other plugins as you can skip directly to a player's active data using the SkillAPI.getPlayerData methods. This would be if you want to extend functionality for handling the inactive accounts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlayerAccounts(org.bukkit.OfflinePlayer player)
    Initializes a new container for player account data.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the max amount of accounts the owner can use
    Retrieves the active account data for the player
    int
    Retrieves the active account ID for the player
    Retrieves all the data for the owner.
    getData(int id)
    Gets the account data by ID for the owner
    getData(int id, org.bukkit.OfflinePlayer player, boolean init)
    Gets the account data by ID for the owner.
    org.bukkit.OfflinePlayer
    Gets the Bukkit offline player object for the owner of the data
    org.bukkit.entity.Player
    Gets the Bukkit player object for the owner of the data
    Gets the name of the owner of the data
    boolean
    hasData(int id)
    Checks whether there is any data for the given account ID.
    void
    setAccount(int id)
    Switches the active account for the player by ID.
    void
    setAccount(int id, boolean apply)
    Switches the active account for the player by ID.

    Methods inherited from class java.lang.Object

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

    • PlayerAccounts

      public PlayerAccounts(org.bukkit.OfflinePlayer player)
      Initializes a new container for player account data. This shouldn't be used by other plugins as the API provides one for each player already.
      Parameters:
      player - player to store data for
  • Method Details

    • getActiveId

      public int getActiveId()
      Retrieves the active account ID for the player
      Returns:
      active account ID
    • getActiveData

      public PlayerData getActiveData()
      Retrieves the active account data for the player
      Returns:
      active account data
    • getPlayer

      public org.bukkit.entity.Player getPlayer()
      Gets the Bukkit player object for the owner of the data
      Returns:
      Bukkit player object or null if offline/dead
    • getOfflinePlayer

      public org.bukkit.OfflinePlayer getOfflinePlayer()
      Gets the Bukkit offline player object for the owner of the data
      Returns:
      Bukkit offline player object
    • getPlayerName

      public String getPlayerName()
      Gets the name of the owner of the data
      Returns:
      owner's name
    • getAccountLimit

      public int getAccountLimit()
      Retrieves the max amount of accounts the owner can use
      Returns:
      available account number
    • hasData

      public boolean hasData(int id)
      Checks whether there is any data for the given account ID. If the player has not switched to the account, there will be no data unless the setting to initialize one account for each class is enabled.
      Parameters:
      id - account ID
      Returns:
      true if data exists, false otherwise
    • getData

      public PlayerData getData(int id)
      Gets the account data by ID for the owner
      Parameters:
      id - account ID
      Returns:
      account data or null if not found
    • getData

      public PlayerData getData(int id, org.bukkit.OfflinePlayer player, boolean init)
      Gets the account data by ID for the owner. If no data exists under the given ID, new data is created as long as the ID is a positive integer (not necessarily in bounds for the player's allowed accounts).
      Parameters:
      id - account ID
      player - offline player reference
      init - whether the data is being initialized
      Returns:
      account data or null if invalid id or player
    • getAllData

      public HashMap<Integer,PlayerData> getAllData()
      Retrieves all the data for the owner. Modifying this map will alter the player's actual data.
      Returns:
      all account data for the player
    • setAccount

      public void setAccount(int id)
      Switches the active account for the player by ID. This will not accept IDs outside the player's account limits. If the player is offline or dead, this will not do anything.
      Parameters:
      id - ID of the account to switch to
    • setAccount

      public void setAccount(int id, boolean apply)
      Switches the active account for the player by ID. This will not accept IDs outside the player's account limits. If the player is offline or dead, this will not do anything.
      Parameters:
      id - ID of the account to switch to
      apply - whether to apply the switch