save method

Future<void> save({
  1. bool force = false,
})

Implementation

Future<void> save({bool force = false}) 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;
  final bytes = state.save().exportAsBytes();
  await file.writeAsBytes(bytes);
}