Skip to content

Commit

Permalink
Fix paper-implementation not saving the world on the main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Mar 14, 2024
1 parent e9e7042 commit a0e9180
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit a0e9180

Please sign in to comment.