Exemplo n.º 1
0
        // get minecraft Profile ID
        public string GetMCProfileID(Guid iAccountId)
        {
            MCUserAccountProfile Profile = GetActiveProfile(GetAccount(iAccountId));

            return(Profile.id);
        }
Exemplo n.º 2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (TxtUser.Text == "" || TxtPass.Text == "")
            {
                MessageBox.Show(this, "Eines der Felder ist leer.", "Fehlerhafte Eingabe!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // Check LoginData
                AuthHandler          Auth     = new AuthHandler();
                AuthenticateResponse AuthData = new AuthenticateResponse();
                try
                {
                    AuthData = Auth.Authenticate(TxtUser.Text.ToString().Trim(), TxtPass.Text.ToString().Trim());
                }
                catch (MCInvalidCredentialsException ex)
                {
                    MessageBox.Show(this, ex.Message.ToString(), "Fehlermeldung von Minecraft.net", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TxtPass.Focus();
                    TxtPass.SelectAll();

                    return;
                }
                catch (MCUserMigratedException ex)
                {
                    MessageBox.Show(this, ex.Message.ToString(), "Fehlermeldung von Minecraft.net", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TxtPass.Focus();
                    TxtPass.SelectAll();

                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message.ToString(), "Verbindungsfehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TxtPass.Focus();
                    TxtPass.SelectAll();

                    return;
                }

                MCUserAccount newAcc = new MCUserAccount
                {
                    guid     = Guid.NewGuid(),
                    profiles = new List <MCUserAccountProfile>(),

                    accessToken   = AuthData.AccessToken,
                    clientToken   = AuthData.ClientToken,
                    username      = TxtUser.Text.ToString().Trim(),
                    activeProfile = AuthData.SelectedProfile.Id
                };

                for (int i = 0; i < AuthData.AvailableProfiles.Length; i++)
                {
                    MCUserAccountProfile newprofile = new MCUserAccountProfile
                    {
                        id     = AuthData.AvailableProfiles[i].Id,
                        name   = AuthData.AvailableProfiles[i].Name,
                        legacy = AuthData.AvailableProfiles[i].Legacy
                    };
                    newAcc.profiles.Add(newprofile);
                }

                Manager U = new Manager();
                U.AddAccount(newAcc);

                // set default user if only one given
                MCUser user = U.GetAccounts();
                if (U.GetNumAccounts() == 1)
                {
                    U.SetDefault(newAcc.guid);
                }

                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 3
0
        // get ingame player name
        public string GetPlayerName(Guid iAccountId)
        {
            MCUserAccountProfile Profile = GetActiveProfile(GetAccount(iAccountId));

            return(Profile.name);
        }