Example #1
0
        public void SaveManifest(MinecraftManifest manifest)
        {
            var seri = new JavaScriptSerializer();
            var text = seri.Serialize(manifest);
            var sw   = new StreamWriter(new FileStream(VersionManifestPath, FileMode.OpenOrCreate));

            sw.Write(text);
            sw.Close();
        }
Example #2
0
        public void InstallLaunchWrapper()
        {
            const string LAUNCHWRAPPER_VERSION = "1.12";

            if (!this.LaunchWithLaunchWrapper)
            {
                var mcdir      = LauncherMain.Instance.Settings.MinecraftFolderName;
                var libraryloc = mcdir + string.Format(
                    "libraries\\net\\minecraft\\launchwrapper\\{0}\\", LAUNCHWRAPPER_VERSION);
                if (!Directory.Exists(libraryloc))
                {
                    Directory.CreateDirectory(libraryloc);
                }
                libraryloc += string.Format("launchwrapper-{0}.jar", LAUNCHWRAPPER_VERSION);
                if (!File.Exists(libraryloc))
                {
                    using (var wc = new WebClient())
                    {
                        string url = string.Format(
                            "https://libraries.minecraft.net/net/minecraft/launchwrapper/{0}/launchwrapper-{0}.jar",
                            LAUNCHWRAPPER_VERSION
                            );
                        if (LauncherMain.Instance.Settings.UseBMCL)
                        {
                            url = url.Replace("libraries.minecraft.net",
                                              "bmclapi2.bangbang93.com/libraries");
                        }
                        wc.DownloadFile(url, libraryloc);
                    }
                }
                var manifest = MinecraftManifest.AnalyzeFromVersion(this);
                manifest.mainClass = "net.minecraft.launchwrapper.Launch";
                var wrapperLibrary = new MinecraftLibrary();
                wrapperLibrary.name = string.Format("net.minecraft:launchwrapper:{0}", LAUNCHWRAPPER_VERSION);
                manifest.libraries.Add(wrapperLibrary);
                this.SaveManifest(manifest);
            }
        }