save method

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

Implementation

Future<void> save({bool force = false}) async {
  var file = File(
    '${worldName == defaultWorldName ? SetonixServer.defaultWorldName : '${SetonixServer.worldDirectory}/$worldName'}${SetonixServer.worldSuffix}',
  );
  if (!await file.exists()) {
    await file.create(recursive: true);
  }
  if (!force && autosave) return;
  final bytes = state.save().exportAsBytes();
  await file.writeAsBytes(bytes);
}