public interface ChunkStore extends ChunkProvider
Created by Pepijn on 14-12-2016.
Modifier and Type | Interface and Description |
---|---|
static interface |
ChunkStore.ChunkVisitor
A visitor of chunks.
|
Modifier and Type | Method and Description |
---|---|
void |
doInTransaction(java.lang.Runnable task)
Run a task, for example saving more than one chunk, in one transaction
against the chunk store, which may improve performance.
|
void |
flush()
Make sure all previously saved chunks are written to disk.
|
java.util.Set<MinecraftCoords> |
getChunkCoords()
Returns the coordinates of all the chunks that currently exist in the
store.
|
int |
getChunkCount()
Return a total count of all the chunks currently in the store.
|
void |
saveChunk(Chunk chunk)
Save a chunk to the store.
|
boolean |
visitChunks(ChunkStore.ChunkVisitor visitor)
Visit all known chunks.
|
boolean |
visitChunksForEditing(ChunkStore.ChunkVisitor visitor)
Visit all known chunks for editing.
|
close, getChunk, getChunkForEditing, isChunkPresent
int getChunkCount()
java.util.Set<MinecraftCoords> getChunkCoords()
boolean visitChunks(ChunkStore.ChunkVisitor visitor)
Note that the order is undefined, allowing the provider to use as efficient an implementation as is possible. The provided chunks may be read-only.
Also note that to improve performance the process may be parallelised. In other words the visitor may be invoked concurrently for different chunks and must therefore be thread-safe. It also means that if the visitor returns false, the iteration may not stop immediately.
visitor
- The visitor to invoke for each chunk.true
if all chunks were visited; false
if not all chunks may have been visited because
the visitor returned false
.boolean visitChunksForEditing(ChunkStore.ChunkVisitor visitor)
visitor
- The visitor to invoke for each chunk.true
if all chunks were visited; false
if not all chunks may have been visited because
the visitor returned false
.void saveChunk(Chunk chunk)
doInTransaction(Runnable)
, or after flush()
has been
called.chunk
- The chunk to save.void doInTransaction(java.lang.Runnable task)
task
- The task to execute in one chunk store transaction.void flush()
doInTransaction(Runnable)
.