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 Btn_Login_Click(object sender, EventArgs e) { // 로그인 버튼 눌렀을때 // 로그인함 Btn_Login.Enabled = false; if (Txt_Pw.Text == "") { //MessageBox.Show("배포용. 복돌기능 막혀잇습니다."); session = MSession.GetOfflineSession(Txt_Email.Text); MessageBox.Show("Offline login Success : " + Txt_Email.Text); } else { var th = new Thread(new ThreadStart(delegate { var login = new MLogin(); var result = login.Authenticate(Txt_Email.Text, Txt_Pw.Text); if (result.Result == MLoginResult.Success) { MessageBox.Show("Login Success : " + result.Username); session = result; } else { MessageBox.Show(result.Result.ToString() + "\n" + result.Message); Invoke((MethodInvoker) delegate { Btn_Login.Enabled = true; }); } })); th.Start(); } }
private void SignIn(object sender, RoutedEventArgs e) { Progress.Value = 0; Progress.Opacity = 100; var th = new Thread(new ThreadStart(delegate { var login = new MLogin(); string email = ""; string password = ""; this.Dispatcher.Invoke(() => { email = Email.Text; password = userPassword.Password; }); var result = login.Authenticate(email, password); if (result.Result == MLoginResult.Success) { Session = result; Dispatcher.BeginInvoke(new Action(delegate { LoginStatus.Foreground = Brushes.LightGreen; LoginStatus.Text = "Successful login! Transfering you to the main window..."; this.Hide(); MainWindowNew mw = new MainWindowNew(Session); mw.Show(); })); } else { Dispatcher.BeginInvoke(new Action(delegate { LoginStatus.Foreground = Brushes.Red; LoginStatus.Text = "Please check your email/password"; Progress.Opacity = 0; })); } })); if (ifOffline.IsChecked != false) { Regex r = new Regex("^[a-zA-Z0-9_]+$"); if (r.IsMatch(Email.Text)) { MainWindowNew.ifOfflineMode = (bool)ifOffline.IsChecked; MainWindowNew mw = new MainWindowNew(MSession.GetOfflineSession(Email.Text)); mw.Show(); this.Close(); } else { LoginStatus.Text = "Invalid characters in your username"; Progress.Opacity = 0; } } else { th.Start(); } }
public MSession Login(string loginEmail, string LoginPass, bool ifPremium) { var session = new MSession(); if (ifPremium) { var login = new MLogin(); session = login.TryAutoLogin(); session = login.Authenticate(loginEmail, LoginPass); if (session.Result != MLoginResult.Success) { LoggerUpdate("[Auth]" + "Unsuccessful Login"); return(null); } else { LoggerUpdate("[Auth] Successful Login"); } accessToken = session.AccessToken; } else { session = MSession.GetOfflineSession(offlineUsername); } return(session); }
public MSession LoginToMinecraftOffline(string username) { Properties.Settings.Default.offlineUsername = username; Properties.Settings.Default.Save(); return(MSession.GetOfflineSession(username)); }
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(); }
MSession OfflineLogin(MSession session) { Console.WriteLine("Kullanıcı Adı Seçin:"); string username; username = Console.ReadLine(); return(MSession.GetOfflineSession(username)); }
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(); }
MSession Login() { bool premiumMode = false; MSession session; if (premiumMode) { Console.WriteLine("Try Auto login"); var login = new MLogin(); session = login.TryAutoLogin(); if (session.Result != MLoginResult.Success) { Console.WriteLine("Auto login failed : {0}", session.Result.ToString()); Console.WriteLine("Input mojang email : "); var email = Console.ReadLine(); Console.WriteLine("Input mojang password : "******"failed to login. {0} : {1}", session.Result.ToString(), session.Message); Console.ReadLine(); return(null); } } } else { session = MSession.GetOfflineSession("tester123"); } Console.WriteLine("Success to login : {0} / {1} / {2}", session.Username, session.UUID, session.AccessToken); return(session); }
private void Btn_Login_Click(object sender, EventArgs e) { // Login Btn_Login.Enabled = false; if (Txt_Pw.Text == "") // Offline Login { if (allowOffline) { Session = MSession.GetOfflineSession(Txt_Email.Text); MessageBox.Show("Offline login Success : " + Txt_Email.Text); } else { MessageBox.Show("Password was empty"); Btn_Login.Enabled = true; return; } } else // Online Login { var th = new Thread(new ThreadStart(delegate { var login = new MLogin(); var result = login.Authenticate(Txt_Email.Text, Txt_Pw.Text); if (result.Result == MLoginResult.Success) { MessageBox.Show("Login Success : " + result.Username); // Success Login Session = result; } else { MessageBox.Show(result.Result.ToString() + "\n" + result.Message); // Failed to login. Show error message Invoke((MethodInvoker) delegate { Btn_Login.Enabled = true; }); } })); th.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 guna2Button1_Click(object sender, EventArgs e) { if (txtUsername.Text == "") { MessageBox.Show("Boşluk olmadan ve sadece ingilizce harf kullanarak giriş yapın!"); // If username contains illegal character or empty } else { MainForm main = new MainForm(); main.Show(); //Username Label on MainForm gets this textboxes value main.LabelText = this.txtUsername.Text; UpdateSession(MSession.GetOfflineSession(txtUsername.Text)); //Updating MainForm Session this.Hide(); Save_Data(); } }
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(); }
MSession OfflineLogin() { // Create fake session by username return(MSession.GetOfflineSession("tester123")); }
private void btnLaunch_Click(object sender, EventArgs e) { //Launches game string selected = this.cbVersion.GetItemText(this.cbVersion.SelectedItem); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo versionInf = FileVersionInfo.GetVersionInfo(assembly.Location); if (guna2CheckBox1.Checked == true) { //Playing rpc if (Properties.Settings.Default.langtr == true) { client.UpdateState($"{selected} oynuyor."); } else { client.UpdateState($"Playing {selected}."); } } UpdateSession(MSession.GetOfflineSession(lbUsername.Text)); if (Session == null) { MessageBox.Show("İlk önce giriş yap"); return; } if (cbVersion.Text == "") { MessageBox.Show("Versiyon Seç / Select Version"); return; } var launchOption = createLaunchOption(); if (launchOption == null) { return; } //Creates launch options var version = cbVersion.Text; var useParallel = rbParallelDownload.Checked; var checkHash = cbCheckFileHash.Checked; var downloadAssets = !cbSkipAssetsDownload.Checked; var th = new Thread(() => { try { if (useMJava) { //Minecraft custom java var mjava = new MJava(MinecraftPath.Runtime); mjava.ProgressChanged += Launcher_ProgressChanged; var javapath = mjava.CheckJava(); launchOption.JavaPath = javapath; } MVersion versionInfo = Versions.GetVersion(version); launchOption.StartVersion = versionInfo; MDownloader downloader; if (useParallel) { downloader = new MParallelDownloader(MinecraftPath, versionInfo, 10, true); } else { downloader = new MDownloader(MinecraftPath, versionInfo); } downloader.ChangeFile += Launcher_FileChanged; downloader.ChangeProgress += Launcher_ProgressChanged; downloader.CheckHash = checkHash; downloader.DownloadAll(downloadAssets); var launch = new MLaunch(launchOption); var process = launch.GetProcess(); StartProcess(process); } catch (MDownloadFileException mex) { 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) { MessageBox.Show(wex.ToString() + "\n\nJava Problem"); } catch (Exception ex) { if (Properties.Settings.Default.langtr == true) { this.Alert("Oyun başlatılamadı", "Libaryler indirilemedi veya", "birşeyler ters gitti.", Form_Info.enmType.Error); }//error else { this.Alert("ERROR", "Libraries could not be downloaded or ", "something goes wrong.", Form_Info.enmType.Error); } MessageBox.Show(ex.ToString()); } }); th.Start(); }
static MSession OffLogin() { return(MSession.GetOfflineSession("")); }
private void LaunchButton_Click(object sender, EventArgs e) { string sptxt = Data.serverIP; if (!string.IsNullOrEmpty(sptxt)) { File.WriteAllText("mars_client\\serverip.ser", sptxt); } else { File.WriteAllText("mars_client\\serverip.ser", ""); } object _version = Data.versionString; if (_version == null) { MessageBox.Show("Please select a version!", "Mars", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string version = (string)_version; File.WriteAllText("mars_client\\version.ser", version); CMLauncher launcher = Data.launcher; bool forge = version.ToLower().Contains("forge"); OutputManager.ShowConsoleWindow(true); Console.WriteLine("[MARS] Setting up launch arguments... Please wait!"); MSession ssh; if (!Data.offline) { ssh = new MSession(); Type editor = typeof(MSession); editor.GetField("<ClientToken>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ssh, Data.clientToken); editor.GetField("<AccessToken>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ssh, Data.accessToken); editor.GetField("<Username>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ssh, Data.username); editor.GetField("<UUID>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ssh, Data.mcUUID); } else { string username = Data.username; ssh = MSession.GetOfflineSession(username); } Console.WriteLine("[MARS] Successfully created session."); MLaunchOption options = new MLaunchOption() { JavaPath = "java.exe", MaximumRamMb = GetInstalledMemoryMB() / 2, Session = ssh, VersionType = version, GameLauncherName = "MarsClient", GameLauncherVersion = "1.5", }; Console.WriteLine("[MARS] Assigned launch options."); if (forge) { string[] parts = version.Split('-'); string mcVer = parts[0]; string forgeVer = parts[2] + "-" + parts[3]; MProfile forgeProfile = launcher.GetProfile(mcVer, forgeVer); options.StartProfile = forgeProfile; } else { options.StartProfile = launcher.GetProfile(version); } if (!string.IsNullOrEmpty(sptxt)) { options.ServerIp = sptxt; } Console.WriteLine("[MARS] Located target profile. Launching..."); Console.WriteLine("[MARS] Moving to new thread..."); Data.hook.OnHookKeyPressed += Hook_OnHookKeyPressed; MLaunch launch = new MLaunch(options); mcThread = new Thread(new ParameterizedThreadStart(delegate(object obj) { MLaunch threadLaunch = (MLaunch)obj; Process pr = threadLaunch.GetProcess(); ProcessStartInfo psi = pr.StartInfo; psi.RedirectStandardOutput = true; psi.RedirectStandardInput = true; psi.UseShellExecute = false; staticMC = Process.Start(psi); staticMC.EnableRaisingEvents = true; launched = true; staticMC.Exited += delegate { //OutputManager.RemoveConsole(); rpcTimer.Stop(); Data.rpccli.Dispose(); Invoke((MethodInvoker) delegate { minecraftClosed = true; }); mcThread.Abort(); }; staticMC.OutputDataReceived += (object _, DataReceivedEventArgs _a) => { string txt = _a.Data; OutputManager.ProcessText(txt); if (txt == null) { return; } if (txt.Contains("[Client thread/INFO]: Connecting to")) { int timeind = txt.IndexOf(']'); string a = txt.Substring(timeind + 38); string b = a.Split(',')[0]; string newserver = "Server: " + b; if (!currentServer.Equals(newserver)) { Debug.WriteLine("Connected to: \"" + b + "\""); Console.WriteLine("Connected to: \"" + b + "\""); } currentServer = "Server: " + b; } }; staticMC.BeginOutputReadLine(); })); mcThread.Start(launch); int launchWaits = 0; while (staticMC == null) { launchWaits++; Console.WriteLine("[MARS] Waiting for process to launch... #{0}", launchWaits); Thread.Sleep(250); } Console.WriteLine("[MARS] Waiting for main window handle..."); Data.mcProcess = staticMC; while (staticMC.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(100); } Data.mcWindow = staticMC.MainWindowHandle; Console.WriteLine("\n\n[MARS] Got main window handle. Attaching UI framework..."); Console.WriteLine("[MARS] Building window...\n\n"); InGameWindow igw = new InGameWindow(); Data.hud = igw; igw.Show(); SetParent(igw.Handle, Data.mcWindow); igw.NowParented(); Console.WriteLine("[MARS] Begun window message pump."); Console.WriteLine("[MARS] Fetching HypixelSelf info..."); if (File.Exists("mars_client\\hypixelself.ser")) { Data.player = HypixelSelf.Deserialize(File.ReadAllText ("mars_client\\hypixelself.ser")); } Console.WriteLine("[MARS] Loaded, if any.\n\n"); Console.WriteLine("[MARS] Finished initialization."); }
private void btnOfflineLogin_Click(object sender, EventArgs e) { UpdateSession(MSession.GetOfflineSession(txtUsername.Text)); }
private void btn_Launch_Click(object sender, EventArgs e) { if (gameistarted == true) { killgame(); } else { gameistarted = true; string selected = this.cbVersion.GetItemText(this.cbVersion.SelectedItem); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo versionInf = FileVersionInfo.GetVersionInfo(assembly.Location); client.UpdateState($"Playing {selected}."); UpdateSession(MSession.GetOfflineSession(username_lbl.Text)); if (Session == null) { MessageBox.Show("İlk önce giriş yap"); return; } if (cbVersion.Text == "") { MessageBox.Show("Versiyon Seç / Select Version"); return; } var launchOption = createLaunchOption(); if (launchOption == null) { return; } //Creates launch options var version = cbVersion.Text; var th = new Thread(() => { try { if (useMJava) { //Minecraft custom java var mjava = new MJava(MinecraftPath.Runtime); mjava.ProgressChanged += Launcher_ProgressChanged; var javapath = mjava.CheckJava(); launchOption.JavaPath = javapath; } else { launchOption.JavaPath = javapath; } MVersion versionInfo = Versions.GetVersion(version); launchOption.StartVersion = versionInfo; MDownloader downloader; downloader = new MDownloader(MinecraftPath, versionInfo); downloader.ChangeFile += Launcher_FileChanged; downloader.ChangeProgress += Launcher_ProgressChanged; downloader.CheckHash = true; downloader.DownloadAll(); var launch = new MLaunch(launchOption); var process = launch.GetProcess(); StartProcess(process); btn_Launch.Text = "Oyunu Kapat"; } catch (MDownloadFileException mex) { 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()); gameistarted = false; } catch (Win32Exception wex) { gameistarted = false; MessageBox.Show(wex.ToString() + "\n\nJava Problem"); } catch (Exception ex) { gameistarted = false; MessageBox.Show(ex.ToString()); } }); th.Start(); } }
private void btnOfflineLogin_Click(object sender, EventArgs e) { UpdateSession(MSession.GetOfflineSession(txtUsername.Text)); MessageBox.Show("Success"); }