public final class RegionManager extends Object
| Constructor and Description |
|---|
RegionManager(RegionDatabase store,
com.google.common.base.Supplier<? extends ConcurrentRegionIndex> indexFactory)
Create a new index.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRegion(ProtectedRegion region)
Aad a region to the manager.
|
ApplicableRegionSet |
getApplicableRegions(org.bukkit.Location loc)
Helper method for
getApplicableRegions(Vector) using Bukkit
locations. |
ApplicableRegionSet |
getApplicableRegions(ProtectedRegion region)
Query for effective flags and owners for the area represented
by the given region.
|
ApplicableRegionSet |
getApplicableRegions(com.sk89q.worldedit.Vector position)
Query for effective flags and owners for the given positive.
|
List<String> |
getApplicableRegionsIDs(com.sk89q.worldedit.Vector position)
Get a list of region names for regions that contain the given position.
|
String |
getName()
Get a displayable name for this store.
|
ProtectedRegion |
getRegion(String id)
Get the region named by the given name (equality determined using
Normal). |
int |
getRegionCountOfPlayer(LocalPlayer player)
Get the number of regions that are owned by the given player.
|
Map<String,ProtectedRegion> |
getRegions()
Get an unmodifiable map of regions containing the state of the
index at the time of call.
|
boolean |
hasRegion(String id)
Return whether the index contains a region by the given name,
with equality determined by
Normal. |
void |
load()
Load regions from storage and replace the index on this manager with
the regions loaded from the store.
|
void |
loadChunk(com.sk89q.worldedit.Vector2D position)
Load the regions for a chunk.
|
void |
loadChunks(Collection<com.sk89q.worldedit.Vector2D> positions)
Load the regions for a chunk.
|
ProtectedRegion |
matchRegion(String pattern)
Matches a region using either the pattern
#{region_index} or
simply by the exact name of the region. |
boolean |
overlapsUnownedRegion(ProtectedRegion region,
LocalPlayer player)
Return whether there are any regions intersecting the given region that
are not owned by the given player.
|
Set<ProtectedRegion> |
removeRegion(String id)
Remove a region from the index with the given name, opting to remove
the children of the removed region.
|
Set<ProtectedRegion> |
removeRegion(String id,
RemovalStrategy strategy)
Remove a region from the index with the given name.
|
void |
save()
Save a snapshot of all the regions as it is right now to storage.
|
boolean |
saveChanges()
Save changes to the region index to disk, preferring to only save
the changes (rather than the whole index), but choosing to save the
whole index if the underlying store does not support partial saves.
|
void |
setRegions(Collection<ProtectedRegion> regions)
Replace the index with the regions in the given collection.
|
void |
setRegions(Map<String,ProtectedRegion> regions)
Replace the index with the regions in the given map.
|
int |
size()
Get the number of regions.
|
void |
unloadChunk(com.sk89q.worldedit.Vector2D position)
Unload the regions for a chunk.
|
public RegionManager(RegionDatabase store, com.google.common.base.Supplier<? extends ConcurrentRegionIndex> indexFactory)
store - the region storeindexFactory - the factory for creating new instances of the indexpublic String getName()
public void load()
throws StorageException
This method will block until the save completes, but it will not block access to the region data from other threads, nor will it prevent the creation or modification of regions in the index while a new collection of regions is loaded from storage.
StorageException - thrown when loading failspublic void save()
throws StorageException
StorageException - thrown on save errorpublic boolean saveChanges()
throws StorageException
This method does nothing if there are no changes.
StorageException - thrown on save errorpublic void loadChunk(com.sk89q.worldedit.Vector2D position)
position - the positionpublic void loadChunks(Collection<com.sk89q.worldedit.Vector2D> positions)
positions - a collection of positionspublic void unloadChunk(com.sk89q.worldedit.Vector2D position)
position - the positionpublic Map<String,ProtectedRegion> getRegions()
This call is relatively heavy (and may block other threads), so refrain from calling it frequently.
public void setRegions(Map<String,ProtectedRegion> regions)
The parents of the regions will also be added to the index, even if they are not in the provided map.
regions - a map of regionspublic void setRegions(Collection<ProtectedRegion> regions)
The parents of the regions will also be added to the index, even if they are not in the provided map.
regions - a collection of regionspublic void addRegion(ProtectedRegion region)
The parents of the region will also be added to the index.
region - the regionpublic boolean hasRegion(String id)
Normal.id - the name of the region@Nullable public ProtectedRegion getRegion(String id)
Normal).id - the name of the regionnull@Nullable public ProtectedRegion matchRegion(String pattern)
#{region_index} or
simply by the exact name of the region.pattern - the pattern@Nullable public Set<ProtectedRegion> removeRegion(String id)
id - the name of the regionid@Nullable public Set<ProtectedRegion> removeRegion(String id, RemovalStrategy strategy)
id - the name of the regionstrategy - what to do with childrenidpublic ApplicableRegionSet getApplicableRegions(com.sk89q.worldedit.Vector position)
position - the positionpublic ApplicableRegionSet getApplicableRegions(ProtectedRegion region)
region - the regionpublic List<String> getApplicableRegionsIDs(com.sk89q.worldedit.Vector position)
position - the positionpublic boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player)
region - the regionplayer - the playerpublic int size()
public int getRegionCountOfPlayer(LocalPlayer player)
player - the playerpublic ApplicableRegionSet getApplicableRegions(org.bukkit.Location loc)
getApplicableRegions(Vector) using Bukkit
locations.loc - the locationApplicableRegionSetCopyright © 2015. All Rights Reserved.