Skip to content

Commit

Permalink
Return to ServerWorld#saveAndFlush() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Lignium committed Jun 17, 2023
1 parent 91657c9 commit e866f33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.spongepowered.api.util.Ticks;
import org.spongepowered.api.world.BlockChangeFlag;
import org.spongepowered.api.world.SerializationBehavior;
import org.spongepowered.api.world.WorldSaveMode;
import org.spongepowered.api.world.border.WorldBorder;
import org.spongepowered.api.world.chunk.WorldChunk;
import org.spongepowered.api.world.generation.ChunkGenerator;
Expand All @@ -78,7 +77,6 @@
import org.spongepowered.math.vector.Vector3d;
import org.spongepowered.math.vector.Vector3i;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -196,15 +194,23 @@ public Path directory() {
return ((ServerLevelBridge) this).bridge$getLevelSave().getLevelPath(LevelResource.ROOT);
}

@Override
public boolean save(final WorldSaveMode worldSaveMode) throws IOException {
private boolean save(final boolean flush) {
final SerializationBehavior behavior = ((PrimaryLevelDataBridge) this.serverLevelData).bridge$serializationBehavior().orElse(SerializationBehavior.AUTOMATIC);
((ServerLevelBridge) this).bridge$setManualSave(true);
final boolean flush = worldSaveMode.equals(WorldSaveMode.SAVE_AND_FLUSH);
this.shadow$save(null, flush, false);
return !behavior.equals(SerializationBehavior.NONE);
}

@Override
public boolean save() {
return save(false);
}

@Override
public boolean saveAndFlush() {
return save(true);
}

@Override
public boolean unloadChunk(final WorldChunk chunk) {
this.shadow$unload((LevelChunk) Objects.requireNonNull(chunk, "chunk"));
Expand Down

0 comments on commit e866f33

Please sign in to comment.