Add flush parameter to World#save (#12330)

This commit is contained in:
Strokkur24 2025-03-24 00:37:48 +01:00 committed by GitHub
parent 7819df10a4
commit 37b9ca1f90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -1,9 +1,7 @@
package org.bukkit;
import java.io.File;
import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -2410,9 +2408,17 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
public BiomeProvider getBiomeProvider();
/**
* Saves world to disk
* Saves the world to disk
*/
public void save();
default void save() {
save(false);
}
/**
* Saves the world to disk
* @param flush Whether to wait for the chunk writer to finish
*/
void save(boolean flush);
/**
* Gets a list of all applied {@link BlockPopulator}s for this World

View File

@ -1264,13 +1264,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
// Paper end
@Override
public void save() {
public void save(boolean flush) {
org.spigotmc.AsyncCatcher.catchOp("world save"); // Spigot
this.server.checkSaveState();
boolean oldSave = this.world.noSave;
this.world.noSave = false;
this.world.save(null, false, false);
this.world.save(null, flush, false);
this.world.noSave = oldSave;
}