Package net.hollowcube.polar
Class PolarLoader
java.lang.Object
net.hollowcube.polar.PolarLoader
- All Implemented Interfaces:
net.minestom.server.instance.IChunkLoader
-
Constructor Summary
ConstructorsConstructorDescriptionPolarLoader(@NotNull InputStream inputStream) PolarLoader(@NotNull Path path) PolarLoader(@NotNull Path savePath, @NotNull PolarWorld worldData) PolarLoader(@NotNull PolarWorld world) -
Method Summary
Modifier and TypeMethodDescription@Nullable net.minestom.server.instance.ChunkloadChunk(@NotNull net.minestom.server.instance.Instance instance, int chunkX, int chunkZ) voidloadInstance(@NotNull net.minestom.server.instance.Instance instance) voidsaveChunk(@NotNull net.minestom.server.instance.Chunk chunk) voidsaveChunks(@NotNull Collection<net.minestom.server.instance.Chunk> chunks) voidsaveInstance(@NotNull net.minestom.server.instance.Instance instance) @NotNull PolarLoadersetLoadLighting(boolean loadLighting) @NotNull PolarLoadersetParallel(boolean parallel) Sets the loader to save and load in parallel.@NotNull PolarLoadersetWorldAccess(@NotNull PolarWorldAccess worldAccess) static @NotNull CompletableFuture<Void> streamLoad(@NotNull net.minestom.server.instance.InstanceContainer instance, @NotNull ReadableByteChannel is, long fileSize, @Nullable PolarDataConverter dataConverter, @Nullable PolarWorldAccess worldAccess, boolean loadLighting) Loads a polar world into an instance in a streaming manner.booleanbooleanvoidunloadChunk(net.minestom.server.instance.Chunk chunk) @NotNull PolarWorldworld()
-
Constructor Details
-
PolarLoader
- Throws:
IOException
-
PolarLoader
-
PolarLoader
- Throws:
IOException
-
PolarLoader
-
-
Method Details
-
streamLoad
@Experimental @NotNull public static @NotNull CompletableFuture<Void> streamLoad(@NotNull @NotNull net.minestom.server.instance.InstanceContainer instance, @NotNull @NotNull ReadableByteChannel is, long fileSize, @Nullable @Nullable PolarDataConverter dataConverter, @Nullable @Nullable PolarWorldAccess worldAccess, boolean loadLighting) Loads a polar world into an instance in a streaming manner.This method significantly reduces the memory overhead of loading a world and should generally be preferrable. It is still in an experimental state and could have issues. It also accesses some internal Minestom APIs and as such only works with
InstanceContainerand is more prone to issues across Minestom versions.- Parameters:
instance- The instance to load the world data into, all chunks in the polar world will be replaced.is- The input stream to read the polar world data from. The stream will be closed after reading.- Returns:
- A future that completes when the world has been fully loaded.
-
world
-
setWorldAccess
@Contract("_ -> this") @NotNull public @NotNull PolarLoader setWorldAccess(@NotNull @NotNull PolarWorldAccess worldAccess) -
setParallel
Sets the loader to save and load in parallel.
The Polar loader on its own supports parallel load out of the box, but a user implementation ofPolarWorldAccessmay not support parallel operations, so care must be taken when enabling this option.- Parameters:
parallel- True to load and save chunks in parallel, false otherwise.- Returns:
- this
-
setLoadLighting
-
supportsParallelLoading
public boolean supportsParallelLoading()- Specified by:
supportsParallelLoadingin interfacenet.minestom.server.instance.IChunkLoader
-
loadInstance
public void loadInstance(@NotNull @NotNull net.minestom.server.instance.Instance instance) - Specified by:
loadInstancein interfacenet.minestom.server.instance.IChunkLoader
-
loadChunk
@Nullable public @Nullable net.minestom.server.instance.Chunk loadChunk(@NotNull @NotNull net.minestom.server.instance.Instance instance, int chunkX, int chunkZ) - Specified by:
loadChunkin interfacenet.minestom.server.instance.IChunkLoader
-
supportsParallelSaving
public boolean supportsParallelSaving()- Specified by:
supportsParallelSavingin interfacenet.minestom.server.instance.IChunkLoader
-
saveInstance
public void saveInstance(@NotNull @NotNull net.minestom.server.instance.Instance instance) - Specified by:
saveInstancein interfacenet.minestom.server.instance.IChunkLoader
-
unloadChunk
public void unloadChunk(net.minestom.server.instance.Chunk chunk) - Specified by:
unloadChunkin interfacenet.minestom.server.instance.IChunkLoader
-
saveChunks
- Specified by:
saveChunksin interfacenet.minestom.server.instance.IChunkLoader
-
saveChunk
public void saveChunk(@NotNull @NotNull net.minestom.server.instance.Chunk chunk) - Specified by:
saveChunkin interfacenet.minestom.server.instance.IChunkLoader
-