Class PSRegion

java.lang.Object
dev.espi.protectionstones.PSRegion
Direct Known Subclasses:
PSMergedRegion, PSStandardRegion

public abstract class PSRegion extends Object
Represents an instance of a ProtectionStones protected region.
  • Nested Class Summary

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

    Modifier and Type
    Method
    Description
    abstract void
    addMember​(UUID uuid)
    Add a member to the region.
    abstract void
    addOwner​(UUID uuid)
    Add an owner to the region.
    abstract boolean
    deleteRegion​(boolean deleteBlock)
    Deletes the region forever.
    abstract boolean
    deleteRegion​(boolean deleteBlock, org.bukkit.entity.Player cause)
    Deletes the region forever.
    boolean
    equals​(Object o)
     
    abstract boolean
     
    static PSRegion
    fromLocation​(org.bukkit.Location l)
    Get the protection stone region that the location is in, or the closest one if there are overlapping regions.
    static PSRegion
    fromLocationGroup​(org.bukkit.Location l)
    Get the protection stone parent region that the location is in.
    static PSRegion
    fromLocationGroupUnsafe​(org.bukkit.Location l)
    Get the protection stone parent region that the location is in.
    static PSRegion
    fromLocationUnsafe​(org.bukkit.Location l)
    Get the protection stone region that the location is in, or the closest one if there are overlapping regions.
    static HashMap<org.bukkit.World,​List<PSRegion>>
    fromName​(String name)
    Get the protection stones regions that have the given name as their set nickname (/ps name), from all worlds.
    static List<PSRegion>
    fromName​(org.bukkit.World w, String name)
    Get the protection stones regions that have the given name as their set nickname (/ps name)
    static PSRegion
    fromWGRegion​(org.bukkit.World w, com.sk89q.worldguard.protection.regions.ProtectedRegion r)
    Get the protection stone region with the world and region.
    abstract org.bukkit.Location
    Get the location of the set home the region has (for /ps tp).
    abstract String
    Get the WorldGuard ID of the region.
    Deprecated.
    abstract UUID
    Get the landlord of the region.
    abstract ArrayList<UUID>
     
    abstract List<PSRegion>
    getMergeableRegions​(org.bukkit.entity.Player p)
    Get a list of regions that the current region can merge into, taking into account a player's permissions.
    abstract String
    Get the name (nickname) of the region from /ps name.
    abstract ArrayList<UUID>
     
    abstract PSRegion
    Get the parent of this region, if there is one.
    abstract List<com.sk89q.worldedit.math.BlockVector2>
     
    abstract Double
    Get the price of the region This applies to either the rent or the full purchase of a region.
    abstract org.bukkit.block.Block
    This method returns the block that is supposed to contain the protection block.
    Get the list of timestamps of the last time regions and sub regions have added to the tax payments list.
    abstract Long
    Get the unix timestamp of when rent was last paid.
    abstract String
    Get the rent period of the region
     
    abstract UUID
    Get the player that is set to autopay the tax amount.
    abstract String
    Get the formatted period(s) allowed for the payment of tax.
    Get the list of tax payments that are due.
    abstract String
    Get the formatted period(s) between tax payments for this region type.
    double
    Get the tax rate for this region type.
    abstract UUID
    Get the tenant of the region.
    abstract String
     
     
    abstract com.sk89q.worldguard.protection.regions.ProtectedRegion
     
    com.sk89q.worldguard.protection.managers.RegionManager
     
    org.bukkit.World
     
    int
     
    boolean
    Hides the protection block, if it is not hidden.
    boolean
    Must be run sync (calls Bukkit API)
    abstract boolean
    isMember​(UUID uuid)
    Get whether or not a player is a member of this region.
    abstract boolean
    isOwner​(UUID uuid)
    Get whether or not a player is an owner of this region.
    abstract boolean
    Check if any tax payments are now late (exceeded tax payment time shown in config).
    abstract net.milkbowl.vault.economy.EconomyResponse
    payTax​(PSPlayer p, double amount)
    Pay outstanding taxes.
    abstract void
    removeMember​(UUID uuid)
    Remove a member of the region, and deal with side-effects
    abstract void
    removeOwner​(UUID uuid)
    Remove an owner of the region, and deal with side-effects.
    abstract void
    Stop renting process and remove tenant.
    abstract void
    rentOut​(UUID landlord, UUID tenant, String rentPeriod, double rentPrice)
    Starts renting process (adds to rent queue) tenant.
    abstract void
    sell​(UUID player)
    Sells the region to a player at the price listed.
    abstract void
    setHome​(double blockX, double blockY, double blockZ)
    Set the home of the region (internally changes the flag).
    abstract void
    setHome​(double blockX, double blockY, double blockZ, float yaw, float pitch)
    Set the home of the region (internally changes the flag).
    abstract void
    setLandlord​(UUID landlord)
    Set the landlord of the region.
    abstract void
    setName​(String name)
    Set the name of the region (from /ps name).
    abstract void
    Set the parent of this region.
    abstract void
    setPrice​(Double price)
    Set the price of the region.
    abstract void
    Save the list of timestamps of the last time regions and sub regions have added to the tax payments list on to the base region.
    abstract void
    setRentable​(UUID landlord, String rentPeriod, double rentPrice)
    MUST BE CALLED when the region is looking for a tenant.
    abstract void
    setRentLastPaid​(Long timestamp)
    Set the unix timestamp of when rent was last paid.
    abstract void
    Set the rent period of the region
    abstract void
    setSellable​(boolean forSale, UUID landlord, double price)
    MUST BE CALLED when setting up the region to be sold or cancelling sale
    abstract void
    setTaxAutopayer​(UUID player)
    Set a player to auto-pay taxes for this region.
    abstract void
    Save the list of tax payments due onto the region.
    abstract void
    setTenant​(UUID tenant)
    Set the tenant of the region
    void
    Change the type of the protection region.
    void
    Toggle whether or not the protection block is hidden.
    boolean
    Unhides the protection block, if it is hidden.
    abstract void
    Update with the current time and calculate any tax payments that are now due.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromLocation

      public static PSRegion fromLocation(org.bukkit.Location l)
      Get the protection stone region that the location is in, or the closest one if there are overlapping regions. Returns either PSGroupRegion, PSStandardRegion or PSMergedRegion.
      Parameters:
      l - the location
      Returns:
      the PSRegion object if the location is in a region, or null if the location is not in a region
    • fromLocationUnsafe

      public static PSRegion fromLocationUnsafe(org.bukkit.Location l)
      Get the protection stone region that the location is in, or the closest one if there are overlapping regions. May return a region with an unconfigured block type (getTypeOptions returns null). Returns either PSGroupRegion, PSStandardRegion or PSMergedRegion.
      Parameters:
      l - the location
      Returns:
      the PSRegion object if the location is in a region, or null if the location is not in a region
    • fromLocationGroup

      public static PSRegion fromLocationGroup(org.bukkit.Location l)
      Get the protection stone parent region that the location is in. Returns either PSGroupRegion or PSStandardRegion.
      Parameters:
      l - the location
      Returns:
      the PSRegion object if the location is in a region, or null if the location is not in a region
    • fromLocationGroupUnsafe

      public static PSRegion fromLocationGroupUnsafe(org.bukkit.Location l)
      Get the protection stone parent region that the location is in. May return a region with an unconfigured block type (getTypeOptions returns null). Returns either PSGroupRegion or PSStandardRegion.
      Parameters:
      l - the location
      Returns:
      the PSRegion object if the location is in a region, or null if the location is not in a region
    • fromWGRegion

      public static PSRegion fromWGRegion(org.bukkit.World w, com.sk89q.worldguard.protection.regions.ProtectedRegion r)
      Get the protection stone region with the world and region. It returns a WGRegion with a null type if the block type isn't configured in the config.
      Parameters:
      w - the world
      r - the WorldGuard region
      Returns:
      the PSRegion based on the parameters, or null if the region given is not a protectionstones region
    • fromName

      public static List<PSRegion> fromName(org.bukkit.World w, String name)
      Get the protection stones regions that have the given name as their set nickname (/ps name)
      Parameters:
      w - the world to look for regions in
      name - the nickname of the region
      Returns:
      the list of regions that have that name
    • fromName

      public static HashMap<org.bukkit.World,​List<PSRegion>> fromName(String name)
      Get the protection stones regions that have the given name as their set nickname (/ps name), from all worlds.
      Parameters:
      name - the nickname of the regions
      Returns:
      the map of worlds, to the regions that have the name
    • getWorld

      public org.bukkit.World getWorld()
      Returns:
      gets the world that the region is in
    • getID

      @Deprecated public String getID()
      Deprecated.
    • getId

      public abstract String getId()
      Get the WorldGuard ID of the region. Note that this is not guaranteed to be unique between worlds.
      Returns:
      the id of the region
    • getName

      public abstract String getName()
      Get the name (nickname) of the region from /ps name.
      Returns:
      the name of the region, or null if the region does not have a name
    • setName

      public abstract void setName(String name)
      Set the name of the region (from /ps name).
      Parameters:
      name - new name, or null to remove the name
    • setParent

      public abstract void setParent(PSRegion r) throws com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException
      Set the parent of this region.
      Parameters:
      r - the region to be the parent, or null for no parent
      Throws:
      com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException - thrown when the parent already inherits from the child
    • getParent

      public abstract PSRegion getParent()
      Get the parent of this region, if there is one.
      Returns:
      the parent of the region, or null if there isn't one
    • getHome

      public abstract org.bukkit.Location getHome()
      Get the location of the set home the region has (for /ps tp).
      Returns:
      the location of the home, or null if the ps_home flag is not set.
    • setHome

      public abstract void setHome(double blockX, double blockY, double blockZ)
      Set the home of the region (internally changes the flag).
      Parameters:
      blockX - block x location
      blockY - block y location
      blockZ - block z location
    • setHome

      public abstract void setHome(double blockX, double blockY, double blockZ, float yaw, float pitch)
      Set the home of the region (internally changes the flag).
      Parameters:
      blockX - block x location
      blockY - block y location
      blockZ - block z location
      yaw - location yaw
      pitch - location pitch
    • forSale

      public abstract boolean forSale()
      Returns:
      whether or not the region is for sale
    • setSellable

      public abstract void setSellable(boolean forSale, UUID landlord, double price)
      MUST BE CALLED when setting up the region to be sold or cancelling sale
      Parameters:
      forSale - whether or not the region is for sale
      landlord - the owner of the region
      price - the price to sell for
    • sell

      public abstract void sell(UUID player)
      Sells the region to a player at the price listed.
      Parameters:
      player - player to transfer the region to
    • getRentStage

      public abstract PSRegion.RentStage getRentStage()
      Returns:
      get the stage of the renting process
    • getLandlord

      public abstract UUID getLandlord()
      Get the landlord of the region.
      Returns:
      returns the UUID of the landlord, or null if there is none.
    • setLandlord

      public abstract void setLandlord(UUID landlord)
      Set the landlord of the region.
      Parameters:
      landlord - uuid of landlord, or null to remove
    • getTenant

      public abstract UUID getTenant()
      Get the tenant of the region.
      Returns:
      returns the UUID of the tenant, or null if there is none.
    • setTenant

      public abstract void setTenant(UUID tenant)
      Set the tenant of the region
      Parameters:
      tenant - uuid of tenant, or null to remove
    • getRentPeriod

      public abstract String getRentPeriod()
      Get the rent period of the region
      Returns:
      returns the rent duration, or null if there is none
    • setRentPeriod

      public abstract void setRentPeriod(String s)
      Set the rent period of the region
      Parameters:
      s - the duration between rent payments (d h m s), or null to remove
    • getPrice

      public abstract Double getPrice()
      Get the price of the region This applies to either the rent or the full purchase of a region.
      Returns:
      the price of the region during rent payments, or null if there is no rent
    • setPrice

      public abstract void setPrice(Double price)
      Set the price of the region. This applies to either the rent or the full purchase of a region.
      Parameters:
      price - the price of the region, or null if there is no rent
    • setRentLastPaid

      public abstract void setRentLastPaid(Long timestamp)
      Set the unix timestamp of when rent was last paid.
      Parameters:
      timestamp - the unix timestamp of when rent was last paid, or null
    • getRentLastPaid

      public abstract Long getRentLastPaid()
      Get the unix timestamp of when rent was last paid.
      Returns:
      the unix timestamp of when rent was last paid, or null if not renting
    • setRentable

      public abstract void setRentable(UUID landlord, String rentPeriod, double rentPrice)
      MUST BE CALLED when the region is looking for a tenant.
      Parameters:
      landlord - the landlord of the region
      rentPeriod - the rent period (d h m s) of the region
      rentPrice - the price to charge during each rent payment
    • rentOut

      public abstract void rentOut(UUID landlord, UUID tenant, String rentPeriod, double rentPrice)
      Starts renting process (adds to rent queue) tenant. MUST BE CALLED when renting the region out to a tenant.
      Parameters:
      landlord - the landlord of the region
      tenant - the tenant of the region
      rentPeriod - the rent period (d h m s) of the region
      rentPrice - the price to charge during each rent payment
    • removeRenting

      public abstract void removeRenting()
      Stop renting process and remove tenant. MUST BE CALLED when removing rent.
    • getTaxRate

      public double getTaxRate()
      Get the tax rate for this region type.
      Returns:
      the tax rate
    • getTaxPeriod

      public abstract String getTaxPeriod()
      Get the formatted period(s) between tax payments for this region type. If you simply wanted the number of seconds, use getTypeOptions().taxPeriod
      Returns:
      the duration between tax payments, or multiple if there are several different ones
    • getTaxPaymentPeriod

      public abstract String getTaxPaymentPeriod()
      Get the formatted period(s) allowed for the payment of tax. If you simply wanted the number of seconds, use getTypeOptions().taxPaymentTime
      Returns:
      the duration of time allowed to pay a tax, or multiple if there are several different ones
    • getTaxPaymentsDue

      public abstract List<PSRegion.TaxPayment> getTaxPaymentsDue()
      Get the list of tax payments that are due.
      Returns:
      the list of tax payments outstanding
    • setTaxPaymentsDue

      public abstract void setTaxPaymentsDue(List<PSRegion.TaxPayment> taxPayments)
      Save the list of tax payments due onto the region.
      Parameters:
      taxPayments - the full list of tax payments that are due
    • getRegionLastTaxPaymentAddedEntries

      public abstract List<PSRegion.LastRegionTaxPaymentEntry> getRegionLastTaxPaymentAddedEntries()
      Get the list of timestamps of the last time regions and sub regions have added to the tax payments list.
      Returns:
      the list of the last time regions and sub regions have added to the tax payment list
    • setRegionLastTaxPaymentAddedEntries

      public abstract void setRegionLastTaxPaymentAddedEntries(List<PSRegion.LastRegionTaxPaymentEntry> entries)
      Save the list of timestamps of the last time regions and sub regions have added to the tax payments list on to the base region.
      Parameters:
      entries - the full list of PSRegion.LastRegionTaxPaymentEntry entries.
    • getTaxAutopayer

      public abstract UUID getTaxAutopayer()
      Get the player that is set to autopay the tax amount.
      Returns:
      the player that is set as the autopayer, or null if no player is set
    • setTaxAutopayer

      public abstract void setTaxAutopayer(UUID player)
      Set a player to auto-pay taxes for this region.
      Parameters:
      player - the player to use to auto-pay taxes
    • payTax

      public abstract net.milkbowl.vault.economy.EconomyResponse payTax(PSPlayer p, double amount)
      Pay outstanding taxes. It will only withdraw the amount required to pay the taxes, and will take up to the amount specified if the outstanding payments are larger.
      Parameters:
      p - the player to take money from
      amount - the amount to take
      Returns:
      the EconomyResponse returned by Vault
    • isTaxPaymentLate

      public abstract boolean isTaxPaymentLate()
      Check if any tax payments are now late (exceeded tax payment time shown in config).
      Returns:
      whether or not any tax payments are now late
    • updateTaxPayments

      public abstract void updateTaxPayments()
      Update with the current time and calculate any tax payments that are now due.
    • isHidden

      public boolean isHidden()
      Must be run sync (calls Bukkit API)
      Returns:
      whether or not the protection block is hidden (/ps hide)
    • hide

      public boolean hide()
      Hides the protection block, if it is not hidden.
      Returns:
      whether or not the block was hidden
    • unhide

      public boolean unhide()
      Unhides the protection block, if it is hidden.
      Returns:
      whether or not the block was unhidden
    • toggleHide

      public void toggleHide()
      Toggle whether or not the protection block is hidden.
    • getProtectBlock

      public abstract org.bukkit.block.Block getProtectBlock()
      This method returns the block that is supposed to contain the protection block. Warning: If the protection stone is hidden, this will give the block that took its place!
      Returns:
      returns the block that may contain the protection stone
    • getTypeOptions

      @Nullable public abstract PSProtectBlock getTypeOptions()
      Returns:
      returns the type, or null if the type is not configured
    • getType

      public abstract String getType()
      Returns:
      returns the protect block type (may include custom player heads PLAYER_HEAD:playername) that the region is
    • setType

      public void setType(PSProtectBlock type)
      Change the type of the protection region.
      Parameters:
      type - the type of protection region to switch to
    • isOwner

      public abstract boolean isOwner(UUID uuid)
      Get whether or not a player is an owner of this region.
      Parameters:
      uuid - the player's uuid
      Returns:
      whether or not the player is a member
    • isMember

      public abstract boolean isMember(UUID uuid)
      Get whether or not a player is a member of this region.
      Parameters:
      uuid - the player's uuid
      Returns:
      whether or not the player is a member
    • getOwners

      public abstract ArrayList<UUID> getOwners()
      Returns:
      returns a list of the owners of the protected region
    • getMembers

      public abstract ArrayList<UUID> getMembers()
      Returns:
      returns a list of the members of the protected region
    • addOwner

      public abstract void addOwner(UUID uuid)
      Add an owner to the region.
      Parameters:
      uuid - the uuid of the player to add
    • addMember

      public abstract void addMember(UUID uuid)
      Add a member to the region.
      Parameters:
      uuid - the uuid of the player to add
    • removeOwner

      public abstract void removeOwner(UUID uuid)
      Remove an owner of the region, and deal with side-effects. Examples of side-effects: removing player as landlord, removing player as auto taxpayer
      Parameters:
      uuid - the uuid of the player to remove
    • removeMember

      public abstract void removeMember(UUID uuid)
      Remove a member of the region, and deal with side-effects
      Parameters:
      uuid - the uuid of the player to remove
    • getPoints

      public abstract List<com.sk89q.worldedit.math.BlockVector2> getPoints()
      Returns:
      returns a list of the bounding points of the protected region
    • getMergeableRegions

      public abstract List<PSRegion> getMergeableRegions(org.bukkit.entity.Player p)
      Get a list of regions that the current region can merge into, taking into account a player's permissions.
      Parameters:
      p - the player to compare permissions with
      Returns:
      the list of regions that the current region can merge into
    • deleteRegion

      public abstract boolean deleteRegion(boolean deleteBlock)
      Deletes the region forever. Can be cancelled by event cancellation.
      Parameters:
      deleteBlock - whether or not to also set the protection block to air (if not hidden)
      Returns:
      whether or not the region was able to be successfully removed
    • deleteRegion

      public abstract boolean deleteRegion(boolean deleteBlock, org.bukkit.entity.Player cause)
      Deletes the region forever. Can be cancelled by event cancellation.
      Parameters:
      deleteBlock - whether or not to also set the protection block to air (if not hidden)
      cause - the player that caused the region to break
      Returns:
      whether or not the region was able to be successfully removed
    • getWGRegion

      public abstract com.sk89q.worldguard.protection.regions.ProtectedRegion getWGRegion()
      Returns:
      returns the WorldGuard region object directly
    • getWGRegionManager

      public com.sk89q.worldguard.protection.managers.RegionManager getWGRegionManager()
      Returns:
      returns the WorldGuard region manager that stores this region
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object