mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 15:07:36 +02:00
Do not force a non-null storage location for chunks saving
This commit is contained in:
parent
09582cffc1
commit
b294ae73e4
@ -168,19 +168,17 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
public abstract Chunk getChunk(int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Save a {@link Chunk} into the defined {@link StorageLocation}
|
||||
* Save a {@link Chunk}
|
||||
*
|
||||
* @param chunk the {@link Chunk} to save
|
||||
* @param callback called when the {@link Chunk} is done saving
|
||||
* @throws NullPointerException if {@link #getStorageLocation()} returns null
|
||||
*/
|
||||
public abstract void saveChunkToStorage(Chunk chunk, Runnable callback);
|
||||
|
||||
/**
|
||||
* Save multiple chunks into the defined {@link StorageLocation}
|
||||
* Save multiple chunks
|
||||
*
|
||||
* @param callback called when the chunks are done saving
|
||||
* @throws NullPointerException if {@link #getStorageLocation()} returns null
|
||||
*/
|
||||
public abstract void saveChunksToStorage(Runnable callback);
|
||||
|
||||
@ -704,7 +702,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a chunk to the instance {@link StorageLocation} without any callback
|
||||
* Save a chunk without any callback
|
||||
*
|
||||
* @param chunk the chunk to save
|
||||
*/
|
||||
@ -713,7 +711,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all chunks to the instance {@link StorageLocation} without any callback
|
||||
* Save all chunks without any callback
|
||||
*/
|
||||
public void saveChunksToStorage() {
|
||||
saveChunksToStorage(null);
|
||||
|
@ -418,13 +418,11 @@ public class InstanceContainer extends Instance {
|
||||
|
||||
@Override
|
||||
public void saveChunkToStorage(Chunk chunk, Runnable callback) {
|
||||
Check.notNull(getStorageLocation(), "You cannot save the chunk if no StorageLocation has been defined");
|
||||
chunkLoader.saveChunk(chunk, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChunksToStorage(Runnable callback) {
|
||||
Check.notNull(getStorageLocation(), "You cannot save the instance if no StorageLocation has been defined");
|
||||
if (chunkLoader.supportsParallelSaving()) {
|
||||
ExecutorService parallelSavingThreadPool = new MinestomThread(MinecraftServer.THREAD_COUNT_PARALLEL_CHUNK_SAVING, MinecraftServer.THREAD_NAME_PARALLEL_CHUNK_SAVING, true);
|
||||
getChunks().forEach(c -> parallelSavingThreadPool.execute(() -> {
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.instance;
|
||||
import net.minestom.server.storage.StorageLocation;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.chunk.ChunkCallback;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -26,6 +27,7 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
|
||||
|
||||
@Override
|
||||
public void saveChunk(Chunk chunk, Runnable callback) {
|
||||
Check.notNull(storageLocation, "You cannot save the chunk if no StorageLocation has been defined");
|
||||
if (storageLocation == null) {
|
||||
callback.run();
|
||||
LOGGER.warn("No storage location to save chunk!");
|
||||
|
Loading…
Reference in New Issue
Block a user