Package dev.espi.protectionstones
Class PSRegion
java.lang.Object
dev.espi.protectionstones.PSRegion
- Direct Known Subclasses:
PSMergedRegion
,PSStandardRegion
Represents an instance of a ProtectionStones protected region.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Add a member to the region.abstract void
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
abstract boolean
forSale()
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.Get the protection stones regions that have the given name as their set nickname (/ps name), from all worlds.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
getHome()
Get the location of the set home the region has (for /ps tp).abstract String
getId()
Get the WorldGuard ID of the region.getID()
Deprecated.abstract UUID
Get the landlord of the region.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
getName()
Get the name (nickname) of the region from /ps name.abstract PSRegion
Get the parent of this region, if there is one.abstract List<com.sk89q.worldedit.math.BlockVector2>
abstract Double
getPrice()
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.abstract List<PSRegion.LastRegionTaxPaymentEntry>
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 regionabstract PSRegion.RentStage
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.abstract List<PSRegion.TaxPayment>
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
getType()
abstract PSProtectBlock
abstract com.sk89q.worldguard.protection.regions.ProtectedRegion
com.sk89q.worldguard.protection.managers.RegionManager
org.bukkit.World
getWorld()
int
hashCode()
boolean
hide()
Hides the protection block, if it is not hidden.boolean
isHidden()
Must be run sync (calls Bukkit API)abstract boolean
Get whether or not a player is a member of this region.abstract boolean
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
Pay outstanding taxes.abstract void
removeMember(UUID uuid)
Remove a member of the region, and deal with side-effectsabstract 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
Starts renting process (adds to rent queue) tenant.abstract void
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
Set the name of the region (from /ps name).abstract void
Set the parent of this region.abstract void
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
setRentPeriod(String s)
Set the rent period of the regionabstract void
setSellable(boolean forSale, UUID landlord, double price)
MUST BE CALLED when setting up the region to be sold or cancelling saleabstract void
setTaxAutopayer(UUID player)
Set a player to auto-pay taxes for this region.abstract void
setTaxPaymentsDue(List<PSRegion.TaxPayment> taxPayments)
Save the list of tax payments due onto the region.abstract void
Set the tenant of the regionvoid
setType(PSProtectBlock type)
Change the type of the protection region.void
Toggle whether or not the protection block is hidden.boolean
unhide()
Unhides the protection block, if it is hidden.abstract void
Update with the current time and calculate any tax payments that are now due.
-
Method Details
-
fromLocation
Get the protection stone region that the location is in, or the closest one if there are overlapping regions. Returns eitherPSGroupRegion
,PSStandardRegion
orPSMergedRegion
.- 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
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 eitherPSGroupRegion
,PSStandardRegion
orPSMergedRegion
.- 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
Get the protection stone parent region that the location is in. Returns eitherPSGroupRegion
orPSStandardRegion
.- 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
Get the protection stone parent region that the location is in. May return a region with an unconfigured block type (getTypeOptions returns null). Returns eitherPSGroupRegion
orPSStandardRegion
.- 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 worldr
- the WorldGuard region- Returns:
- the
PSRegion
based on the parameters, or null if the region given is not a protectionstones region
-
fromName
Get the protection stones regions that have the given name as their set nickname (/ps name)- Parameters:
w
- the world to look for regions inname
- the nickname of the region- Returns:
- the list of regions that have that name
-
fromName
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. -
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
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
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.CircularInheritanceExceptionSet 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
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 locationblockY
- block y locationblockZ
- 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 locationblockY
- block y locationblockZ
- block z locationyaw
- location yawpitch
- location pitch
-
forSale
public abstract boolean forSale()- Returns:
- whether or not the region is for sale
-
setSellable
MUST BE CALLED when setting up the region to be sold or cancelling sale- Parameters:
forSale
- whether or not the region is for salelandlord
- the owner of the regionprice
- the price to sell for
-
sell
Sells the region to a player at the price listed.- Parameters:
player
- player to transfer the region to
-
getRentStage
- Returns:
- get the stage of the renting process
-
getLandlord
Get the landlord of the region.- Returns:
- returns the UUID of the landlord, or null if there is none.
-
setLandlord
Set the landlord of the region.- Parameters:
landlord
- uuid of landlord, or null to remove
-
getTenant
Get the tenant of the region.- Returns:
- returns the UUID of the tenant, or null if there is none.
-
setTenant
Set the tenant of the region- Parameters:
tenant
- uuid of tenant, or null to remove
-
getRentPeriod
Get the rent period of the region- Returns:
- returns the rent duration, or null if there is none
-
setRentPeriod
Set the rent period of the region- Parameters:
s
- the duration between rent payments (d h m s), or null to remove
-
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
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
Set the unix timestamp of when rent was last paid.- Parameters:
timestamp
- the unix timestamp of when rent was last paid, or null
-
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
MUST BE CALLED when the region is looking for a tenant.- Parameters:
landlord
- the landlord of the regionrentPeriod
- the rent period (d h m s) of the regionrentPrice
- the price to charge during each rent payment
-
rentOut
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 regiontenant
- the tenant of the regionrentPeriod
- the rent period (d h m s) of the regionrentPrice
- 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
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
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
Get the list of tax payments that are due.- Returns:
- the list of tax payments outstanding
-
setTaxPaymentsDue
Save the list of tax payments due onto the region.- Parameters:
taxPayments
- the full list of tax payments that are due
-
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 ofPSRegion.LastRegionTaxPaymentEntry
entries.
-
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
Set a player to auto-pay taxes for this region.- Parameters:
player
- the player to use to auto-pay taxes
-
payTax
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 fromamount
- 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
- Returns:
- returns the type, or null if the type is not configured
-
getType
- Returns:
- returns the protect block type (may include custom player heads PLAYER_HEAD:playername) that the region is
-
setType
Change the type of the protection region.- Parameters:
type
- the type of protection region to switch to
-
isOwner
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
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
- Returns:
- returns a list of the owners of the protected region
-
getMembers
- Returns:
- returns a list of the members of the protected region
-
addOwner
Add an owner to the region.- Parameters:
uuid
- the uuid of the player to add
-
addMember
Add a member to the region.- Parameters:
uuid
- the uuid of the player to add
-
removeOwner
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
Remove a member of the region, and deal with side-effects- Parameters:
uuid
- the uuid of the player to remove
-
getPoints
- Returns:
- returns a list of the bounding points of the protected region
-
getMergeableRegions
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
-
hashCode
public int hashCode()
-