save method
Future<void>
save({ - bool force = false,
- bool collectScriptState = true,
})
Implementation
Future<void> save({
bool force = false,
bool collectScriptState = true,
}) async {
final safeWorldName = _sanitizeWorldFileName(worldName);
var file = File(
p.join(
server.rootDirectory,
SetonixServer.worldDirectory,
'$safeWorldName${SetonixServer.worldSuffix}',
),
);
if (!await file.exists()) {
await file.create(recursive: true);
}
if (!force && !autosave) return;
if (_isSaving) return;
_isSaving = true;
try {
if (collectScriptState) {
await pluginSystem.collectState();
}
final bytes = state.save().setScriptStates(_scriptStates).exportAsBytes();
await file.writeAsBytes(bytes);
} finally {
_isSaving = false;
}
}