コード例 #1
0
ファイル: PathForm.cs プロジェクト: KALITRIK/345-Launcher
        private void btnSetDefault_Click(object sender, EventArgs e)
        {
            var defaultPath = MinecraftPath.GetOSDefaultPath();

            apply(new MinecraftPath(defaultPath));
            // When you press path is changes to default Appdata/Roaming/.minecraft
        }
コード例 #2
0
        /// <summary>
        /// Verifica se il modpack era gia stato installato
        /// </summary>
        /// <param name="ModpackBaseDirectory"></param>
        /// <param name="ModpackModsDirectory"></param>
        /// <returns>Restituisce un valore booleano indicante se il modpack era gia stato installato</returns>
        static public bool isModpackInstalled(string ModpackBaseDirectory, string ModpackModsDirectory)
        {
            if (Directory.Exists(ModpackBaseDirectory))
            {
                if (!Directory.Exists(ModpackModsDirectory))
                {
                    Directory.CreateDirectory(ModpackModsDirectory);
                }
                return(true);
            }
            else
            {
                if (!Directory.Exists(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances")))
                {
                    Directory.CreateDirectory(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances"));
                }

                if (!Directory.Exists(ModpackBaseDirectory))
                {
                    Directory.CreateDirectory(ModpackBaseDirectory);
                }
                if (!Directory.Exists(ModpackModsDirectory))
                {
                    Directory.CreateDirectory(ModpackModsDirectory);
                }
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// Cambia la lista di mod
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ModpackCBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            modList.Text = "";
            if (modpackCBox.SelectedItem != null)
            {
                if (File.Exists(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", (string)modpackCBox.SelectedItem, "Files.txt")))
                {
                    foreach (string str in await File.ReadAllLinesAsync(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", (string)modpackCBox.SelectedItem, "Files.txt")))
                    {
                        modList.Text += $"{str.Replace(".jar", "")}\n";
                    }
                }
                else
                {
                    foreach (FileInfo file in new DirectoryInfo(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", (string)modpackCBox.SelectedItem, "mods")).GetFiles())
                    {
                        await File.AppendAllTextAsync(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", (string)modpackCBox.SelectedItem, "Files.txt"), file.Name + Environment.NewLine);
                    }

                    foreach (string str in await File.ReadAllLinesAsync(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", (string)modpackCBox.SelectedItem, "Files.txt")))
                    {
                        modList.Text += $"{str.Replace(".jar", "")}\n";
                    }
                }
            }
        }
コード例 #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Initialize launcher

            var defaultPath = new MinecraftPath(MinecraftPath.GetOSDefaultPath());

            InitializeLauncher(defaultPath);
        }
コード例 #5
0
        async Task Start(MSession session)
        {
            var path = MinecraftPath.GetOSDefaultPath();
            var game = new MinecraftPath(path);

            // Create CMLauncher instance
            var launcher = new CMLauncher(game);

            // if you want to download with parallel downloader, add below code :
            System.Net.ServicePointManager.DefaultConnectionLimit = 256;

            launcher.ProgressChanged += Downloader_ChangeProgress;
            launcher.FileChanged     += Downloader_ChangeFile;

            Console.WriteLine($"{launcher.MinecraftPath.BasePath} adresine kuruldu.");

            // Get all installed profiles and load all profiles from mojang server
            var versions = await launcher.GetAllVersionsAsync();

            foreach (var item in versions) // Display all profiles
            {
                // You can filter snapshots and old versions to add if statement :
                if (item.MType == CmlLib.Core.Version.MVersionType.Release || item.MType == CmlLib.Core.Version.MVersionType.Custom)
                {
                    List <string> list = new List <string> {
                        item.Type + " " + item.Name
                    };

                    list.ForEach(i => Console.Write("{0}\n", i));
                }
            }

            var launchOption = new MLaunchOption
            {
                MaximumRamMb = 1024,
                Session      = session,
            };


            Console.WriteLine("Versiyon yazın (örnek 1.12.2): ");
            var process = await launcher.CreateProcessAsync(Console.ReadLine(), launchOption);

            //var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption);
            Console.WriteLine(process.StartInfo.Arguments);

            // Below codes are print game logs in Console.
            var processUtil = new CmlLib.Utils.ProcessUtil(process);

            processUtil.OutputReceived += (s, e) => Console.WriteLine(e);
            processUtil.StartWithEvents();
            process.WaitForExit();

            // or just start it without print logs
            // process.Start();

            Console.ReadLine();
            return;
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: CmlLib/CmlLib.Core
        private async void MainForm_Shown(object sender, EventArgs e)
        {
            lbLibraryVersion.Text = "CmlLib.Core " + getLibraryVersion();

            // Initialize launcher
            var defaultPath = new MinecraftPath(MinecraftPath.GetOSDefaultPath());

            await initializeLauncher(defaultPath);
        }
コード例 #7
0
        async Task TestAll(MSession session)
        {
            var path = MinecraftPath.GetOSDefaultPath();
            var game = new MinecraftPath(path);

            var launcher = new CMLauncher(game);

            System.Net.ServicePointManager.DefaultConnectionLimit = 256;
            launcher.FileDownloader = new AsyncParallelDownloader();

            launcher.ProgressChanged += Downloader_ChangeProgress;
            launcher.FileChanged     += Downloader_ChangeFile;

            Console.WriteLine($"Initialized in {launcher.MinecraftPath.BasePath}");

            var launchOption = new MLaunchOption
            {
                MaximumRamMb = 1024,
                Session      = session,
            };

            var versions = await launcher.GetAllVersionsAsync();

            foreach (var item in versions)
            {
                Console.WriteLine(item.Type + " " + item.Name);

                if (!item.IsLocalVersion)
                {
                    continue;
                }

                var process = launcher.CreateProcess(item.Name, launchOption);

                //var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption);
                Console.WriteLine(process.StartInfo.Arguments);

                // Below codes are print game logs in Console.
                var processUtil = new CmlLib.Utils.ProcessUtil(process);
                processUtil.OutputReceived += (s, e) => Console.WriteLine(e);
                processUtil.StartWithEvents();

                Thread.Sleep(1000 * 15);

                if (process.HasExited)
                {
                    Console.WriteLine("FAILED!!!!!!!!!");
                    Console.ReadLine();
                }

                process.Kill();
                process.WaitForExit();
            }

            return;
        }
コード例 #8
0
 /// <summary>
 /// Controlla se la cartella Minecraft esiste
 /// </summary>
 /// <returns>Restituisce un valore booleano indicante se la cartella Minecraft esiste</returns>
 static public bool doesMinecraftExist()
 {
     if (Directory.Exists(MinecraftPath.GetOSDefaultPath()))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #9
0
        /// <summary>
        /// OpenFolderDialog per selezionare le mod
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void SelectModPath(object sender, RoutedEventArgs e)
        {
            OpenFolderDialog dialog = new OpenFolderDialog()
            {
                Directory = MinecraftPath.GetOSDefaultPath(),
                Title     = "Selezione cartella mod"
            };

            string path = await dialog.ShowAsync(this);

            if (Directory.Exists(path))
            {
                ModU.Text = path;
            }
        }
コード例 #10
0
        /// <summary>
        /// Crea un nuovo profilo nel launcher di minecraft impostato con il 75% della ram del sistema e un icona personalizzata
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ModpackBaseDirectory">Directory del modpack</param>
        /// <param name="DropboxKey">token di DropBox</param>
        /// <param name="nome">Nome del Modpack</param>
        /// <param name="forgeversion">Versione di forge</param>
        /// <returns></returns>
        static public async Task ParseProfile(MainWindow sender, string ModpackBaseDirectory, string DropboxKey, string nome, string forgeversion)
        {
            sender.Message("Rilevo la quantità di ram nel sistema...");
            float ram          = (float)GC.GetGCMemoryInfo().TotalAvailableMemoryBytes / 1024f / 1024f / 1024f;
            float allocatedram = (float)Math.Ceiling(ram / 100f * 75f);

            sender.Message("Creo il nuovo profilo nel launcher...");

            string iconPath = Path.Combine(ModpackBaseDirectory, "icon.png");

            using (var dbx = new DropboxClient(DropboxKey))
            {
                using (var response = await dbx.Files.DownloadAsync(@"/icon.png"))
                {
                    using (var fileStream = File.Create(iconPath))
                    {
                        (await response.GetContentAsStreamAsync()).CopyTo(fileStream);
                    }
                }
            }

            byte[] imageArray = File.ReadAllBytes(iconPath);
            string base64ImageRepresentation = Convert.ToBase64String(imageArray);

            string parsedJson = await File.ReadAllTextAsync(Path.Combine(MinecraftPath.GetOSDefaultPath(), "launcher_profiles.json"));

            LauncherProfile root = JsonConvert.DeserializeObject <LauncherProfile>(parsedJson);

            if (root.profiles.ContainsKey("forge"))
            {
                root.profiles.Remove("forge");
            }
            if (!root.profiles.ContainsKey(nome))
            {
                root.profiles.Add(nome, new Profile
                {
                    name          = nome,
                    type          = "custom",
                    lastVersionId = forgeversion,
                    icon          = "data:image/png;base64," + base64ImageRepresentation,
                    gameDir       = ModpackBaseDirectory,
                    javaArgs      = $@"-Xmx{allocatedram}G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M",
                });
            }
            await File.WriteAllTextAsync(Path.Combine(MinecraftPath.GetOSDefaultPath(), "launcher_profiles.json"), JsonConvert.SerializeObject(root, Formatting.Indented));
        }
コード例 #11
0
        /// <summary>
        /// Controlla se il modpack esiste e prepara per il download del modpack
        /// </summary>
        /// <param name="nome">nome del modpack</param>
        /// <param name="Firebasetoken"></param>
        /// <returns></returns>
        public async Task <bool> ModpackExists(string nome, string Firebasetoken)
        {
            FirebaseResponse response = await client.GetAsync("/");

            ModpacksList = response.ResultAs <Modpacks>();

            if (ModpacksList.modpack.ContainsKey(Firebasetoken))
            {
                modpack = ModpacksList.modpack[Firebasetoken];
                if (await Utilities.isDropboxTokenValid(modpack.Token))
                {
                    if (nome != "")
                    {
                        if (nome.Contains("*") || nome.Contains(".") || nome.Contains("\"") || nome.Contains("/") || nome.Contains("[") || nome.Contains("]") || nome.Contains(":") || nome.Contains(";") || nome.Contains("|") || nome.Contains(","))
                        {
                            return(false);
                        }
                        else
                        {
                            ModpackBaseDirectory = Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", nome);
                            ModpackModsDirectory = Path.Combine(ModpackBaseDirectory, "mods");
                            modpack.Name         = nome;
                            return(true);
                        }
                    }
                    else
                    {
                        ModpackBaseDirectory = Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", nome);
                        ModpackModsDirectory = Path.Combine(ModpackBaseDirectory, "mods");
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #12
0
        static void Main(string[] args)
        {
            var lp = MLauncherProfile.LoadFromDefaultPath();

            System.Diagnostics.Debug.Write(lp);

            //var path = new Minecraft("your minecraft directory);
            var path = MinecraftPath.GetOSDefaultPath(); // mc directory

            var launcher = new CmlLib.CMLauncher(path);

            launcher.ProgressChanged += (s, e) =>
            {
                Console.WriteLine("{0}%", e.ProgressPercentage);
            };
            launcher.FileChanged += (e) =>
            {
                Console.WriteLine("[{0}] {1} - {2}/{3}", e.FileKind.ToString(), e.FileName, e.ProgressedFileCount, e.TotalFileCount);
            };

            launcher.UpdateProfiles();
            foreach (var item in launcher.Profiles)
            {
                Console.WriteLine(item.Name);
            }

            var launchOption = new MLaunchOption
            {
                MaximumRamMb = 1024,
                Session      = MSession.GetOfflineSession("hello"), // Login Session. ex) Session = MSession.GetOfflineSession("hello")

                //LauncherName = "MyLauncher",
                //ScreenWidth = 1600,
                //ScreenHeigth = 900,
                //ServerIp = "mc.hypixel.net"
            };

            // launch vanila
            var process = launcher.CreateProcess("1.15.2", launchOption);

            process.Start();
        }
コード例 #13
0
        static public async Task RemoveModpack(MainWindow sender, string ModpackName)
        {
            Directory.Delete(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", ModpackName), true);

            if (File.Exists(ModpackSavePath))
            {
                Modpacks modpacks = JsonConvert.DeserializeObject <Modpacks>(await File.ReadAllTextAsync(ModpackSavePath));
                modpacks.modpack.Remove(ModpackName);

                File.Delete(ModpackSavePath);
                await File.WriteAllTextAsync(ModpackSavePath, JsonConvert.SerializeObject(modpacks, Formatting.Indented));

                List <string> items = new List <string>();
                foreach (KeyValuePair <string, Modpack> modpack in modpacks.modpack)
                {
                    items.Add(modpack.Value.Name);
                }
                sender.modpackCBox.Items = items;
            }
        }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: KALITRIK/345-Launcher
        private void MainForm_Load(object sender, EventArgs e)
        {
            var defaultPath = new MinecraftPath(MinecraftPath.GetOSDefaultPath());

            InitializeLauncher(defaultPath);
            Modlar frm = new Modlar()
            {
                TopLevel = false, TopMost = true
            };

            this.panel2.Controls.Add(frm);
            frm.Show();

            #region UpdateBrowser
            var appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe";
            using (var Key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true))
                Key.SetValue(appName, 99999, RegistryValueKind.DWord);

            webBrowser1.Navigate("https://launcher.mehmetali345.xyz/launcher.html");
            webBrowser1.ScriptErrorsSuppressed = true;
            #endregion
        }
コード例 #15
0
        /// <summary>
        /// Installa Il Modpack Nel launcher di minecraft e nel modpackUpdater
        /// </summary>
        /// <returns></returns>
        private async Task InstallModpack(string token)
        {
            ModpackBaseDirectory = Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances", NomeU.Text);
            ModpackModsDirectory = Path.Combine(ModpackBaseDirectory, "mods");

            Message("Creazione file necessari...");

            if (!Directory.Exists(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances")))
            {
                Directory.CreateDirectory(Path.Combine(MinecraftPath.GetOSDefaultPath(), "Istances"));
            }
            if (!Directory.Exists(ModpackBaseDirectory))
            {
                Directory.CreateDirectory(ModpackBaseDirectory);
            }
            if (!Directory.Exists(ModpackModsDirectory))
            {
                Directory.CreateDirectory(ModpackModsDirectory);
            }
            else
            {
                Directory.Delete(ModpackModsDirectory, true);
                Directory.CreateDirectory(ModpackModsDirectory);
            }

            foreach (FileInfo file in new DirectoryInfo(ModU.Text).GetFiles())
            {
                statusU.Text = $"Copia del file: {file.Name}";
                file.CopyTo(Path.Combine(ModpackModsDirectory, file.Name));
            }

            string forgeVersion = await Utilities.InstallForge(this, ModpackBaseDirectory, DropboxU.Text);

            await Utilities.ParseProfile(this, ModpackBaseDirectory, DropboxU.Text, NomeU.Text, forgeVersion);

            await ModManager.AddModpack(this, NomeU.Text, token);
        }
コード例 #16
0
        private void Main_Form_Load(object sender, EventArgs e)
        {
            int Out;

            if (InternetGetConnectedState(out Out, 0) == true)
            {
                webBrowser1.Navigate("https://launcher.mehmetali345.xyz/launcher.html");
                webBrowser1.ScriptErrorsSuppressed         = true;
                webBrowser1.IsWebBrowserContextMenuEnabled = false;
                UserHead();
            }
            else
            {
                userhead.Image           = Properties.Resources.steve;
                noint_picturebox.Visible = true;
                noint_picturebox.Image   = Properties.Resources.nointbg;
            }

            var defaultPath = new MinecraftPath(MinecraftPath.GetOSDefaultPath());

            InitializeLauncher(defaultPath);

            cbVersion.DropDownHeight = 200;
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: CmlLib/CmlLib.Core
        void Start(MSession session)
        {
            // Initializing Launcher

            // Set minecraft home directory
            // MinecraftPath.GetOSDefaultPath() return default minecraft BasePath of current OS.
            // https://github.com/AlphaBs/CmlLib.Core/blob/master/CmlLib/Core/MinecraftPath.cs

            // You can set this path to what you want like this :
            //var path = "./testdir";
            var path = MinecraftPath.GetOSDefaultPath();
            var game = new MinecraftPath(path);

            // Create CMLauncher instance
            var launcher = new CMLauncher(game);

            // if you want to download with parallel downloader, add below code :
            System.Net.ServicePointManager.DefaultConnectionLimit = 256;

            launcher.ProgressChanged += Downloader_ChangeProgress;
            launcher.FileChanged     += Downloader_ChangeFile;

            Console.WriteLine($"Initialized in {launcher.MinecraftPath.BasePath}");

            // Get all installed profiles and load all profiles from mojang server
            var versions = launcher.GetAllVersions();

            foreach (var item in versions) // Display all profiles
            {
                // You can filter snapshots and old versions to add if statement :
                // if (item.MType == MProfileType.Custom || item.MType == MProfileType.Release)
                Console.WriteLine(item.Type + " " + item.Name);
            }

            var launchOption = new MLaunchOption
            {
                MaximumRamMb = 1024,
                Session      = session,

                //ScreenWidth = 1600,
                //ScreenHeight = 900,
                //ServerIp = "mc.hypixel.net",
                //MinimumRamMb = 102,
                //FullScreen = true,

                // More options:
                // https://github.com/AlphaBs/CmlLib.Core/wiki/MLaunchOption
            };

            // download essential files (ex: vanilla libraries) and create game process.

            // var process = await launcher.CreateProcessAsync("1.15.2", launchOption); // vanilla
            // var process = await launcher.CreateProcessAsync("1.12.2-forge1.12.2-14.23.5.2838", launchOption); // forge
            // var process = await launcher.CreateProcessAsync("1.12.2-LiteLoader1.12.2"); // liteloader
            // var process = await launcher.CreateProcessAsync("fabric-loader-0.11.3-1.16.5") // fabric-loader

            Console.WriteLine("input version (example: 1.12.2) : ");
            var process = launcher.CreateProcess(Console.ReadLine(), launchOption);

            //var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption);
            Console.WriteLine(process.StartInfo.Arguments);

            // Below codes are print game logs in Console.
            var processUtil = new CmlLib.Utils.ProcessUtil(process);

            processUtil.OutputReceived += (s, e) => Console.WriteLine(e);
            processUtil.StartWithEvents();
            process.WaitForExit();

            // or just start it without print logs
            // process.Start();

            Console.ReadLine();
        }
コード例 #18
0
ファイル: Minecraft.cs プロジェクト: rnwkgusasd/MC_Launcher
 public string GetDefaultPath()
 {
     return(MinecraftPath.GetOSDefaultPath());
 }
コード例 #19
0
        void Start(MSession session)
        {
            // Initializing Launcher

            // Set minecraft home directory
            // MinecraftPath.GetOSDefaultPath() return default minecraft BasePath of current OS.
            // https://github.com/AlphaBs/CmlLib.Core/blob/master/CmlLib/Core/MinecraftPath.cs

            // You can set this path to what you want like this :
            // var path = Environment.GetEnvironmentVariable("APPDATA") + "\\.mylauncher";
            var path = MinecraftPath.GetOSDefaultPath();
            var game = new MinecraftPath(path);

            // Create CMLauncher instance
            var launcher = new CMLauncher(game);

            launcher.ProgressChanged += Downloader_ChangeProgress;
            launcher.FileChanged     += Downloader_ChangeFile;
            launcher.LogOutput       += (s, e) => Console.WriteLine(e);

            Console.WriteLine($"Initialized in {launcher.MinecraftPath.BasePath}");

            var versions = launcher.GetAllVersions(); // Get all installed profiles and load all profiles from mojang server

            foreach (var item in versions)            // Display all profiles
            {
                // You can filter snapshots and old versions to add if statement :
                // if (item.MType == MProfileType.Custom || item.MType == MProfileType.Release)
                Console.WriteLine(item.Type + " " + item.Name);
            }

            var launchOption = new MLaunchOption
            {
                MaximumRamMb = 1024,
                Session      = session,

                // More options:
                // https://github.com/AlphaBs/CmlLib.Core/wiki/MLaunchOption
            };

            // (A) checks forge installation and install forge if it was not installed.
            // (B) just launch any versions without installing forge, but it can still launch forge already installed.
            // Both methods automatically download essential files (ex: vanilla libraries) and create game process.

            // (A) download forge and launch
            var process = launcher.CreateProcess("1.7.10", "10.13.4.1614", launchOption);

            // (B) launch vanilla version
            // var process = launcher.CreateProcess("1.15.2", launchOption);

            // If you have already installed forge, you can launch it directly like this.
            // var process = launcher.CreateProcess("1.12.2-forge1.12.2-14.23.5.2838", launchOption);

            // launch by user input
            //Console.WriteLine("input version (example: 1.12.2) : ");
            //var process = launcher.CreateProcess(Console.ReadLine(), launchOption);

            //var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption);
            Console.WriteLine(process.StartInfo.Arguments);

            // Below codes are print game logs in Console.
            var processUtil = new CmlLib.Utils.ProcessUtil(process);

            processUtil.OutputReceived += (s, e) => Console.WriteLine(e);
            processUtil.StartWithEvents();
            process.WaitForExit();

            // or just start it without print logs
            // process.Start();

            Console.ReadLine();

            return;
        }
コード例 #20
0
        void StartWithAdvancedOptions(MSession session)
        {
            // game directory
            var defaultPath = MinecraftPath.GetOSDefaultPath();
            var path        = Path.Combine(Environment.CurrentDirectory, "game dir");

            // create minecraft path instance
            var minecraft = new MinecraftPath(path);

            minecraft.SetAssetsPath(Path.Combine(defaultPath, "assets")); // this speed up asset downloads

            // get all version metadatas
            // you can also use MVersionLoader.GetVersionMetadatasFromLocal and GetVersionMetadatasFromWeb
            var versionMetadatas = MVersionLoader.GetVersionMetadatas(minecraft);

            foreach (var item in versionMetadatas)
            {
                Console.WriteLine("Name : {0}", item.Name);
                Console.WriteLine("Type : {0}", item.Type);
                Console.WriteLine("Path : {0}", item.Path);
                Console.WriteLine("IsLocalVersion : {0}", item.IsLocalVersion);
                Console.WriteLine("============================================");
            }
            Console.WriteLine("");
            Console.WriteLine("LatestRelease : {0}", versionMetadatas.LatestReleaseVersion?.Name);
            Console.WriteLine("LatestSnapshot : {0}", versionMetadatas.LatestSnapshotVersion?.Name);

            Console.WriteLine("Input Version Name (ex: 1.15.2) : ");
            var versionName = Console.ReadLine();

            // get MVersion from MVersionMetadata
            var version = versionMetadatas.GetVersion(versionName);

            if (version == null)
            {
                Console.WriteLine("{0} is not exist", versionName);
                return;
            }

            Console.WriteLine("\n\nVersion Information : ");
            Console.WriteLine("Id : {0}", version.Id);
            Console.WriteLine("Type : {0}", version.TypeStr);
            Console.WriteLine("ReleaseTime : {0}", version.ReleaseTime);
            Console.WriteLine("AssetId : {0}", version.AssetId);
            Console.WriteLine("JAR : {0}", version.Jar);
            Console.WriteLine("Libraries : {0}", version.Libraries.Length);

            if (version.IsInherited)
            {
                Console.WriteLine("Inherited Profile from {0}", version.ParentVersionId);
            }

            // Download mode
            Console.WriteLine("\nSelect download mode : ");
            Console.WriteLine("(1) Sequence Download");
            Console.WriteLine("(2) Parallel Download");
            var downloadModeInput = Console.ReadLine();

            MDownloader downloader;

            if (downloadModeInput == "1")
            {
                downloader = new MDownloader(minecraft, version); // Sequence Download
            }
            else if (downloadModeInput == "2")
            {
                downloader = new MParallelDownloader(minecraft, version); // Parallel Download (note: Parallel Download is not stable yet)
            }
            else
            {
                Console.WriteLine("Input 1 or 2");
                Console.ReadLine();
                return;
            }

            downloader.ChangeFile     += Downloader_ChangeFile;
            downloader.ChangeProgress += Downloader_ChangeProgress;

            // Start download
            downloader.DownloadAll();

            Console.WriteLine("Download Completed.\n");

            // Set java
            Console.WriteLine("Input java path (empty input will download java) : ");
            var javaInput = Console.ReadLine();

            if (javaInput == "")
            {
                var java = new MJava();
                java.ProgressChanged += Downloader_ChangeProgress;
                javaInput             = java.CheckJava();
            }

            // LaunchOption
            var option = new MLaunchOption()
            {
                JavaPath     = javaInput,
                Session      = session,
                StartVersion = version,
                Path         = minecraft,

                MaximumRamMb = 4096,
                ScreenWidth  = 1600,
                ScreenHeight = 900,
            };

            // Launch
            var launch  = new MLaunch(option);
            var process = launch.GetProcess();

            Console.WriteLine(process.StartInfo.Arguments);
            process.Start();
            Console.WriteLine("Started");
            Console.ReadLine();
        }
コード例 #21
0
 public static MojangLauncherProfile LoadFromDefaultPath()
 {
     return(LoadFromFile(Path.Combine(MinecraftPath.GetOSDefaultPath(), "launcher_profiles.json")));
 }
コード例 #22
0
        private void Settings_Minecraft_Load(object sender, EventArgs e)
        {
            var defaultPath = new MinecraftPath(MinecraftPath.GetOSDefaultPath());

            InitializeLauncher(defaultPath);
        }
コード例 #23
0
        private void btnSetDefault_Click(object sender, EventArgs e)
        {
            var defaultPath = MinecraftPath.GetOSDefaultPath();

            apply(new MinecraftPath(defaultPath));
        }
コード例 #24
0
        public static MojangLauncherAccounts FromDefaultPath()
        {
            var path = Path.Combine(MinecraftPath.GetOSDefaultPath(), "launcher_accounts.json");

            return(FromFile(path));
        }