Class ProtectedRegion
java.lang.Object
com.sk89q.worldguard.protection.regions.ProtectedRegion
- All Implemented Interfaces:
ChangeTracked
,Comparable<ProtectedRegion>
- Direct Known Subclasses:
GlobalProtectedRegion
,ProtectedCuboidRegion
,ProtectedPolygonalRegion
public abstract class ProtectedRegion
extends Object
implements ChangeTracked, Comparable<ProtectedRegion>
Represents a region that can be indexed and have spatial queries performed
against it.
Instances can be modified and access from several threads at a time.
Note: this class has a natural ordering that is inconsistent with equals. Regions with identical ids (and also the same priority) may exist in different managers (or no manager at all), so care should be taken when comparing regions that have not been obtained from a single manager.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Thrown when setting a parent would create a circular inheritance situation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected com.sk89q.worldedit.math.BlockVector3
protected com.sk89q.worldedit.math.BlockVector3
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the parent (set the parent tonull
).int
compareTo
(ProtectedRegion other) boolean
contains
(int x, int y, int z) Check to see if a point is inside this region.boolean
contains
(com.sk89q.worldedit.math.BlockVector2 position) Check to see if a position is contained within this region.abstract boolean
contains
(com.sk89q.worldedit.math.BlockVector3 pt) Check to see if a point is inside this region.boolean
containsAny
(List<com.sk89q.worldedit.math.BlockVector2> positions) Check to see if any of the points are inside this region projected onto the X-Z plane.void
copyFrom
(ProtectedRegion other) Copy attributes from another region.<T extends Flag<V>,
V>
VgetFlag
(T flag) Get a flag's value.getFlags()
Get the map of flags.getId()
Gets the name of this regiongetIntersectingRegions
(Collection<ProtectedRegion> regions) Return a list of regions from the given list of regions that intersect with this region.com.sk89q.worldedit.math.BlockVector3
Get a vector containing the highest X, Y, and Z components for the corner of the axis-aligned bounding box that contains this region.Get the domain that contains the members of this region, which does not automatically include the owners.com.sk89q.worldedit.math.BlockVector3
Get a vector containing the smallest X, Y, and Z components for the corner of the axis-aligned bounding box that contains this region.Get the domain that contains the owners of this region.Get the parent of the region, if one exists.abstract List
<com.sk89q.worldedit.math.BlockVector2> Get points of the region projected onto the X-Z plane.int
Get the priority of the region, where higher numbers indicate a higher priority.abstract RegionType
getType()
Get the type of region.int
hashCode()
boolean
Checks whether a region has members or owners.protected boolean
intersects
(ProtectedRegion region, Area thisArea) Test whether the given region intersects with this area.protected boolean
intersectsBoundingBox
(ProtectedRegion region) Checks if the bounding box of a region intersects with with the bounding box of this region.protected boolean
intersectsEdges
(ProtectedRegion region) Compares all edges of two regions to see if any of them intersect.boolean
isDirty()
Tests whether changes have been made.boolean
isMember
(LocalPlayer player) Checks whether a player is a member OR OWNER of the region or any of its parents.boolean
Deprecated.Names are deprecated, this will not return players added by UUID (LocalPlayer)boolean
isMemberOnly
(LocalPlayer player) Checks whether a player is a member of the region or any of its parents.boolean
isOwner
(LocalPlayer player) Checks whether a player is an owner of region or any of its parents.boolean
Deprecated.Names are deprecated, this will not return owners added by UUID (LocalPlayer)abstract boolean
Return whether this type of region encompasses physical area.boolean
static boolean
Checks to see if the given ID is a valid ID.void
setDirty
(boolean dirty) Set whether changes have been made.<T extends Flag<V>,
V>
voidsetFlag
(T flag, V val) Set a flag's value.void
Set the map of flags.void
setMembers
(DefaultDomain members) Set the members domain.protected void
setMinMaxPoints
(List<com.sk89q.worldedit.math.BlockVector3> points) Set the minimum and maximum points of the bounding box for a regionvoid
setOwners
(DefaultDomain owners) Set the owner domain.void
setParent
(ProtectedRegion parent) Set the parent of this region.void
setPriority
(int priority) Set the priority of the region, where higher numbers indicate a higher priority.toString()
abstract int
volume()
Get the number of blocks in this region.
-
Field Details
-
GLOBAL_REGION
- See Also:
-
min
protected com.sk89q.worldedit.math.BlockVector3 min -
max
protected com.sk89q.worldedit.math.BlockVector3 max
-
-
Method Details
-
setMinMaxPoints
Set the minimum and maximum points of the bounding box for a region- Parameters:
points
- the points to set with at least one entry
-
getId
Gets the name of this region- Returns:
- the name
-
isPhysicalArea
public abstract boolean isPhysicalArea()Return whether this type of region encompasses physical area.- Returns:
- Whether physical area is encompassed
-
getMinimumPoint
public com.sk89q.worldedit.math.BlockVector3 getMinimumPoint()Get a vector containing the smallest X, Y, and Z components for the corner of the axis-aligned bounding box that contains this region.- Returns:
- the minimum point
-
getMaximumPoint
public com.sk89q.worldedit.math.BlockVector3 getMaximumPoint()Get a vector containing the highest X, Y, and Z components for the corner of the axis-aligned bounding box that contains this region.- Returns:
- the maximum point
-
getPriority
public int getPriority()Get the priority of the region, where higher numbers indicate a higher priority.- Returns:
- the priority
-
setPriority
public void setPriority(int priority) Set the priority of the region, where higher numbers indicate a higher priority.- Parameters:
priority
- the priority to set
-
getParent
Get the parent of the region, if one exists.- Returns:
- the parent, or
null
-
setParent
public void setParent(@Nullable ProtectedRegion parent) throws ProtectedRegion.CircularInheritanceException Set the parent of this region. This checks to make sure that it will not result in circular inheritance.- Parameters:
parent
- the new parent- Throws:
ProtectedRegion.CircularInheritanceException
- when circular inheritance is detected
-
clearParent
public void clearParent()Clear the parent (set the parent tonull
). -
getOwners
Get the domain that contains the owners of this region.- Returns:
- the domain
-
setOwners
Set the owner domain.- Parameters:
owners
- the new domain
-
getMembers
Get the domain that contains the members of this region, which does not automatically include the owners.- Returns:
- the members
-
setMembers
Set the members domain.- Parameters:
members
- the new domain
-
hasMembersOrOwners
public boolean hasMembersOrOwners()Checks whether a region has members or owners.- Returns:
- whether there are members or owners
-
isOwner
Checks whether a player is an owner of region or any of its parents.- Parameters:
player
- player to check- Returns:
- whether an owner
-
isOwner
Deprecated.Names are deprecated, this will not return owners added by UUID (LocalPlayer)Checks whether a player is an owner of region or any of its parents.- Parameters:
playerName
- player name to check- Returns:
- whether an owner
-
isMember
Checks whether a player is a member OR OWNER of the region or any of its parents.- Parameters:
player
- player to check- Returns:
- whether an owner or member
-
isMember
Deprecated.Names are deprecated, this will not return players added by UUID (LocalPlayer)Checks whether a player is a member OR OWNER of the region or any of its parents.- Parameters:
playerName
- player name to check- Returns:
- whether an owner or member
-
isMemberOnly
Checks whether a player is a member of the region or any of its parents.- Parameters:
player
- player to check- Returns:
- whether an member
-
getFlag
Get a flag's value.- Type Parameters:
T
- the flag typeV
- the type of the flag's value- Parameters:
flag
- the flag to check- Returns:
- the value or null if isn't defined
-
setFlag
Set a flag's value.- Type Parameters:
T
- the flag typeV
- the type of the flag's value- Parameters:
flag
- the flag to checkval
- the value to set
-
getFlags
Get the map of flags.- Returns:
- the map of flags currently used for this region
-
setFlags
Set the map of flags.A copy of the map will be used.
- Parameters:
flags
- the flags to set
-
copyFrom
Copy attributes from another region.- Parameters:
other
- the other region
-
getPoints
Get points of the region projected onto the X-Z plane.- Returns:
- the points
-
volume
public abstract int volume()Get the number of blocks in this region.- Returns:
- the volume of this region in blocks
-
contains
public abstract boolean contains(com.sk89q.worldedit.math.BlockVector3 pt) Check to see if a point is inside this region.- Parameters:
pt
- The point to check- Returns:
- Whether
pt
is in this region
-
contains
public boolean contains(com.sk89q.worldedit.math.BlockVector2 position) Check to see if a position is contained within this region.- Parameters:
position
- the position to check- Returns:
- whether
position
is in this region
-
contains
public boolean contains(int x, int y, int z) Check to see if a point is inside this region.- Parameters:
x
- the x coordinate to checky
- the y coordinate to checkz
- the z coordinate to check- Returns:
- whether this region contains the point
-
containsAny
Check to see if any of the points are inside this region projected onto the X-Z plane.- Parameters:
positions
- a list of positions- Returns:
- true if contained
-
getType
Get the type of region.- Returns:
- the type
-
getIntersectingRegions
Return a list of regions from the given list of regions that intersect with this region.- Parameters:
regions
- a list of regions to source from- Returns:
- the elements of
regions
that intersect with this region
-
intersects
Test whether the given region intersects with this area.- Parameters:
region
- the region to testthisArea
- an area object for this region- Returns:
- true if the two regions intersect
-
intersectsBoundingBox
Checks if the bounding box of a region intersects with with the bounding box of this region.- Parameters:
region
- the region to check- Returns:
- whether the given region intersects
-
intersectsEdges
Compares all edges of two regions to see if any of them intersect.- Parameters:
region
- the region to check- Returns:
- whether any edges of a region intersect
-
isTransient
public boolean isTransient()- Returns:
true
if this region should only be kept in memory and not be saved
-
isDirty
public boolean isDirty()Description copied from interface:ChangeTracked
Tests whether changes have been made.- Specified by:
isDirty
in interfaceChangeTracked
- Returns:
true
if this region is not transient and changes have been made.
-
setDirty
public void setDirty(boolean dirty) Description copied from interface:ChangeTracked
Set whether changes have been made.- Specified by:
setDirty
in interfaceChangeTracked
- Parameters:
dirty
- a new dirty state
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ProtectedRegion>
-
hashCode
public int hashCode() -
toString
-
isValidId
Checks to see if the given ID is a valid ID.- Parameters:
id
- the id to check- Returns:
- whether the region id given is valid
-