Package dev.espi.protectionstones
Class PSPlayer
java.lang.Object
dev.espi.protectionstones.PSPlayer
Wrapper for a Bukkit player that exposes ProtectionStones related methods.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionnet.milkbowl.vault.economy.EconomyResponse
depositBalance(double amount)
Add a certain amount to the player's bank account.static PSPlayer
fromPlayer(org.bukkit.entity.Player p)
Adapt a Bukkit player into a PSPlayer wrapper.static PSPlayer
fromPlayer(org.bukkit.OfflinePlayer p)
static PSPlayer
Adapt a UUID into a PSPlayer wrapper.double
Get the player's balance.int
Get a player's total protection limit from permission (protectionstones.limit.x) If there is no attached Player object to this PSPlayer, and LuckPerms is not enabled, this throws a CannotAccessOfflinePlayerPermissionsException.getHomes(org.bukkit.World w)
Get the list of homes a player owns.getName()
org.bukkit.OfflinePlayer
Get the wrapped Bukkit offline player.org.bukkit.entity.Player
Get the wrapped Bukkit player.getPSRegions(org.bukkit.World w, boolean canBeMember)
Get the list of regions that a player owns, or is a member of.getPSRegionsCrossWorld(org.bukkit.World w, boolean canBeMember)
Get the list of regions that a player owns, or is a member of.Get a player's permission limits for each protection block (protectionstones.limit.alias.x) Protection blocks that aren't specified in the player's permissions will not be returned in the map.Get the list of regions that a player can pay money for taxes to.getUuid()
Get the wrapped player's uuid.boolean
hasAmount(double amount)
Get if the player has a certain amount of money.void
Pay another player a certain amount of money.net.milkbowl.vault.economy.EconomyResponse
withdrawBalance(double amount)
Withdraw a certain amount from the player's bank account.
-
Constructor Details
-
PSPlayer
public PSPlayer(org.bukkit.entity.Player player) -
PSPlayer
-
-
Method Details
-
fromUUID
Adapt a UUID into a PSPlayer wrapper.- Parameters:
uuid
- the uuid to wrap- Returns:
- the PSPlayer object
-
fromPlayer
Adapt a Bukkit player into a PSPlayer wrapper.- Parameters:
p
- the player to wrap- Returns:
- the PSPlayer object
-
fromPlayer
-
getUuid
Get the wrapped player's uuid.- Returns:
- the uuid
-
getPlayer
public org.bukkit.entity.Player getPlayer()Get the wrapped Bukkit player. It may return null if the object wraps a UUID that does not exist.- Returns:
- the player, or null
-
getOfflinePlayer
public org.bukkit.OfflinePlayer getOfflinePlayer()Get the wrapped Bukkit offline player. Safer to use than getPlayer (this does not return a null). It may return an empty player if the object wraps a UUID that does not exist.- Returns:
- the offline player
-
getName
-
hasAmount
public boolean hasAmount(double amount)Get if the player has a certain amount of money. Vault must be enabled!- Parameters:
amount
- the amount to check- Returns:
- whether the player has this amount of money
-
getBalance
public double getBalance()Get the player's balance. Vault must be enabled!- Returns:
- the amount of money the player has
-
depositBalance
public net.milkbowl.vault.economy.EconomyResponse depositBalance(double amount)Add a certain amount to the player's bank account. Vault must be enabled! Must be run on main thread!- Parameters:
amount
- the amount to add- Returns:
- the
EconomyResponse
that is given by Vault
-
withdrawBalance
public net.milkbowl.vault.economy.EconomyResponse withdrawBalance(double amount)Withdraw a certain amount from the player's bank account. Vault must be enabled! Must be run on main thread!- Parameters:
amount
- the amount to withdraw- Returns:
- the
EconomyResponse
that is given by Vault
-
pay
Pay another player a certain amount of money. Vault must be enabled! Must be run on main thread!- Parameters:
payee
- the player to payamount
- the amount to pay
-
getRegionLimits
Get a player's permission limits for each protection block (protectionstones.limit.alias.x) Protection blocks that aren't specified in the player's permissions will not be returned in the map. If LuckPerms support isn't enabled and the player is not online, then the method will throw a CannotAccessOfflinePlayerPermissionsException.- Returns:
- a hashmap containing a psprotectblock object to an integer, which is the number of protection regions of that type the player is allowed to place
-
getGlobalRegionLimits
public int getGlobalRegionLimits()Get a player's total protection limit from permission (protectionstones.limit.x) If there is no attached Player object to this PSPlayer, and LuckPerms is not enabled, this throws a CannotAccessOfflinePlayerPermissionsException.- Returns:
- the number of protection regions the player can have, or -1 if there is no limit set.
-
getTaxEligibleRegions
Get the list of regions that a player can pay money for taxes to. Note: this should be run asynchronously, as it can be very slow with large amounts of regions.- Returns:
- the regions that the player owes tax money to
-
getPSRegions
Get the list of regions that a player owns, or is a member of. It is recommended to run this asynchronously since the query can be slow.- Parameters:
w
- world to search for regions incanBeMember
- whether or not to add regions where the player is a member, not owner- Returns:
- list of regions that the player owns (or is a part of if canBeMember is true)
-
getPSRegionsCrossWorld
Get the list of regions that a player owns, or is a member of. It is recommended to run this asynchronously since the query can be slow. Note: Regions that the player owns that are named will be cross-world, otherwise this only searches in one world.- Parameters:
w
- world to search for regions incanBeMember
- whether or not to add regions where the player is a member, not owner- Returns:
- list of regions that the player owns (or is a part of if canBeMember is true)
-
getHomes
Get the list of homes a player owns. It is recommended to run this asynchronously. Note: Regions that the player owns that are named will be cross-world, otherwise this only searches in one world.- Parameters:
w
- world to search for regions in- Returns:
- list of regions that are the player's homes
-