2020-06-30 18:07:47 +02:00
|
|
|
package net.minestom.server.instance;
|
|
|
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Interface implemented to change the way chunks are loaded/saved
|
|
|
|
* see {@link MinestomBasicChunkLoader} for the default implementation used in {@link InstanceContainer}
|
|
|
|
*/
|
2020-06-30 18:07:47 +02:00
|
|
|
public interface IChunkLoader {
|
2020-07-21 18:48:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a specific chunk
|
|
|
|
*
|
|
|
|
* @param instance the instance where the chunk belong
|
|
|
|
* @param chunkX the chunk X
|
|
|
|
* @param chunkZ the chunk Z
|
|
|
|
* @param callback the callback executed when the chunk is done loading
|
|
|
|
* @return true if the chunk loaded successfully, false otherwise
|
|
|
|
*/
|
2020-06-30 18:12:09 +02:00
|
|
|
boolean loadChunk(Instance instance, int chunkX, int chunkZ, Consumer<Chunk> callback);
|
2020-07-21 18:48:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save a specific chunk with a callback for when it is done
|
|
|
|
*
|
|
|
|
* @param chunk the chunk to save
|
|
|
|
* @param callback the callback executed when the chunk is done saving
|
|
|
|
*/
|
2020-06-30 18:07:47 +02:00
|
|
|
void saveChunk(Chunk chunk, Runnable callback);
|
2020-07-07 13:41:55 +02:00
|
|
|
|
|
|
|
/**
|
2020-07-21 18:48:15 +02:00
|
|
|
* Does this ChunkLoader allow for multi-threaded saving of chunks?
|
|
|
|
*
|
2020-07-07 13:41:55 +02:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
default boolean supportsParallelSaving() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-21 18:48:15 +02:00
|
|
|
* Does this ChunkLoader allow for multi-threaded loading of chunks?
|
|
|
|
*
|
2020-07-07 13:41:55 +02:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
default boolean supportsParallelLoading() {
|
|
|
|
return false;
|
|
|
|
}
|
2020-06-30 18:07:47 +02:00
|
|
|
}
|