Class PSPlayer

java.lang.Object
dev.espi.protectionstones.PSPlayer

public class PSPlayer extends Object
Wrapper for a Bukkit player that exposes ProtectionStones related methods.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PSPlayer​(UUID uuid)
     
    PSPlayer​(org.bukkit.entity.Player player)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.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
    fromUUID​(UUID uuid)
    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.
     
    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.
    Get the wrapped player's uuid.
    boolean
    hasAmount​(double amount)
    Get if the player has a certain amount of money.
    void
    pay​(PSPlayer payee, double amount)
    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.

    Methods inherited from class java.lang.Object

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

    • PSPlayer

      public PSPlayer(org.bukkit.entity.Player player)
    • PSPlayer

      public PSPlayer(UUID uuid)
  • Method Details

    • fromUUID

      public static PSPlayer fromUUID(UUID uuid)
      Adapt a UUID into a PSPlayer wrapper.
      Parameters:
      uuid - the uuid to wrap
      Returns:
      the PSPlayer object
    • fromPlayer

      public static PSPlayer fromPlayer(org.bukkit.entity.Player p)
      Adapt a Bukkit player into a PSPlayer wrapper.
      Parameters:
      p - the player to wrap
      Returns:
      the PSPlayer object
    • fromPlayer

      public static PSPlayer fromPlayer(org.bukkit.OfflinePlayer p)
    • getUuid

      public UUID 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

      public String 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

      public void pay(PSPlayer payee, double amount)
      Pay another player a certain amount of money. Vault must be enabled! Must be run on main thread!
      Parameters:
      payee - the player to pay
      amount - the amount to pay
    • getRegionLimits

      public HashMap<PSProtectBlock,​Integer> 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

      public List<PSRegion> 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

      public List<PSRegion> getPSRegions(org.bukkit.World w, boolean canBeMember)
      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 in
      canBeMember - 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

      public List<PSRegion> getPSRegionsCrossWorld(org.bukkit.World w, boolean canBeMember)
      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 in
      canBeMember - 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

      public List<PSRegion> getHomes(org.bukkit.World w)
      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