public async Task <ulong> CreateServerAsync(string serverName, ServerVersion serverVersion, VanillaSettings settings, JavaSettings javaSettings, string worldPath) { serverName = RefineName(serverName); string serverPath = Path.Combine(_application.EntityPath, serverName); if (string.IsNullOrEmpty(settings.LevelName)) { settings.LevelName = "world"; } DirectoryInfo directoryInfo = Directory.CreateDirectory(serverPath); // TODO CKE serverVersion.Build = await VersionManager.Instance.GetLatestBuild(serverVersion); Server server = new Server(serverName, serverVersion, settings, javaSettings); _context.ServerSet.Add(server); //Download server.jar var downloadProgress = new Progress <float>(); downloadProgress.ProgressChanged += (_, f) => { // TODO CKE send notification update }; await _download.DownloadJarAsync(server, downloadProgress, CancellationToken.None); //Move World Files if (worldPath != null) { //TODO CKE add world import //new FileImporter().DirectoryCopy(worldPath, // Path.Combine(directoryInfo.FullName, server.VanillaSettings.LevelName), true); } //Writing necessary files await _fileWriter.WriteEula(Path.Combine(_application.EntityPath, directoryInfo.Name)); await _fileWriter.WriteServerSettings(Path.Combine(_application.EntityPath, directoryInfo.Name), settings.SettingsDictionary); await _context.SaveChangesAsync(); return(server.Id); }