Fix paper-implementation not saving the world on the main thread

This commit is contained in:
Lukas Rieger (Blue) 2024-03-14 09:17:22 +01:00
parent e9e7042aed
commit a0e9180360
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -28,11 +28,14 @@
import de.bluecolored.bluemap.core.resources.datapack.DataPack;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.lang.ref.WeakReference;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
public class BukkitWorld implements ServerWorld {
@ -71,7 +74,10 @@ public boolean persistWorldChanges() {
if (!FoliaSupport.IS_FOLIA) {
World world = delegate.get();
if (world != null) {
world.save();
Executor mainThread = Bukkit.getScheduler().getMainThreadExecutor(BukkitPlugin.getInstance());
CompletableFuture
.runAsync(world::save, mainThread)
.join();
return true;
}
}