Class PolarLoader

java.lang.Object
net.hollowcube.polar.PolarLoader
All Implemented Interfaces:
net.minestom.server.instance.IChunkLoader

public class PolarLoader extends Object implements net.minestom.server.instance.IChunkLoader
  • Constructor Details

  • 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 InstanceContainer and 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

      @NotNull public @NotNull PolarWorld world()
    • setWorldAccess

      @Contract("_ -> this") @NotNull public @NotNull PolarLoader setWorldAccess(@NotNull @NotNull PolarWorldAccess worldAccess)
    • setParallel

      @Contract("_ -> this") @NotNull public @NotNull PolarLoader setParallel(boolean parallel)
      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 of PolarWorldAccess may 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

      @Contract("_ -> this") @NotNull public @NotNull PolarLoader setLoadLighting(boolean loadLighting)
    • supportsParallelLoading

      public boolean supportsParallelLoading()
      Specified by:
      supportsParallelLoading in interface net.minestom.server.instance.IChunkLoader
    • loadInstance

      public void loadInstance(@NotNull @NotNull net.minestom.server.instance.Instance instance)
      Specified by:
      loadInstance in interface net.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:
      loadChunk in interface net.minestom.server.instance.IChunkLoader
    • supportsParallelSaving

      public boolean supportsParallelSaving()
      Specified by:
      supportsParallelSaving in interface net.minestom.server.instance.IChunkLoader
    • saveInstance

      public void saveInstance(@NotNull @NotNull net.minestom.server.instance.Instance instance)
      Specified by:
      saveInstance in interface net.minestom.server.instance.IChunkLoader
    • unloadChunk

      public void unloadChunk(net.minestom.server.instance.Chunk chunk)
      Specified by:
      unloadChunk in interface net.minestom.server.instance.IChunkLoader
    • saveChunks

      public void saveChunks(@NotNull @NotNull Collection<net.minestom.server.instance.Chunk> chunks)
      Specified by:
      saveChunks in interface net.minestom.server.instance.IChunkLoader
    • saveChunk

      public void saveChunk(@NotNull @NotNull net.minestom.server.instance.Chunk chunk)
      Specified by:
      saveChunk in interface net.minestom.server.instance.IChunkLoader