install method

Future<VanillaServer> install (String serverdir, { String version, bool eula: false })

Implementation

static Future<VanillaServer> install(String serverdir, {String version, bool eula = false}) async {

  await createDirIfNotExists(serverdir);

  http.Response response = await http.get('https://launchermeta.mojang.com/mc/game/version_manifest.json');
  Map<String,dynamic> version_manifest = json.decode(response.body);
  if(version == null) version = version_manifest["latest"]["release"];

  _VersionInformations informations;

  for(Map<String,dynamic> value in version_manifest["versions"]) {
    if(value["id"] != version) continue;
    http.Response response = await http.get(value["url"]);
    Map<String,dynamic> versioninformation = json.decode(response.body);
    informations = _VersionInformations(id: value["id"],releaseTime: value["releaseTime"], time: value["time"], type: value["time"], url: value["url"], download: versioninformation["downloads"]["server"]["url"]);
    break;
  }

  DartMcLauncherVanillaProperties properties = new DartMcLauncherVanillaProperties(jar_file: "server.jar", maxram: 1024, minram: 512, minecraft_version: version, gui: false, file: "$serverdir/dart-mc-launcher.properties");
  ServerProperties serverProperties = new ServerProperties(file: '$serverdir/server.properties');
  List<Future> futures = [
    properties.save(),
    downloadFile(informations.download, '$serverdir/server.jar'),
    createEula(serverdir, eula),
    serverProperties.save()
  ];
  futures.addAll(create_start_files(serverdir, 'server.jar'));

  await Future.wait(futures);
  return VanillaServer._init(serverdir, properties, serverProperties);
}