Minestom/src/main/java/net/minestom/server/instance/IChunkLoader.java

51 lines
1.7 KiB
Java
Raw Normal View History

package net.minestom.server.instance;
import net.minestom.server.utils.chunk.ChunkCallback;
2020-07-21 18:48:15 +02:00
/**
2020-10-12 02:56:30 +02:00
* Interface implemented to change the way chunks are loaded/saved.
* <p>
2020-10-12 02:56:30 +02:00
* See {@link MinestomBasicChunkLoader} for the default implementation used in {@link InstanceContainer}.
2020-07-21 18:48:15 +02:00
*/
public interface IChunkLoader {
2020-07-21 18:48:15 +02:00
/**
2020-10-12 02:56:30 +02:00
* Load a {@link Chunk}, all blocks should be set since the {@link ChunkGenerator} is not applied
2020-07-21 18:48:15 +02:00
*
2020-10-12 03:18:02 +02:00
* @param instance the {@link Instance} where the {@link Chunk} belong
2020-07-21 18:48:15 +02:00
* @param chunkX the chunk X
* @param chunkZ the chunk Z
2020-10-12 03:18:02 +02:00
* @param callback the callback executed when the {@link Chunk} is done loading,
* never called if the method returns false.
2020-07-21 18:48:15 +02:00
* @return true if the chunk loaded successfully, false otherwise
*/
boolean loadChunk(Instance instance, int chunkX, int chunkZ, ChunkCallback callback);
2020-07-21 18:48:15 +02:00
/**
2020-10-12 02:56:30 +02:00
* Save a {@link Chunk} with a callback for when it is done
2020-07-21 18:48:15 +02:00
*
2020-10-12 03:18:02 +02:00
* @param chunk the {@link Chunk} to save
* @param callback the callback executed when the {@link Chunk} is done saving,
* should be called even if the saving failed (you can throw an exception)
2020-07-21 18:48:15 +02:00
*/
void saveChunk(Chunk chunk, Runnable callback);
/**
2020-10-12 02:56:30 +02:00
* Does this {@link IChunkLoader} allow for multi-threaded saving of {@link Chunk}?
2020-07-21 18:48:15 +02:00
*
2020-08-07 09:14:50 +02:00
* @return true if the chunk loader supports parallel saving
*/
default boolean supportsParallelSaving() {
return false;
}
/**
2020-10-12 02:56:30 +02:00
* Does this {@link IChunkLoader} allow for multi-threaded loading of {@link Chunk}?
2020-07-21 18:48:15 +02:00
*
2020-08-07 09:14:50 +02:00
* @return true if the chunk loader supports parallel loading
*/
default boolean supportsParallelLoading() {
return false;
}
}