load static method

Future<SetonixServer> load({
  1. String? worldFile,
  2. bool disableLoading = false,
})

Implementation

static Future<SetonixServer> load({
  String? worldFile,
  bool disableLoading = false,
}) async {
  final assetManager = ServerAssetManager();
  final consoler = Consoler(
    defaultProgramConfig: DefaultProgramConfiguration(
      description: "Setonix server",
    ),
  );
  await _runStaticLogZone(
      consoler, () => assetManager.init(console: consoler));
  worldFile ??= defaultWorldFile;
  final file = File(worldFile);
  SetonixData? data;
  if (!disableLoading && await file.exists()) {
    final bytes = await file.readAsBytes();
    data = SetonixData.fromData(bytes);
  }
  data ??= SetonixData.empty().setInfo(GameInfo(
    packs: assetManager.packs.map((e) => e.key).toList(),
  ));
  return SetonixServer._(worldFile, consoler, data, assetManager);
}