public static async Task SaveAssetIndexes(IEnumerable <VersionManifest> manifests)
        {
            JsonSerializer js = new JsonSerializer()
            {
                Formatting = Formatting.Indented
            };

            await Task.WhenAll(
                manifests.Select(async x =>
            {
                AssetGroupIndex ai = await x.AssetGroup.GetIndex();
                Directory.CreateDirectory("data/assets/indexes");
                using (FileStream fs = File.Open("data/assets/indexes/" + x.AssetGroup.ID + ".json", FileMode.Create, FileAccess.Write, FileShare.Read))
                    using (StreamWriter sw = new StreamWriter(fs))
                        using (JsonTextWriter jw = new JsonTextWriter(sw))
                            js.Serialize(jw, ai.DescribedBy);
                Log.FileNew("data/assets/indexes/" + x.AssetGroup.ID + ".json");
            }));
        }
        public static async Task WriteScripts(Config cfg, TransformedTarget[] tv, MCDownload downloader)
        {
            foreach (var t in tv)
            {
                MCVersion       v  = downloader.GetRemoteVersion(t.VersionID);
                VersionManifest vm = await v.GetManifest();

                GameArguments combined = new GameArguments(t.From.JVMArguments)
                                         + vm.JavaArguments
                                         //  (vm.LoggingSettings.ContainsKey("client") ? vm.LoggingSettings["client"].GameArgument : new GameArguments("")) +
                                         + new GameArguments("me.basiqueevangelist.launchergenerator.authhelper.MinecraftAuthHelper")
                                         + new GameArguments(vm.MainClass)
                                         + new GameArguments(cfg.Username)
                                         + new GameArguments(t.From.NewGameArguments)
                                         + vm.MinecraftArguments;
                AssetGroupIndex ai = await vm.AssetGroup.GetIndex();

                Dictionary <string, string> variables = new Dictionary <string, string>
                {
                    ["auth_player_name"]  = "@USERNAME",
                    ["version_name"]      = t.VersionID,
                    ["game_directory"]    = ".",
                    ["assets_root"]       = "../../assets",
                    ["game_assets"]       = "../../assets" + (ai.IsVirtual ? "/virtual/" + vm.AssetGroup.ID : ""),
                    ["assets_index_name"] = vm.AssetGroup.ID,
                    ["auth_uuid"]         = "@UUID",
                    ["auth_access_token"] = "@ACCESSTOKEN",
                    ["user_type"]         = "mojang",
                    ["version_type"]      = v.Type.ToString(),
                    ["classpath"]         = Classpath(vm),
                    ["natives_directory"] = "../../versions/" + t.VersionID + "/natives",
                    ["launcher_name"]     = "LauncherGenerator",
                    ["launcher_version"]  = "0.1a",
                    ["path"] = vm.LoggingSettings.ContainsKey("client") ? "../../assets/log_configs/" + ((RemoteFile)vm.LoggingSettings["client"].File).Name : ""
                };
                string[] cargs = combined.Process(variables, Array.Empty <string>());
                string   fname = "data/" + t.From.Name + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".bat" : ".sh");
                using (FileStream fs = File.Open(fname, System.IO.FileMode.Create, FileAccess.Write, FileShare.Read))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                        {
                            sw.WriteLine("title Minecraft " + t.VersionID + " launch script");
                            sw.WriteLine("cd %~dp0");
                        }
                        else
                        {
                            sw.WriteLine("#!/bin/sh");
                            sw.WriteLine("printf \"\\033]0;Minecraft " + t.VersionID + " launch script\\007\"");
                            sw.WriteLine("cd $(cd `dirname $0` && pwd)");
                        }
                        sw.WriteLine("cd profiles/" + t.From.Profile);
                        sw.WriteLine(t.From.JavaPath.Replace("\\", "\\\\") + " " + GameArguments.FoldArgs(cargs));
                        // sw.WriteLine("pause");
                    }
                Log.FileNew(fname);
                if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                {
                    UnixFileInfo ufi = new UnixFileInfo(fname);
                    ufi.FileAccessPermissions |= FileAccessPermissions.UserExecute | FileAccessPermissions.GroupRead | FileAccessPermissions.OtherExecute;
                }
            }

            var assembly = typeof(Program).Assembly;

            using (Stream jarIn = assembly.GetManifestResourceStream("LauncherGenerator.MCAuthHelper.jar") ?? throw new NotImplementedException())
                using (FileStream jarOut = File.Open("data/MCAuthHelper.jar", FileMode.Create, FileAccess.Write, FileShare.Delete))
                    await jarIn.CopyToAsync(jarOut);
        }