Interface RegionDatabase
- All Known Implementing Classes:
MemoryRegionDatabase
,YamlRegionFile
public interface RegionDatabase
A region database stores a set of regions for a single world.
If there are multiple worlds, then there should be one region database
per world. To manage multiple region databases, consider using an
implementation of a RegionDriver
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get a displayable name for this store.loadAll
(FlagRegistry flags) Load all regions from storage and place them into the passed map.void
saveAll
(Set<ProtectedRegion> regions) Replace all the data in the store with the given collection of regions.void
saveChanges
(RegionDifference difference) Perform a partial save that only commits changes, rather than the entire region index.
-
Method Details
-
getName
String getName()Get a displayable name for this store. -
loadAll
Load all regions from storage and place them into the passed map.The map will only be modified from one thread. The keys of each map entry will be in respect to the ID of the region but transformed to be lowercase. Until this method returns, the map may not be modified by any other thread simultaneously. If an exception is thrown, then the state in which the map is left is undefined.
The provided map should have reasonably efficient
get()
andput()
calls in order to maximize performance.- Parameters:
flags
- a flag registry- Returns:
- a set of loaded regions
- Throws:
StorageException
- thrown on read error
-
saveAll
Replace all the data in the store with the given collection of regions.- Parameters:
regions
- a set of regions- Throws:
StorageException
- thrown on write error
-
saveChanges
Perform a partial save that only commits changes, rather than the entire region index.- Parameters:
difference
- the difference- Throws:
DifferenceSaveException
- thrown if partial saves are not supportedStorageException
- thrown on write error
-