Interface RegionIndex
- All Superinterfaces:
ChangeTracked
- All Known Subinterfaces:
ConcurrentRegionIndex
- All Known Implementing Classes:
ChunkHashTable
,HashMapIndex
,PriorityRTreeIndex
An index of regions to allow for fast lookups of regions by their ID and
through spatial queries.
Indexes may be thread-unsafe.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ProtectedRegion region) Add a region to this index, replacing any existing one with the same name (equality determined usingNormal
).void
addAll
(Collection<ProtectedRegion> regions) Add a list of regions to this index, replacing any existing one with the same name (equality determined usingNormal
).void
apply
(Predicate<ProtectedRegion> consumer) Apply the given predicate to all the regions in the index until there are no more regions or the predicate returns false.void
applyContaining
(com.sk89q.worldedit.math.BlockVector3 position, Predicate<ProtectedRegion> consumer) Apply the given predicate to all regions that contain the given position until there are no more regions or the predicate returns false.void
applyIntersecting
(ProtectedRegion region, Predicate<ProtectedRegion> consumer) Apply the given predicate to all regions that intersect the given region until there are no more regions or the predicate returns false.void
bias
(com.sk89q.worldedit.math.BlockVector2 chunkPosition) Bias the given chunk for faster lookups (put it in a hash table, etc.).void
biasAll
(Collection<com.sk89q.worldedit.math.BlockVector2> chunkPosition) Bias the given chunk for faster lookups (put it in a hash table, etc.).boolean
Test whether the index contains a region named by the given name (equality determined usingNormal
).void
forget
(com.sk89q.worldedit.math.BlockVector2 chunkPosition) No longer bias the given chunk for faster lookup.void
Clearly all extra cache data created by any calls tobias(BlockVector2)
.Get the region named by the given name (equality determined usingNormal
).Get the list of changed or removed regions since last call and clear those lists.remove
(String id, RemovalStrategy strategy) Remove a region from the index with the given name.void
setDirty
(RegionDifference difference) Set the index to be dirty using the given difference.int
size()
Return the number of regions in the index.values()
Get an unmodifiable collection of regions stored in this index.Methods inherited from interface com.sk89q.worldguard.util.ChangeTracked
isDirty, setDirty
-
Method Details
-
bias
void bias(com.sk89q.worldedit.math.BlockVector2 chunkPosition) Bias the given chunk for faster lookups (put it in a hash table, etc.).Implementations may choose to do nothing.
- Parameters:
chunkPosition
- the chunk position
-
biasAll
Bias the given chunk for faster lookups (put it in a hash table, etc.).Implementations may choose to do nothing.
- Parameters:
chunkPosition
- the chunk position
-
forget
void forget(com.sk89q.worldedit.math.BlockVector2 chunkPosition) No longer bias the given chunk for faster lookup.- Parameters:
chunkPosition
- the chunk position
-
forgetAll
void forgetAll()Clearly all extra cache data created by any calls tobias(BlockVector2)
. -
add
Add a region to this index, replacing any existing one with the same name (equality determined usingNormal
).The parents of the region will also be added to the index.
- Parameters:
region
- the region
-
addAll
Add a list of regions to this index, replacing any existing one with the same name (equality determined usingNormal
).The parents of the region will also be added to the index.
- Parameters:
regions
- a collections of regions
-
remove
Remove a region from the index with the given name.- Parameters:
id
- the name of the regionstrategy
- what to do with children- Returns:
- a list of removed regions where the first entry is the region specified by
id
-
contains
Test whether the index contains a region named by the given name (equality determined usingNormal
).- Parameters:
id
- the name of the region- Returns:
- true if the index contains the region
-
get
Get the region named by the given name (equality determined usingNormal
).- Parameters:
id
- the name of the region- Returns:
- a region or
null
-
apply
Apply the given predicate to all the regions in the index until there are no more regions or the predicate returns false.- Parameters:
consumer
- a predicate that returns true to continue iterating
-
applyContaining
void applyContaining(com.sk89q.worldedit.math.BlockVector3 position, Predicate<ProtectedRegion> consumer) Apply the given predicate to all regions that contain the given position until there are no more regions or the predicate returns false.- Parameters:
position
- the positionconsumer
- a predicate that returns true to continue iterating
-
applyIntersecting
Apply the given predicate to all regions that intersect the given region until there are no more regions or the predicate returns false.- Parameters:
region
- the intersecting regionconsumer
- a predicate that returns true to continue iterating
-
size
int size()Return the number of regions in the index.- Returns:
- the number of regions
-
getAndClearDifference
RegionDifference getAndClearDifference()Get the list of changed or removed regions since last call and clear those lists.- Returns:
- the difference
-
setDirty
Set the index to be dirty using the given difference.- Parameters:
difference
- the difference
-
values
Collection<ProtectedRegion> values()Get an unmodifiable collection of regions stored in this index.- Returns:
- a collection of regions
-