public class JavaChunkStore extends java.lang.Object implements ChunkStore
Modifier and Type | Class and Description |
---|---|
static interface |
JavaChunkStore.RegionVisitor |
ChunkStore.ChunkVisitor
Constructor and Description |
---|
JavaChunkStore(Platform platform,
java.io.File regionDir,
int minHeight,
int maxHeight) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the chunk provider, flushing any changes and closing any system
resources.
|
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()
Saves all dirty chunks and closes all files.
|
Chunk |
getChunk(int x,
int z)
Load a chunk.
|
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.
|
Chunk |
getChunkForEditing(int x,
int z)
Load a chunk.
|
boolean |
isChunkPresent(int x,
int z)
Determine whether a chunk is present.
|
static void |
main(java.lang.String[] args) |
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.
|
boolean |
visitRegions(JavaChunkStore.RegionVisitor visitor,
boolean readOnly,
java.lang.String operation,
java.util.Set<DataType> dataTypes) |
public JavaChunkStore(Platform platform, java.io.File regionDir, int minHeight, int maxHeight)
public boolean visitRegions(JavaChunkStore.RegionVisitor visitor, boolean readOnly, java.lang.String operation, java.util.Set<DataType> dataTypes) throws java.io.IOException
java.io.IOException
public int getChunkCount()
ChunkStore
getChunkCount
in interface ChunkStore
public java.util.Set<MinecraftCoords> getChunkCoords()
ChunkStore
getChunkCoords
in interface ChunkStore
public boolean visitChunks(ChunkStore.ChunkVisitor visitor)
ChunkStore
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.
visitChunks
in interface ChunkStore
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
.public boolean visitChunksForEditing(ChunkStore.ChunkVisitor visitor)
ChunkStore
visitChunksForEditing
in interface ChunkStore
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
.public void saveChunk(Chunk chunk)
ChunkStore
ChunkStore.doInTransaction(Runnable)
, or after ChunkStore.flush()
has been
called.saveChunk
in interface ChunkStore
chunk
- The chunk to save.public void doInTransaction(java.lang.Runnable task)
ChunkStore
doInTransaction
in interface ChunkStore
task
- The task to execute in one chunk store transaction.public void flush()
flush
in interface ChunkStore
public boolean isChunkPresent(int x, int z)
ChunkProvider
isChunkPresent
in interface ChunkProvider
x
- The X coordinate to check.z
- The Z coordinate to check.true
if the chunk provider contains a chunk at the
specified coordinates.public Chunk getChunk(int x, int z)
null
if the chunk does not exist in the map.getChunk
in interface ChunkProvider
x
- The X coordinate in the Minecraft coordinate system of the chunk to load.z
- The Z coordinate in the Minecraft coordinate system of the chunk to load.null
if the chunk does not exist in the map.public Chunk getChunkForEditing(int x, int z)
null
if the chunk does not exist in the map.getChunkForEditing
in interface ChunkProvider
x
- The X coordinate in the Minecraft coordinate system of the chunk to load.z
- The Z coordinate in the Minecraft coordinate system of the chunk to load.null
if the chunk does not exist in the map.public void close()
ChunkProvider
close
in interface java.lang.AutoCloseable
close
in interface ChunkProvider
public static void main(java.lang.String[] args)