Class PlayerAccounts
java.lang.Object
studio.magemonkey.fabled.api.player.PlayerAccounts
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
Fabled.getData methods. This would be if you want
to extend functionality for handling the inactive accounts.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerAccounts
(org.bukkit.OfflinePlayer player) Initializes a new container for player account data. -
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the max amount of accounts the owner can useRetrieves the active account data for the playerint
Retrieves the active account ID for the playerRetrieves all the data for the owner.getData
(int id) Gets the account data by ID for the ownergetData
(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 dataorg.bukkit.entity.Player
Gets the Bukkit player object for the owner of the dataGets the name of the owner of the databoolean
hasData
(int id) Checks whether there is any data for the given account ID.boolean
isLoaded()
isLoaded
(boolean isLoaded) 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.
-
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
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
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
Gets the account data by ID for the owner- Parameters:
id
- account ID- Returns:
- account data or null if not found
-
getData
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 IDplayer
- offline player referenceinit
- whether the data is being initialized- Returns:
- account data or null if invalid id or player
-
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 toapply
- whether to apply the switch
-
isLoaded
public boolean isLoaded() -
isLoaded
- Returns:
this
.
-