Esempio n. 1
0
        private void Main_Shown(object sender, EventArgs e)
        {
            // Initialize launcher
            Txt_Path.Text = Minecraft.GetOSDefaultPath();

            var th = new Thread(new ThreadStart(delegate
            {
                InitializeLauncher();

                // Try auto login

                var login       = new MLogin();
                MSession result = login.TryAutoLogin();

                if (result.Result != MLoginResult.Success)
                {
                    return;
                }

                MessageBox.Show("¡Auto inicio de sesión completado!\n\nUsuario: " + result.Username);
                Session = result;

                Invoke((MethodInvoker) delegate
                {
                    Btn_Login.Enabled = false;
                    Btn_Login.Text    = "Auto inicio\nCompletado";
                    Txt_User.Text     = Session.Username;
                    Txt_Pass.Text     = "#########";
                });
            }));

            th.Start();
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        async Task StartAsync(MSession session) // async version
        {
            var path     = new MinecraftPath();
            var launcher = new CMLauncher(path);

            System.Net.ServicePointManager.DefaultConnectionLimit = 256;

            var versions = await launcher.GetAllVersionsAsync();

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

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

            Console.WriteLine("input version (example: 1.12.2) : ");
            var versionName = Console.ReadLine();
            var process     = await launcher.CreateProcessAsync(versionName, new MLaunchOption
            {
                Session      = session,
                MaximumRamMb = 1024
            });

            Console.WriteLine(process.StartInfo.Arguments);
            process.Start();
        }
Esempio n. 4
0
        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();
            }
        }
Esempio n. 5
0
        }       //	loadDefault

        /// <summary>
        /// Validate Login.
        /// Creates session and calls ModelValidationEngine
        /// </summary>
        /// <param name="org">log-in org</param>
        /// <returns>error message</returns>
        public String ValidateLogin(KeyNamePair org)
        {
            String info         = m_user + ",R:" + m_role.ToString() + ",O=" + m_org.ToString();
            int    AD_Client_ID = m_ctx.GetAD_Client_ID();
            int    AD_Org_ID    = org.GetKey();
            int    AD_Role_ID   = m_ctx.GetAD_Role_ID();
            int    AD_User_ID   = m_ctx.GetAD_User_ID();
            //
            MSession session = MSession.Get(m_ctx, true);

            if (AD_Client_ID != session.GetAD_Client_ID())
            {
                session.SetAD_Client_ID(AD_Client_ID);
            }
            if (AD_Org_ID != session.GetAD_Org_ID())
            {
                session.SetAD_Org_ID(AD_Org_ID);
            }
            if (AD_Role_ID != session.GetAD_Role_ID())
            {
                session.SetAD_Role_ID(AD_Role_ID);
            }
            //
            String error = ModelValidationEngine.Get().LoginComplete(AD_Client_ID, AD_Org_ID, AD_Role_ID, AD_User_ID);

            if (error != null && error.Length > 0)
            {
                session.SetDescription(error);
                session.Save();
                return(error);
            }
            //	Log
            session.Save();
            return(null);
        }       //	validateLogin
Esempio n. 6
0
        public static void LogOut()
        {
            for (int i = 2; i < _sWindows.Count; i++)
            {
                object o = _sWindows[i];
                if (o != null)
                {
                    //if (o is System.Windows.Forms.Form)
                    //{
                    //    ((System.Windows.Forms.Form)o).Close();
                    //}
                    //else if (o is System.Windows.Forms.ContainerControl)
                    //{
                    //    System.Windows.Forms.Form frm = ((System.Windows.Forms.ContainerControl)o).ParentForm;
                    //    if (frm != null)
                    //    {
                    //        frm.Close();
                    //        frm = null;
                    //    }
                    //}
                }
            }

            MSession session = MSession.Get(Env.GetContext(), false);   //	finish

            if (session != null)
            {
                session.Logout();
            }
            VLogErrorBuffer.Get(true).ResetBuffer(false);
            Reset(true);
        }
Esempio n. 7
0
        public MSession LoginToMinecraftOffline(string username)
        {
            Properties.Settings.Default.offlineUsername = username;
            Properties.Settings.Default.Save();

            return(MSession.GetOfflineSession(username));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        private async void buttonLogin_Click(object sender, EventArgs e)
        {
            this.Enabled          = false;
            this.labelStatus.Text = "Please wait...";

            try
            {
                var username    = this.textBoxUsername.Text;
                var password    = this.textBoxPassword.Text;
                var loginResult = await new MLogin().AuthenticateAsync(username, password);

                if (loginResult.IsSuccess)
                {
                    this.Session      = loginResult.Session;
                    this.DialogResult = DialogResult.OK;
                    AppConfig.Update(config => config.LastUsername = username);
                    return;
                }

                MessageBox.Show(this,
                                $"Login failed: {loginResult.ErrorMessage}",
                                "Login Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                this.textBoxPassword.Text = "";
                this.textBoxPassword.Focus();
            }
            finally
            {
                this.Enabled          = true;
                this.labelStatus.Text = string.Empty;
            }
        }
Esempio n. 10
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            // Initialize launcher
            Txt_Path.Text = Minecraft.GetOSDefaultPath();

            var th = new Thread(new ThreadStart(delegate
            {
                InitializeLauncher();

                // Try auto login

                var login       = new MLogin();
                MSession result = login.TryAutoLogin();

                if (result.Result != MLoginResult.Success)
                {
                    return;
                }

                MessageBox.Show("Auto Login Success!");
                Session = result;
                Invoke((MethodInvoker) delegate {
                    Btn_Login.Enabled = false;
                    Btn_Login.Text    = "Auto Login\nSuccess";
                });
            }));

            th.Start();
        }
Esempio n. 11
0
        private MLaunchOption CreateLaunchOptions(MSession session)
        {
            var computerInfo = new ComputerInfo();
            var config       = AppConfig.Get();
            var ramSize      = ((long)computerInfo.TotalPhysicalMemory).Bytes();
            // Set JVM max memory to 2 GB less than the user's total RAM, at most 12 GB but at least 5
            var maxRamGb = (int)Math.Max(Math.Min(ramSize.Gigabytes - 4, 12), 5);
            var maxRamMb = maxRamGb.Gigabytes().Megabytes;

            if (config.MaxRamMb is not null)
            {
                if (config.MaxRamMb <= 2048)
                {
                    throw new InvalidOperationException("Max RAM must be greater than 2048 megabytes");
                }

                maxRamMb = Math.Min(maxRamMb, config.MaxRamMb.Value);
            }

            return(new MLaunchOption {
                Path = new MinecraftPath(PackBuilder.ProfilePath),
                JavaPath = config.JavaPath,
                MinimumRamMb = (int)1.Gigabytes().Megabytes,
                MaximumRamMb = (int)maxRamMb,
                GameLauncherName = this.packMetadata.DisplayName,
                Session = session,
            });
        }
Esempio n. 12
0
        private void ThreadAutoLogin(string email, string password, string username, bool autorun, string ramamount)
        {
            formMain.pannelswitch(false);
            MSession    sessionUtilisateur = null;
            ThreadLogin threadLogin        = new ThreadLogin(formMain);

            if (!String.IsNullOrEmpty(email) && !String.IsNullOrWhiteSpace(email) && !String.IsNullOrEmpty(password) && !String.IsNullOrWhiteSpace(password))
            {
                Thread threadLoginMojang = new Thread(() => threadLogin.ThreadLoginMojang(email, password));
                threadLoginMojang.Start();
                threadLoginMojang.Join();
            }
            else if (String.IsNullOrEmpty(username) && String.IsNullOrWhiteSpace(username))
            {
                Thread threadLoginOffline = new Thread(() => threadLogin.ThreadLoginOffline(username));
                threadLoginOffline.Start();
                threadLoginOffline.Join();
            }

            sessionUtilisateur = formMain.SessionUtilisateur;

            if (sessionUtilisateur != null && autorun)
            {
                AutoRun(ramamount);
            }
        }
 public MLoginResponse(MLoginResult result, MSession session, string errormsg, string rawresponse)
 {
     Result       = result;
     Session      = session;
     ErrorMessage = errormsg;
     RawResponse  = rawresponse;
 }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        void TestStartSync(MSession session)
        {
            var path     = new MinecraftPath();
            var launcher = new CMLauncher(path);

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

            var versions = launcher.GetAllVersions();

            foreach (var item in versions)
            {
                Console.WriteLine(item.Name);
            }

            var process = launcher.CreateProcess("1.5.2", new MLaunchOption
            {
                Session = session
            });

            var processUtil = new CmlLib.Utils.ProcessUtil(process);

            processUtil.OutputReceived += (s, e) => Console.WriteLine(e);
            processUtil.StartWithEvents();
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
 private void setSession(MSession session)
 {
     this.session        = session;
     btnStart.Enabled    = true;
     txtAccessToken.Text = session.AccessToken;
     txtUUID.Text        = session.UUID;
     txtUsername.Text    = session.Username;
 }
Esempio n. 18
0
        private void ThreadRunGame(string ramAmount)
        {
            runMinecraft runMinecraft       = new runMinecraft();
            MSession     sessionUtilisateur = formMain.SessionUtilisateur;
            MProfile     profileUtilisateur = formMain.ProfileUtilisateur;

            runMinecraft.Run(profileUtilisateur, sessionUtilisateur, ramAmount);
        }
Esempio n. 19
0
 private void Logout_and_Cache_Load(object sender, EventArgs e)
 {
     session         = login.GetLocalToken();
     lvAT.Text       = session.AccessToken;
     lvUsername.Text = session.Username;
     lvUUID.Text     = session.UUID;
     lvCT.Text       = session.ClientToken;
 }
Esempio n. 20
0
 private void UpdateSession(MSession session)
 {
     this.Session    = session;
     lvAT.Text       = session.AccessToken;
     lvUsername.Text = session.Username;
     lvUUID.Text     = session.UUID;
     UpdateCachedSession();
 }
Esempio n. 21
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;
        }
Esempio n. 22
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;
        }
Esempio n. 23
0
        MSession OfflineLogin(MSession session)
        {
            Console.WriteLine("Kullanıcı Adı Seçin:");

            string username;

            username = Console.ReadLine();

            return(MSession.GetOfflineSession(username));
        }
Esempio n. 24
0
 /// <summary>
 /// Before Save
 /// </summary>
 /// <param name="newRecord">new</param>
 /// <returns>true</returns>
 protected override bool BeforeSave(bool newRecord)
 {
     if (newRecord && GetAD_Session_ID() == 0)
     {
         MSession session       = MSession.Get(GetCtx(), true);
         int      AD_Session_ID = session.GetAD_Session_ID();
         SetAD_Session_ID(AD_Session_ID);
     }
     return(true);
 }
Esempio n. 25
0
        private void UpdateSession(MSession session)
        {
            // Success to login!

            var mainForm = new MainForm(session);

            mainForm.FormClosed += (s, e) => this.Close();
            mainForm.Show();
            this.Hide();
        }
Esempio n. 26
0
        public void TryAutoLogin()
        {
            MLogin         Log      = new MLogin();
            MLoginResponse Response = Log.TryAutoLogin();

            if (Response.IsSuccess)
            {
                CurrentSession = Response.Session;
            }
        }
        public static void XBoxLogin(FileManager.Modpacks modpack)
        {
            MicrosoftLoginWindow loginWindow = new MicrosoftLoginWindow();
            MSession             session     = loginWindow.ShowLoginDialog();

            if (session != null)
            {
                SESSION = session;
                _       = LaunchGameAsync(modpack);
            }
        }
Esempio n. 28
0
 public static bool onRequestBefore(bool ifCheck)
 {
     if (ifCheck)
     {
         if (!MSession.exist("username"))
         {
             Native.writeToPage(Native.getErrorMsg("您还未登陆, 请登陆再试!")); return(false);
         }
     }
     return(true);
 }
Esempio n. 29
0
        /// <summary>
        /// Function will check if Action need to save or not.
        /// If Yes, then save information in table.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="ActionOrigin">Action Origin(Menu, Window, Form)</param>
        /// <param name="OriginName">(Form name or window name)</param>
        /// <param name="AD_Table_ID">AD_Table_ID of table from where action intiated</param>
        /// <param name="Record_ID">Selected Record_ID</param>
        /// <param name="Process_ID">AD_Process_ID with which report is linked</param>
        /// <param name="ProcessName">Name of Process</param>
        /// <param name="fileType">Requested file type(PDF, CSV, RTF)</param>
        /// <param name="description">Desciption like filename or anything else</param>
        /// <param name="ActionType">Action type.(Viewed Or Downloaded)</param>
        public static void SaveActionLog(Ctx ctx, string ActionOrigin, string OriginName, int AD_Table_ID, int Record_ID,
                                         int processID, string ProcessName, string fileType, string description, string ActionType)
        {
            //Save Action Log key is fetched from System Config window
            string canSave = Util.GetValueOfString(ctx.GetContext("#SAVE_ACTION_LOG"));

            if (!canSave.Equals("Y"))
            {
                return;
            }

            string reportTypeForLog = MActionLog.ACTIONTYPE_View;
            string descriptonForLog = "Report Viewed";

            if (!string.IsNullOrEmpty(description))
            {
                descriptonForLog = description;
            }
            if (!string.IsNullOrEmpty(ActionType))
            {
                reportTypeForLog = ActionType;
            }
            // As PDF viewed in Browser, so PDF report Viewed message will be saved.
            else if (fileType.Equals(ProcessCtl.ReportType_PDF))
            {
                reportTypeForLog = MActionLog.ACTIONTYPE_View;
                descriptonForLog = "PDF Report Viewed";
            }
            else if (fileType.Equals(ProcessCtl.ReportType_CSV))
            {
                reportTypeForLog = MActionLog.ACTIONTYPE_Download;
                descriptonForLog = "CSV Report Downloaded";
            }
            else if (fileType.Equals(ProcessCtl.ReportType_RTF))
            {
                reportTypeForLog = MActionLog.ACTIONTYPE_Download;
                descriptonForLog = "RTF Report Downloaded";
            }
            else if (fileType.Equals(ProcessCtl.ReportType_HTML))
            {
                reportTypeForLog = MActionLog.ACTIONTYPE_View;
                descriptonForLog = "Report Viewed";
            }
            if (processID > 0)
            {
                descriptonForLog += ", Process Name:->" + ProcessName;
            }

            MSession sess = MSession.Get(ctx);

            sess.ActionLog(ctx, sess.GetAD_Session_ID(), ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID(),
                           ActionOrigin, reportTypeForLog, OriginName, descriptonForLog, AD_Table_ID, Record_ID);
        }
Esempio n. 30
0
        public void ThreadLoginOffline(string username)
        {
            formMain.pannelswitch(false);

            LoginMojang loginMojang        = new LoginMojang();
            MSession    sessionUtilisateur = loginMojang.LoginToMinecraftOffline(username);

            formMain.AcountnameLabel("Bonjour " + sessionUtilisateur.Username);
            Checkprofile();

            formMain.SessionUtilisateur = sessionUtilisateur;
        }