9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +00:00

refactor(bukkit): 改进保存

This commit is contained in:
jhqwqmc
2025-05-02 17:57:42 +08:00
parent abd3d04b6e
commit ef89cc8280

View File

@@ -113,13 +113,7 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent {
@Override
protected Operation commitBefore() {
try {
for (CEChunk ceChunk : this.needSaveChunks) {
this.ceWorld.worldDataStorage().writeChunkAt(ceChunk.chunkPos(), ceChunk, true);
}
} catch (Exception e) {
CraftEngine.instance().logger().warn("Error when recording FastAsyncWorldEdit operation chunks", e);
}
saveAllChunks();
return super.commitBefore();
}
@@ -133,6 +127,7 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent {
int blockZ = position.z();
this.processBlock(blockX, blockY, blockZ, blockState, oldBlockState);
}
saveAllChunks();
} catch (Exception e) {
CraftEngine.instance().logger().warn("Error when recording FastAsyncWorldEdit operation blocks", e);
}
@@ -156,4 +151,16 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent {
}
this.needSaveChunks.add(ceChunk);
}
private void saveAllChunks() {
try {
for (CEChunk ceChunk : this.needSaveChunks) {
System.out.println("saveAllChunks");
this.ceWorld.worldDataStorage().writeChunkAt(ceChunk.chunkPos(), ceChunk, true);
}
this.needSaveChunks.clear();
} catch (Exception e) {
CraftEngine.instance().logger().warn("Error when recording FastAsyncWorldEdit operation chunks", e);
}
}
}