private void button1_Click(object sender, EventArgs e) { var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); MLogin login = new MLogin(); MSession session = MSession.GetOfflineSession(textBox1.Text); session = login.TryAutoLogin(); Minecraft.Initialize(Path.Combine(appDataPath, @"SkyLauncher\")); MProfileInfo[] infos = MProfileInfo.GetProfiles(); MProfile profile = MProfile.FindProfile(infos, "1.12.2"); DownloadGame(profile); var option = new MLaunchOption() { // must require StartProfile = profile, JavaPath = "java.exe", //SET YOUR JAVA PATH (if you want autoset, goto wiki) MaximumRamMb = 4096, // MB Session = MSession.GetOfflineSession(textBox1.Text), // not require LauncherName = "McLauncher", // display launcher name at main window CustomJavaParameter = "" // set your own java args }; MLaunch launch = new MLaunch(option); launch.GetProcess().Start(); }
private void Btn_Launch_Click(object sender, EventArgs e) { // Launch if (session == null) { MessageBox.Show("Login First"); return; } if (Cb_Version.Text == "") { return; } groupBox1.Enabled = false; groupBox2.Enabled = false; string startVersion = Cb_Version.Text; string javaPath = Txt_Java.Text; string xmx = Txt_Ram.Text; string launcherName = Txt_LauncherName.Text; string serverIp = Txt_ServerIp.Text; var th = new Thread(new ThreadStart(delegate { var profile = MProfile.FindProfile(versions, startVersion); // Find Profile DownloadGame(profile); // Download game files MLaunchOption option = new MLaunchOption() // Set options { StartProfile = profile, JavaPath = javaPath, LauncherName = launcherName, MaximumRamMb = int.Parse(xmx), ServerIp = serverIp, Session = session, CustomJavaParameter = Txt_JavaArgs.Text }; if (Txt_ScWd.Text != "" && Txt_ScHt.Text != "") { option.ScreenHeight = int.Parse(Txt_ScHt.Text); option.ScreenWidth = int.Parse(Txt_ScWd.Text); } MLaunch launch = new MLaunch(option); // Start Process var process = launch.GetProcess(); DebugProcess(process); this.Invoke((MethodInvoker) delegate { groupBox1.Enabled = true; groupBox2.Enabled = true; }); })); th.Start(); }
private MLaunchOption createLaunchOption() { //Sets launch options try { var launchOption = new MLaunchOption() { Path = MinecraftPath, MaximumRamMb = int.Parse(Properties.Settings.Default.ram), Session = this.Session, FullScreen = Properties.Settings.Default.fs, }; if (!string.IsNullOrEmpty(Properties.Settings.Default.ram)) { launchOption.MinimumRamMb = int.Parse(Properties.Settings.Default.mram); } if (!string.IsNullOrEmpty(Properties.Settings.Default.JVM)) { launchOption.JVMArguments = Properties.Settings.Default.JVM.Split(' '); } return(launchOption); } catch (Exception ex) { MessageBox.Show("Failed to create MLaunchOption\n\n" + ex.ToString()); return(null); } }
private void button1_Click(object sender, EventArgs e) { var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); MLogin login = new MLogin(); MSession session = MSession.GetOfflineSession(textBox1.Text); session = login.TryAutoLogin(); Minecraft.Initialize(Path.Combine(appDataPath, @"SkyLauncher\")); MProfileInfo[] infos = MProfileInfo.GetProfiles(); MProfile profile = MProfile.FindProfile(infos, comboBox1.SelectedItem.ToString()); DownloadGame(profile); var option = new MLaunchOption() { // must require StartProfile = profile, JavaPath = "java.exe", //JAVA PAT MaximumRamMb = 4096, // MB Session = MSession.GetOfflineSession(textBox1.Text), // not require LauncherName = "SkyLauncher", CustomJavaParameter = "" // java args }; MLaunch launch = new MLaunch(option); launch.GetProcess().Start(); }
private void StartGame() { var local = MProfileInfo.GetProfilesFromLocal(); MProfileInfo[] versions = MProfileInfo.GetProfiles(); MProfile profile = MProfile.GetProfile(versions, "1.12.2-forge1.12.2-14.23.5.2847"); MLaunchOption option = new MLaunchOption() { StartProfile = profile, JavaPath = GADD_Application.Properties.Settings.Default.mclocation + "\\runtime\\bin\\javaw.exe", MaximumRamMb = GADD_Application.Properties.Settings.Default.ram, LauncherName = "GADD", Session = session, CustomJavaParameter = Properties.Settings.Default.javargs }; MLaunch launch = new MLaunch(option); var proc = launch.GetProcess(); //proc.Start(); //launch.GetProcess().Start(); StartDebug(proc); //Console.ProcessLock(launch); Invoke((MethodInvoker) delegate { GaddPage.GP.ButtonStat(true); }); }
public static async Task LaunchGameAsync(FileManager.Modpacks modpack) { try { var path = new MinecraftPath(Directory.GetCurrentDirectory() + $@"\Launcher\{modpack}"); var launcher = new CMLauncher(path); // more options : https://github.com/AlphaBs/CmlLib.Core/wiki/MLaunchOption var launchOption = new MLaunchOption { MaximumRamMb = Settings.RAM, Session = SESSION }; forgeVersion = File.ReadAllText($"Launcher/{modpack}/Forge Version.txt"); var process = await launcher.CreateProcessAsync(forgeVersion, launchOption); process.Start(); } catch (Exception) { main.GetError($"Failed Launching {modpack}!"); } }
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; }
private MLaunchOption createLaunchOption() { try { var launchOption = new MLaunchOption() { Path = MinecraftPath, MaximumRamMb = int.Parse(TxtXmx.Text), Session = this.Session, VersionType = Txt_VersionType.Text, GameLauncherName = Txt_GLauncherName.Text, GameLauncherVersion = Txt_GLauncherVersion.Text, FullScreen = cbFullscreen.Checked, ServerIp = Txt_ServerIp.Text, DockName = Txt_DockName.Text, DockIcon = Txt_DockIcon.Text }; if (!useMJava) { launchOption.JavaPath = javaPath; } if (!string.IsNullOrEmpty(txtXms.Text)) { launchOption.MinimumRamMb = int.Parse(txtXms.Text); } if (!string.IsNullOrEmpty(Txt_ServerPort.Text)) { launchOption.ServerPort = int.Parse(Txt_ServerPort.Text); } if (!string.IsNullOrEmpty(Txt_ScWd.Text) && !string.IsNullOrEmpty(Txt_ScHt.Text)) { launchOption.ScreenHeight = int.Parse(Txt_ScHt.Text); launchOption.ScreenWidth = int.Parse(Txt_ScWd.Text); } if (!string.IsNullOrEmpty(Txt_JavaArgs.Text)) { launchOption.JVMArguments = Txt_JavaArgs.Text.Split(' '); } return(launchOption); } catch (Exception ex) // exceptions. like FormatException in int.Parse { MessageBox.Show("Failed to create MLaunchOption\n\n" + ex.ToString()); return(null); } }
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; }
private void LaunchClick(object sender, RoutedEventArgs e) { LaunchProgress.Opacity = 100; var th = new Thread(new ThreadStart(delegate { string selectedver = ""; Application.Current.Dispatcher.Invoke((Action) delegate { LaunchButton.IsEnabled = false; selectedver = versionList.Text; }); var ThisThreadOptions = new MLaunchOption(); Application.Current.Dispatcher.Invoke(delegate { int screenHeight = 0; int screenWidth = 0; int MaxRamMB = Convert.ToInt32(MaxMemSlider.Value); try { screenHeight = Convert.ToInt32(ScreenHeightBox.Text); screenWidth = Convert.ToInt32(ScreenWidthBox.Text); } catch { screenHeight = 0; screenWidth = 0; } var launchOptions = new MLaunchOption { JavaPath = JavaPathBox.Text, ServerIp = ServerIPBox.Text, ScreenHeight = screenHeight, ScreenWidth = screenWidth, MaximumRamMb = MaxRamMB, Session = MainSession, JVMArguments = CustomArgsBox.Text.Split(" ") }; ThisThreadOptions = launchOptions; }); CMLauncher launcher = new CMLauncher(Minecraft.GetOSDefaultPath()); launcher.ProgressChanged += Launcher_ProgressChanged; launcher.FileChanged += Launcher_FileChanged; var process = launcher.CreateProcess(selectedver, ThisThreadOptions); process.Start(); Application.Current.Dispatcher.Invoke((Action) delegate { LaunchButton.IsEnabled = true; LaunchProgress.Visibility = Visibility.Hidden; LaunchLog.Visibility = Visibility.Hidden; }); })); th.Start(); }
public void Run(MProfile profile, MSession session, string ram) { int ramNumber = Checkram(ram); string javapath = Directory.GetCurrentDirectory() + @"\Minecraft\runtime\jre-x64\bin\javaw.exe"; MLaunchOption option = LaunchOption(profile, session, ramNumber, javapath); MLaunch launch = new MLaunch(option); launch.GetProcess().Start(); }
private void downloadMinecraftStuff_DoWork(object sender, DoWorkEventArgs e) { if (cancel) { return; } startButtonEnabled = false; var minecraft = new Minecraft(Path.Combine(path, modpack.Name)); minecraft.SetAssetsPath(path); var launcher = new Launcher(minecraft); launcher.ProgressChanged += Downloader_ChangeProgress; launcher.FileChanged += Downloader_ChangeFile; launcher.UpdateProfiles(); progressLabel = "Download der Assets abgeschlossen."; MJava java = new MJava(); var javaBinary = java.CheckJava(); var option = new MLaunchOption { GameLauncherName = "LandOfRailsLauncher", GameLauncherVersion = "0.1", JavaPath = javaBinary, Session = session, StartProfile = profile, MaximumRamMb = Settings.Default.RAM, }; string forgeVersion; using (StreamReader r = new StreamReader(Path.Combine(path, modpack.Name, "bin", "version.txt"))) { forgeVersion = r.ReadLine(); } var process = launcher.CreateProcess(modpack.MinecraftVersion, forgeVersion, option); Log.Debug($"{process.StartInfo.WorkingDirectory}\n{process.StartInfo.Arguments}\n{process.StartInfo.Domain}\n{process.StartInfo.FileName}\n{process.StartInfo.UserName}\n{process.StartInfo.Verb}"); if (Settings.Default.openConsole) { processWindow.Start(process); } else { process.Start(); } }
public Process CreateProcess(MLaunchOption option) { if (string.IsNullOrEmpty(option.JavaPath)) { option.JavaPath = CheckJRE(); } CheckGameFiles(option.StartProfile); var launch = new MLaunch(option); return(launch.GetProcess()); }
public void start(MSession session, string version) { var McPath = Minecraft.GetOSDefaultPath(); var launcher = new CmlLib.CMLauncher(McPath); // ignore 2 errors var launchOptions = new MLaunchOption { MaximumRamMb = 2048, Session = session, }; var process = launcher.CreateProcess(version, launchOptions); process.Start(); }
private void LaunchGame() { ThreadPool.QueueUserWorkItem((Task) => { MLaunchOption Options = new MLaunchOption() { MaximumRamMb = 2048, Session = CurrentSession, ServerIp = "45.23.44.208" }; Process Proc = CMLauncher.CreateProcess("1.16.3", "34.1.11", Options); Proc.Start(); }); }
private MLaunchOption createLaunchOption() { //Sets launch options try { var launchOption = new MLaunchOption() { Path = MinecraftPath, MaximumRamMb = int.Parse(TxtXmx.Text), Session = this.Session, FullScreen = cbFullscreen.Checked, }; if (!useMJava) { launchOption.JavaPath = javaPath; } if (!string.IsNullOrEmpty(TxtXms.Text)) { launchOption.MinimumRamMb = int.Parse(TxtXms.Text); } if (!string.IsNullOrEmpty(Txt_JavaArgs.Text)) { launchOption.JVMArguments = Txt_JavaArgs.Text.Split(' '); } return(launchOption); } catch (Exception ex) { if (Properties.Settings.Default.langtr == true) { this.Alert("MLaunchOption oluşamadı", "Eğer sorun devam ederse", "geri bildirim gönderin.", Form_Info.enmType.Error); } else { this.Alert("MLaunchOption not created", "If problems unsolves", "send feedback.", Form_Info.enmType.Error); } MessageBox.Show("Failed to create MLaunchOption\n\n" + ex.ToString()); return(null); } }
void Start(MSession session) { // initializing launcher var path = Minecraft.GetOSDefaultPath(); // mc directory //var path = @"./mctestdir"; var launcher = new CmlLib.CMLauncher(path); launcher.ProgressChanged += Downloader_ChangeProgress; launcher.FileChanged += Downloader_ChangeFile; Console.WriteLine($"Initialized in {launcher.Minecraft.path}"); launcher.UpdateProfileInfos(); foreach (var item in launcher.ProfileInfos) { Console.WriteLine(item.Name); } var launchOption = new MLaunchOption { MaximumRamMb = 1024, Session = session, }; // launch forge // var process = launcher.CreateProcess("1.12.2", "14.23.5.2768", launchOption); // launch vanila // var process = launcher.CreateProcess("1.15.2", launchOption); // launch by user input Console.WriteLine("input version : "); var process = launcher.CreateProcess(Console.ReadLine(), launchOption); Console.WriteLine(process.StartInfo.Arguments); process.Start(); Console.WriteLine("Started"); Console.ReadLine(); return; }
public string Launch(string username, string password, int memory, string version, bool fullScreen) { var account = new MLogin().Authenticate(username, password); if (!account.IsSuccess) { return(account.Result.ToString() + '\n' + account.ErrorMessage); } var session = account.Session; var mcp = new MinecraftPath(Path.Combine(Utility.GetWorkingDir(), ".minecraft")); ChangeOption(mcp.BasePath, Thread.CurrentThread.CurrentUICulture.Name.Replace('-', '_').ToLower()); var launcher = new CMLauncher(mcp); launcher.FileChanged += (e) => { LFileKind = e.FileKind.ToString(); LFileName = e.FileName; LProgressedFileCnt = e.ProgressedFileCount.ToString(); LTotFileCnt = e.TotalFileCount.ToString(); }; launcher.ProgressChanged += (sender, e) => { LProgressPercentage = e.ProgressPercentage.ToString(); }; var launchOption = new MLaunchOption { MaximumRamMb = memory, Session = session, FullScreen = fullScreen, ServerIp = "124.71.131.172", ServerPort = 25565, JavaPath = Utility.GetJava(launcher), JVMArguments = new string[] { "-javaagent:../nide8auth.jar=28f8f58a8a7f11e88feb525400b59b6a", "-Dnide8auth.client=true" } }; var process = launcher.CreateProcess(version, launchOption); Console.WriteLine("[Launch] FileName: " + process.StartInfo.FileName); Console.WriteLine("[Launch] Arguments: " + process.StartInfo.Arguments); Console.WriteLine("[Launch] WorkingDirectory: " + process.StartInfo.WorkingDirectory); process.Start(); return(string.Empty); }
private void launch_Click(object sender, EventArgs e) { launch.Enabled = false; //var path = new Minecraft("your minecraft directory); var path = Minecraft.GetOSDefaultPath(); // mc directory var launcher = new CmlLib.CMLauncher(path); launcher.ProgressChanged += (s, ev) => { Console.WriteLine("{0}%", ev.ProgressPercentage); progressBar1.Value = ev.ProgressPercentage; }; launcher.FileChanged += (ev) => { string txt = String.Format("[{0}] {1} - {2}/{3}", ev.FileKind.ToString(), ev.FileName, ev.ProgressedFileCount, ev.TotalFileCount); Console.WriteLine(txt); progress.Text = txt; }; var launchOption = new MLaunchOption { MaximumRamMb = c.maxRam, Session = c.session, // Login Session. ex) Session = MSession.GetOfflineSession("hello") GameLauncherName = "ClearSky", ScreenHeight = c.screenHeight, ScreenWidth = c.screenWidth, //ServerIp = "chocu.kro.kr" }; // launch forge //var process = launcher.Launch("1.12.2", "14.23.5.2768", launchOption); p = launcher.CreateProcess("1.15.2", launchOption); p.Exited += P_Exited; p.Start(); }
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(); }
// this code is from README.md async Task QuickStart() { //var path = new MinecraftPath("game_directory_path"); var path = new MinecraftPath(); // use default directory var launcher = new CMLauncher(path); launcher.FileChanged += (e) => { Console.WriteLine("[{0}] {1} - {2}/{3}", e.FileKind.ToString(), e.FileName, e.ProgressedFileCount, e.TotalFileCount); }; launcher.ProgressChanged += (s, e) => { Console.WriteLine("{0}%", e.ProgressPercentage); }; var versions = await launcher.GetAllVersionsAsync(); foreach (var item in versions) { Console.WriteLine(item.Name); } var launchOption = new MLaunchOption { MaximumRamMb = 1024, Session = MSession.GetOfflineSession("hello"), // Login Session. ex) Session = MSession.GetOfflineSession("hello") //ScreenWidth = 1600, //ScreenHeigth = 900, //ServerIp = "mc.hypixel.net" }; // launch vanila var process = await launcher.CreateProcessAsync("1.15.2", launchOption); process.Start(); }
private void Btn_Launch_Click(object sender, EventArgs e) { // Launch if (Session == null) { MessageBox.Show("Inicie sesión primero"); return; } if (Cb_Version.Text == "") { MessageBox.Show("Porfavor eliga una versión"); return; } groupBox1.Enabled = false; groupBox2.Enabled = false; try { var versionname = Cb_Version.Text; var launchOption = new MLaunchOption() { JavaPath = Txt_Java.Text, MaximumRamMb = int.Parse(Txt_Ram.Text), Session = this.Session, VersionType = Txt_VersionType.Text, GameLauncherName = Txt_GLauncherName.Text, GameLauncherVersion = Txt_GLauncherVersion.Text, ServerIp = Txt_ServerIp.Text, DockName = Txt_DockName.Text, DockIcon = Txt_DockIcon.Text }; if (!string.IsNullOrEmpty(Txt_ServerPort.Text)) { launchOption.ServerPort = int.Parse(Txt_ServerPort.Text); } if (!string.IsNullOrEmpty(Txt_ScWd.Text) && !string.IsNullOrEmpty(Txt_ScHt.Text)) { launchOption.ScreenHeight = int.Parse(Txt_ScHt.Text); launchOption.ScreenWidth = int.Parse(Txt_ScWd.Text); } if (!string.IsNullOrEmpty(Txt_JavaArgs.Text)) { launchOption.JVMArguments = Txt_JavaArgs.Text.Split(' '); } var th = new Thread(() => { var process = Launcher.CreateProcess(versionname, launchOption); StartProcess(process); }); th.Start(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { var fWork = new Action(() => { if (GameConsole != null) { GameConsole.Close(); } GameConsole = new GameConsole(); GameConsole.Show(); groupBox1.Enabled = true; groupBox2.Enabled = true; }); if (this.InvokeRequired) { this.Invoke(fWork); } else { fWork.Invoke(); } } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { DoubleAnimation OpacityAnimation = new DoubleAnimation(); OpacityAnimation.From = this.Opacity; OpacityAnimation.To = 1; OpacityAnimation.Duration = TimeSpan.FromSeconds(0.3); this.BeginAnimation(Window.OpacityProperty, OpacityAnimation); await Task.Delay(300); if (!File.Exists(TotalPath + @"/Storage/Stream/MinecraftVersion")) { try { using (SftpClient Client = new SftpClient("bedrock-project.ru", "root", "singularity")) { Client.Connect(); using (Stream fileStream = File.Create(Environment.CurrentDirectory + @"/Storage/Stream/MinecraftVersion")) { Client.DownloadFile("/launcher/Storage/Stream/MinecraftVersion", fileStream); } } } catch { } } string MinecraftVersion; try { FileStream FileStream = new FileStream(TotalPath + @"/Storage/Stream/MinecraftVersion", FileMode.Open, FileAccess.Read); using (var StreamReader = new StreamReader(FileStream, Encoding.UTF8)) { MinecraftVersion = StreamReader.ReadToEnd(); MinecraftVersion = MinecraftVersion.Trim(); if (MinecraftVersion == null) { MinecraftVersion = "1.16.4"; } } } catch { MinecraftVersion = "1.16.4"; } MSession MSession; if (Nickname != null) { MSession = MSession.GetOfflineSession(Nickname); } else { MSession = MSession.GetOfflineSession("Steve"); } var LaunchOption = new MLaunchOption { MinimumRamMb = 512, MaximumRamMb = 1024, Session = MSession, ScreenWidth = 1920, ScreenHeight = 1080, ServerIp = IP, FullScreen = true }; try { System.Diagnostics.Process Process = Launcher.CreateProcess(MinecraftVersion, LaunchOption); Process.Start(); } catch { string PATH = new MinecraftPath() + @"\versions\" + MinecraftVersion; Directory.Delete(PATH, true); System.Diagnostics.Process Process = Launcher.CreateProcess(MinecraftVersion, LaunchOption); Process.Start(); } // launch forge (already installed) // var process = launcher.CreateProcess("1.16.2-forge-33.0.5", launchOption); // launch forge (install forge if not installed) // var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption); DoubleAnimation WidthAnimation = new DoubleAnimation(); WidthAnimation.From = LoadProgress.Opacity; WidthAnimation.To = 320; WidthAnimation.Duration = TimeSpan.FromSeconds(2); LoadProgress.BeginAnimation(Rectangle.WidthProperty, WidthAnimation); await Task.Delay(2000); OpacityAnimation.From = this.Opacity; OpacityAnimation.To = 0; OpacityAnimation.Duration = TimeSpan.FromSeconds(0.3); this.BeginAnimation(Window.OpacityProperty, OpacityAnimation); await Task.Delay(1000); this.Close(); }
public Process CreateProcess(string versionname, MLaunchOption option) { option.StartProfile = GetProfile(versionname); return(CreateProcess(option)); }
// Start Game private async void Btn_Launch_Click(object sender, EventArgs e) { if (session == null) { MessageBox.Show("Login First"); return; } if (cbVersion.Text == "") { MessageBox.Show("Select Version"); return; } // disable ui setUIEnabled(false); try { // create LaunchOption var launchOption = new MLaunchOption() { MaximumRamMb = int.Parse(TxtXmx.Text), Session = this.session, VersionType = Txt_VersionType.Text, GameLauncherName = Txt_GLauncherName.Text, GameLauncherVersion = Txt_GLauncherVersion.Text, FullScreen = cbFullscreen.Checked, ServerIp = Txt_ServerIp.Text, DockName = Txt_DockName.Text, DockIcon = Txt_DockIcon.Text }; if (!string.IsNullOrEmpty(javaPath)) { launchOption.JavaPath = javaPath; } if (!string.IsNullOrEmpty(txtXms.Text)) { launchOption.MinimumRamMb = int.Parse(txtXms.Text); } if (!string.IsNullOrEmpty(Txt_ServerPort.Text)) { launchOption.ServerPort = int.Parse(Txt_ServerPort.Text); } if (!string.IsNullOrEmpty(Txt_ScWd.Text) && !string.IsNullOrEmpty(Txt_ScHt.Text)) { launchOption.ScreenHeight = int.Parse(Txt_ScHt.Text); launchOption.ScreenWidth = int.Parse(Txt_ScWd.Text); } if (!string.IsNullOrEmpty(Txt_JavaArgs.Text)) { launchOption.JVMArguments = Txt_JavaArgs.Text.Split(' '); } if (rbParallelDownload.Checked) { System.Net.ServicePointManager.DefaultConnectionLimit = 256; launcher.FileDownloader = new AsyncParallelDownloader(); } else { launcher.FileDownloader = new SequenceDownloader(); } // check file hash or don't check launcher.GameFileCheckers.AssetFileChecker.CheckHash = cbSkipHashCheck.Checked; launcher.GameFileCheckers.ClientFileChecker.CheckHash = cbSkipHashCheck.Checked; launcher.GameFileCheckers.LibraryFileChecker.CheckHash = cbSkipHashCheck.Checked; if (cbSkipAssetsDownload.Checked) { launcher.GameFileCheckers.AssetFileChecker = null; } var process = await launcher.CreateProcessAsync(cbVersion.Text, launchOption); // Create Arguments and Process // process.Start(); // Just start game, or StartProcess(process); // Start Process with debug options } catch (FormatException fex) // int.Parse exception { MessageBox.Show("Failed to create MLaunchOption\n\n" + fex); } catch (MDownloadFileException mex) // download exception { MessageBox.Show( $"FileName : {mex.ExceptionFile.Name}\n" + $"FilePath : {mex.ExceptionFile.Path}\n" + $"FileUrl : {mex.ExceptionFile.Url}\n" + $"FileType : {mex.ExceptionFile.Type}\n\n" + mex.ToString()); } catch (Win32Exception wex) // java exception { MessageBox.Show(wex + "\n\nIt seems your java setting has problem"); } catch (Exception ex) // all exception { MessageBox.Show(ex.ToString()); } finally { // re open log form if (logForm != null) { logForm.Close(); } logForm = new GameLog(); logForm.Show(); // enable ui setUIEnabled(true); } }
public Process CreateProcess(string mcversion, string forgeversion, MLaunchOption option) { return(CreateProcess(CheckForge(mcversion, forgeversion), option)); }
public Process Start(Server server) { System.Net.ServicePointManager.DefaultConnectionLimit = 256; var game = new MinecraftPath(path); var launcher = new CMLauncher(game); launcher.ProgressChanged += Download_Progress; launcher.FileChanged += Download_ChangeFile; string version = ""; if (server.TYPE == "forge") { version = FindForgeVersion(server.VERSION); if (version == "") { return(null); } } else { version = server.VERSION; } var lv = new LocalVersionLoader(game).GetVersionMetadatas(); var findVersion = lv.GetVersion(version); if (findVersion == null) { var findMVersion = lv.GetVersionMetadata(version); if (findMVersion != null) { findMVersion.Save(game); } else { var findWVersion = new MojangVersionLoader().GetVersionMetadatas().GetVersionMetadata(version); if (findWVersion != null) { findWVersion.Save(game); } else { return(null); } } } var launchOption = new MLaunchOption { ServerIp = server.IP, ServerPort = server.PORT, MaximumRamMb = ram, Session = se, Path = game, StartVersion = findVersion, GameLauncherName = "JML", GameLauncherVersion = "1.0" }; var process = launcher.CreateProcess(launchOption); process.Start(); return(process); }
public Process Start(string _version) { System.Net.ServicePointManager.DefaultConnectionLimit = 256; var game = new MinecraftPath(path); var launcher = new CMLauncher(game); launcher.ProgressChanged += Download_Progress; launcher.FileChanged += Download_ChangeFile; var lv = new LocalVersionLoader(game).GetVersionMetadatas(); MVersion findVersion = null; try { findVersion = lv.GetVersion(_version); } catch (KeyNotFoundException) { } //var findVersion = lv.GetVersion(_version); if (findVersion == null) { MVersionMetadata findMVersion = null; try { findMVersion = lv.GetVersionMetadata(_version); } catch (KeyNotFoundException) { } if (findMVersion != null) { findMVersion.Save(game); } else { var findWVersion = new MojangVersionLoader().GetVersionMetadatas().GetVersionMetadata(_version); if (findWVersion != null) { findWVersion.Save(game); } else { return(null); } } } try { findVersion = lv.GetVersion(_version); } catch (KeyNotFoundException) { return(null); } var launchOption = new MLaunchOption { MaximumRamMb = ram, Session = se, Path = game, StartVersion = findVersion, GameLauncherName = "JML", GameLauncherVersion = "1.0" }; MLaunch launch = new MLaunch(launchOption); var process = launch.GetProcess(); process.Start(); //Process process = launcher.CreateProcess(launchOption); //process.Start(); return(process); }
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(); }
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; }