Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add world save mode for ServerWorld#save() to support flush #3688

Open
wants to merge 2 commits into
base: api-10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SpongeAPI
Original file line number Diff line number Diff line change
Expand Up @@ -77,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 @@ -195,14 +194,23 @@ public Path directory() {
return ((ServerLevelBridge) this).bridge$getLevelSave().getLevelPath(LevelResource.ROOT);
}

@Override
public boolean save() throws IOException {
private boolean save(final boolean flush) {
final SerializationBehavior behavior = ((PrimaryLevelDataBridge) this.serverLevelData).bridge$serializationBehavior().orElse(SerializationBehavior.AUTOMATIC);
((ServerLevelBridge) this).bridge$setManualSave(true);
this.shadow$save(null, false, false);
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
Loading