wait for all loaded chunks to be saved

This commit is contained in:
Julian Krings
2024-08-22 16:20:16 +02:00
parent 3dfdb9654a
commit 386131ddf0
2 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -126,8 +126,8 @@ allprojects {
dependencies { dependencies {
// Provided or Classpath // Provided or Classpath
compileOnly 'org.projectlombok:lombok:1.18.24' compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.projectlombok:lombok:1.18.34'
// Shaded // Shaded
implementation 'com.dfsek:Paralithic:0.4.0' implementation 'com.dfsek:Paralithic:0.4.0'
@@ -39,17 +39,16 @@ import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter; import lombok.Getter;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.QuartPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.ProtoChunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@@ -264,9 +263,11 @@ public class Headless implements IHeadless, LevelHeightAccessor {
public void close() throws IOException { public void close() throws IOException {
if (closed) return; if (closed) return;
try { try {
while (loadedChunks.get() > 0)
J.sleep(50);
executor.shutdown(); executor.shutdown();
try { try {
if (executor.awaitTermination(10, TimeUnit.SECONDS)) if (executor.awaitTermination(5, TimeUnit.SECONDS))
executor.shutdownNow(); executor.shutdownNow();
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {}
storage.close(); storage.close();