diff --git a/CmlLib/CmlLib.csproj b/CmlLib/CmlLib.csproj
index c3eaee5..96100d5 100644
--- a/CmlLib/CmlLib.csproj
+++ b/CmlLib/CmlLib.csproj
@@ -4,7 +4,7 @@
netstandard2.0
8.0
enable
- 3.3.8
+ 3.3.9
Minecraft Launcher Library for .NET
Support all version, forge, optifine
diff --git a/CmlLibWinFormSample/CmlLibWinFormSample.csproj b/CmlLibWinFormSample/CmlLibWinFormSample.csproj
index 1b114ac..6a91e94 100644
--- a/CmlLibWinFormSample/CmlLibWinFormSample.csproj
+++ b/CmlLibWinFormSample/CmlLibWinFormSample.csproj
@@ -172,5 +172,13 @@
CmlLib
+
+
+ 3.0.2
+
+
+ 1.0.1823.32
+
+
\ No newline at end of file
diff --git a/CmlLibWinFormSample/LoginForm.Designer.cs b/CmlLibWinFormSample/LoginForm.Designer.cs
index 84785db..a5fc54f 100644
--- a/CmlLibWinFormSample/LoginForm.Designer.cs
+++ b/CmlLibWinFormSample/LoginForm.Designer.cs
@@ -28,171 +28,31 @@ protected override void Dispose(bool disposing)
///
private void InitializeComponent()
{
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.txtEmail = new System.Windows.Forms.TextBox();
- this.txtPassword = new System.Windows.Forms.TextBox();
- this.btnLogin = new System.Windows.Forms.Button();
- this.btnSignout = new System.Windows.Forms.Button();
- this.btnInvalidate = new System.Windows.Forms.Button();
- this.btnDeleteToken = new System.Windows.Forms.Button();
- this.label7 = new System.Windows.Forms.Label();
- this.gMojangLogin = new System.Windows.Forms.GroupBox();
- this.btnAutoLoginMojangLauncher = new System.Windows.Forms.Button();
- this.btnAutoLogin = new System.Windows.Forms.Button();
this.gOfflineLogin = new System.Windows.Forms.GroupBox();
this.btnOfflineLogin = new System.Windows.Forms.Button();
this.txtUsername = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.btnSignout = new System.Windows.Forms.Button();
+ this.btnAddNewAccount = new System.Windows.Forms.Button();
+ this.btnXboxLogin = new System.Windows.Forms.Button();
+ this.txtXboxUsername = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
- this.gMojangLogin.SuspendLayout();
this.gOfflineLogin.SuspendLayout();
+ this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(41, 105);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(56, 15);
- this.label5.TabIndex = 5;
- this.label5.Text = "Email : ";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(13, 135);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(87, 15);
- this.label6.TabIndex = 6;
- this.label6.Text = "Password : ";
- //
- // txtEmail
- //
- this.txtEmail.Location = new System.Drawing.Point(104, 101);
- this.txtEmail.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.txtEmail.Name = "txtEmail";
- this.txtEmail.Size = new System.Drawing.Size(325, 25);
- this.txtEmail.TabIndex = 7;
- //
- // txtPassword
- //
- this.txtPassword.Location = new System.Drawing.Point(104, 131);
- this.txtPassword.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.txtPassword.Name = "txtPassword";
- this.txtPassword.Size = new System.Drawing.Size(325, 25);
- this.txtPassword.TabIndex = 8;
- this.txtPassword.UseSystemPasswordChar = true;
- //
- // btnLogin
- //
- this.btnLogin.Location = new System.Drawing.Point(435, 100);
- this.btnLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnLogin.Name = "btnLogin";
- this.btnLogin.Size = new System.Drawing.Size(86, 59);
- this.btnLogin.TabIndex = 9;
- this.btnLogin.Text = "Login";
- this.btnLogin.UseVisualStyleBackColor = true;
- this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
- //
- // btnSignout
- //
- this.btnSignout.Location = new System.Drawing.Point(104, 179);
- this.btnSignout.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnSignout.Name = "btnSignout";
- this.btnSignout.Size = new System.Drawing.Size(86, 29);
- this.btnSignout.TabIndex = 10;
- this.btnSignout.Text = "Signout";
- this.btnSignout.UseVisualStyleBackColor = true;
- this.btnSignout.Click += new System.EventHandler(this.btnSignout_Click);
- //
- // btnInvalidate
- //
- this.btnInvalidate.Location = new System.Drawing.Point(197, 179);
- this.btnInvalidate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnInvalidate.Name = "btnInvalidate";
- this.btnInvalidate.Size = new System.Drawing.Size(86, 29);
- this.btnInvalidate.TabIndex = 11;
- this.btnInvalidate.Text = "Invalidate";
- this.btnInvalidate.UseVisualStyleBackColor = true;
- this.btnInvalidate.Click += new System.EventHandler(this.btnInvalidate_Click);
- //
- // btnDeleteToken
- //
- this.btnDeleteToken.Location = new System.Drawing.Point(289, 179);
- this.btnDeleteToken.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnDeleteToken.Name = "btnDeleteToken";
- this.btnDeleteToken.Size = new System.Drawing.Size(112, 29);
- this.btnDeleteToken.TabIndex = 12;
- this.btnDeleteToken.Text = "Delete Token";
- this.btnDeleteToken.UseVisualStyleBackColor = true;
- this.btnDeleteToken.Click += new System.EventHandler(this.btnDeleteToken_Click);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(34, 185);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(68, 15);
- this.label7.TabIndex = 13;
- this.label7.Text = "Logout : ";
- //
- // gMojangLogin
- //
- this.gMojangLogin.Controls.Add(this.btnAutoLoginMojangLauncher);
- this.gMojangLogin.Controls.Add(this.btnAutoLogin);
- this.gMojangLogin.Controls.Add(this.btnLogin);
- this.gMojangLogin.Controls.Add(this.label7);
- this.gMojangLogin.Controls.Add(this.label5);
- this.gMojangLogin.Controls.Add(this.btnDeleteToken);
- this.gMojangLogin.Controls.Add(this.label6);
- this.gMojangLogin.Controls.Add(this.btnInvalidate);
- this.gMojangLogin.Controls.Add(this.txtEmail);
- this.gMojangLogin.Controls.Add(this.btnSignout);
- this.gMojangLogin.Controls.Add(this.txtPassword);
- this.gMojangLogin.Location = new System.Drawing.Point(12, 65);
- this.gMojangLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.gMojangLogin.Name = "gMojangLogin";
- this.gMojangLogin.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.gMojangLogin.Size = new System.Drawing.Size(527, 220);
- this.gMojangLogin.TabIndex = 14;
- this.gMojangLogin.TabStop = false;
- this.gMojangLogin.Text = "Mojang Login";
- //
- // btnAutoLoginMojangLauncher
- //
- this.btnAutoLoginMojangLauncher.Location = new System.Drawing.Point(104, 64);
- this.btnAutoLoginMojangLauncher.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnAutoLoginMojangLauncher.Name = "btnAutoLoginMojangLauncher";
- this.btnAutoLoginMojangLauncher.Size = new System.Drawing.Size(322, 29);
- this.btnAutoLoginMojangLauncher.TabIndex = 15;
- this.btnAutoLoginMojangLauncher.Text = "TryAutoLogin (launcher_accounts.json)";
- this.btnAutoLoginMojangLauncher.UseVisualStyleBackColor = true;
- this.btnAutoLoginMojangLauncher.Click += new System.EventHandler(this.btnAutoLoginMojangLauncher_Click);
- //
- // btnAutoLogin
- //
- this.btnAutoLogin.Location = new System.Drawing.Point(104, 27);
- this.btnAutoLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.btnAutoLogin.Name = "btnAutoLogin";
- this.btnAutoLogin.Size = new System.Drawing.Size(322, 29);
- this.btnAutoLogin.TabIndex = 14;
- this.btnAutoLogin.Text = "TryAutoLogin (CmlLib.Core cache file)";
- this.btnAutoLogin.UseVisualStyleBackColor = true;
- this.btnAutoLogin.Click += new System.EventHandler(this.btnAutoLogin_Click);
- //
// gOfflineLogin
//
this.gOfflineLogin.Controls.Add(this.btnOfflineLogin);
this.gOfflineLogin.Controls.Add(this.txtUsername);
this.gOfflineLogin.Controls.Add(this.label8);
- this.gOfflineLogin.Location = new System.Drawing.Point(12, 326);
+ this.gOfflineLogin.Location = new System.Drawing.Point(11, 159);
this.gOfflineLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.gOfflineLogin.Name = "gOfflineLogin";
this.gOfflineLogin.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.gOfflineLogin.Size = new System.Drawing.Size(527, 72);
+ this.gOfflineLogin.Size = new System.Drawing.Size(527, 93);
this.gOfflineLogin.TabIndex = 15;
this.gOfflineLogin.TabStop = false;
this.gOfflineLogin.Text = "Offline Login";
@@ -228,74 +88,108 @@ private void InitializeComponent()
// label2
//
this.label2.AutoSize = true;
- this.label2.Font = new System.Drawing.Font("굴림", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte) (129)));
+ this.label2.Font = new System.Drawing.Font("굴림", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label2.Location = new System.Drawing.Point(8, 15);
this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(532, 19);
+ this.label2.Size = new System.Drawing.Size(440, 15);
this.label2.TabIndex = 17;
this.label2.Text = "CmlLib.Core (.NET Framework WinForm) Sample Launcher";
//
- // label1
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.btnSignout);
+ this.groupBox1.Controls.Add(this.btnAddNewAccount);
+ this.groupBox1.Controls.Add(this.btnXboxLogin);
+ this.groupBox1.Controls.Add(this.txtXboxUsername);
+ this.groupBox1.Controls.Add(this.label3);
+ this.groupBox1.Location = new System.Drawing.Point(12, 47);
+ this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.groupBox1.Size = new System.Drawing.Size(527, 93);
+ this.groupBox1.TabIndex = 16;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Microsoft Xbox Login";
//
- this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte) (129)));
- this.label1.Location = new System.Drawing.Point(19, 42);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(317, 15);
- this.label1.TabIndex = 18;
- this.label1.Text = "Please login with your mojang account : ";
+ // btnSignout
+ //
+ this.btnSignout.Location = new System.Drawing.Point(267, 50);
+ this.btnSignout.Name = "btnSignout";
+ this.btnSignout.Size = new System.Drawing.Size(158, 23);
+ this.btnSignout.TabIndex = 4;
+ this.btnSignout.Text = "Signout";
+ this.btnSignout.UseVisualStyleBackColor = true;
+ this.btnSignout.Click += new System.EventHandler(this.btnSignout_Click);
+ //
+ // btnAddNewAccount
+ //
+ this.btnAddNewAccount.Location = new System.Drawing.Point(92, 50);
+ this.btnAddNewAccount.Name = "btnAddNewAccount";
+ this.btnAddNewAccount.Size = new System.Drawing.Size(169, 23);
+ this.btnAddNewAccount.TabIndex = 3;
+ this.btnAddNewAccount.Text = "Add a new account";
+ this.btnAddNewAccount.UseVisualStyleBackColor = true;
+ this.btnAddNewAccount.Click += new System.EventHandler(this.btnAddNewAccount_Click);
+ //
+ // btnXboxLogin
+ //
+ this.btnXboxLogin.Location = new System.Drawing.Point(434, 19);
+ this.btnXboxLogin.Name = "btnXboxLogin";
+ this.btnXboxLogin.Size = new System.Drawing.Size(86, 54);
+ this.btnXboxLogin.TabIndex = 2;
+ this.btnXboxLogin.Text = "Login";
+ this.btnXboxLogin.UseVisualStyleBackColor = true;
+ this.btnXboxLogin.Click += new System.EventHandler(this.btnXboxLogin_Click);
+ //
+ // txtXboxUsername
+ //
+ this.txtXboxUsername.Location = new System.Drawing.Point(92, 19);
+ this.txtXboxUsername.Name = "txtXboxUsername";
+ this.txtXboxUsername.ReadOnly = true;
+ this.txtXboxUsername.Size = new System.Drawing.Size(333, 25);
+ this.txtXboxUsername.TabIndex = 1;
//
// label3
//
this.label3.AutoSize = true;
- this.label3.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte) (129)));
- this.label3.Location = new System.Drawing.Point(12, 298);
+ this.label3.Location = new System.Drawing.Point(6, 22);
this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(280, 15);
- this.label3.TabIndex = 19;
- this.label3.Text = "or, Just type a username you want :";
+ this.label3.Size = new System.Drawing.Size(82, 15);
+ this.label3.TabIndex = 0;
+ this.label3.Text = "Username: ";
//
// LoginForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(551, 410);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label1);
+ this.ClientSize = new System.Drawing.Size(551, 260);
+ this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.gOfflineLogin);
- this.Controls.Add(this.gMojangLogin);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "LoginForm";
this.Text = "LoginForm";
this.Load += new System.EventHandler(this.LoginForm_Load);
- this.gMojangLogin.ResumeLayout(false);
- this.gMojangLogin.PerformLayout();
this.gOfflineLogin.ResumeLayout(false);
this.gOfflineLogin.PerformLayout();
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
+
}
#endregion
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.TextBox txtEmail;
- private System.Windows.Forms.TextBox txtPassword;
- private System.Windows.Forms.Button btnLogin;
- private System.Windows.Forms.Button btnSignout;
- private System.Windows.Forms.Button btnInvalidate;
- private System.Windows.Forms.Button btnDeleteToken;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.GroupBox gMojangLogin;
- private System.Windows.Forms.Button btnAutoLogin;
private System.Windows.Forms.GroupBox gOfflineLogin;
private System.Windows.Forms.Button btnOfflineLogin;
private System.Windows.Forms.TextBox txtUsername;
private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Button btnAutoLoginMojangLauncher;
private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Button btnSignout;
+ private System.Windows.Forms.Button btnAddNewAccount;
+ private System.Windows.Forms.Button btnXboxLogin;
+ private System.Windows.Forms.TextBox txtXboxUsername;
private System.Windows.Forms.Label label3;
}
}
\ No newline at end of file
diff --git a/CmlLibWinFormSample/LoginForm.cs b/CmlLibWinFormSample/LoginForm.cs
index 4743240..52d712b 100644
--- a/CmlLibWinFormSample/LoginForm.cs
+++ b/CmlLibWinFormSample/LoginForm.cs
@@ -1,6 +1,6 @@
using CmlLib.Core.Auth;
+using CmlLib.Core.Auth.Microsoft;
using System;
-using System.Threading;
using System.Windows.Forms;
namespace CmlLibWinFormSample
@@ -12,151 +12,69 @@ public LoginForm()
InitializeComponent();
}
- MLogin login = new MLogin();
+ JELoginHandler loginHandler;
+ MSession session;
- private void LoginForm_Load(object sender, EventArgs e)
+ private async void LoginForm_Load(object sender, EventArgs e)
{
- btnAutoLogin_Click(null, null);
- }
+ this.Enabled = false;
- private void btnAutoLogin_Click(object sender, EventArgs e)
- {
- gMojangLogin.Enabled = false;
- gOfflineLogin.Enabled = false;
+ loginHandler = JELoginHandlerBuilder.BuildDefault();
- var th = new Thread(() =>
+ try
{
- var result = login.TryAutoLogin();
-
- if (result.Result != MLoginResult.Success)
- {
- MessageBox.Show($"Failed to AutoLogin : {result.Result}\n{result.ErrorMessage}");
- Invoke(new Action(() =>
- {
- gMojangLogin.Enabled = true;
- gOfflineLogin.Enabled = true;
- }));
- return;
- }
-
- MessageBox.Show("Auto Login Success!");
- Invoke(new Action(() =>
- {
- gMojangLogin.Enabled = true;
- gOfflineLogin.Enabled = true;
-
- btnAutoLogin.Enabled = false;
- btnLogin.Enabled = false;
- btnAutoLoginMojangLauncher.Enabled = false;
- btnLogin.Text = "Auto Login\nSuccess";
-
- UpdateSession(result.Session);
- }));
- });
- th.Start();
- }
-
- private void btnAutoLoginMojangLauncher_Click(object sender, EventArgs e)
- {
- gMojangLogin.Enabled = false;
- gOfflineLogin.Enabled = false;
-
- var th = new Thread(() =>
+ session = await loginHandler.AuthenticateSilently();
+ txtXboxUsername.Text = session.Username;
+ }
+ catch (Exception ex)
{
- var result = login.TryAutoLoginFromMojangLauncher();
-
- if (result.Result != MLoginResult.Success)
- {
- MessageBox.Show($"Failed to AutoLogin : {result.Result}\n{result.ErrorMessage}");
- Invoke(new Action(() =>
- {
- gMojangLogin.Enabled = true;
- gOfflineLogin.Enabled = true;
- }));
- return;
- }
-
- MessageBox.Show("Auto Login Success!");
- Invoke(new Action(() =>
- {
- gMojangLogin.Enabled = true;
- gOfflineLogin.Enabled = true;
-
- btnAutoLogin.Enabled = false;
- btnAutoLoginMojangLauncher.Enabled = false;
- btnLogin.Enabled = false;
- btnLogin.Text = "Auto Login\nSuccess";
+ Console.WriteLine(ex);
+ }
- UpdateSession(result.Session);
- }));
- });
- th.Start();
+ this.Enabled = true;
}
- private void btnLogin_Click(object sender, EventArgs e)
+ private async void btnAddNewAccount_Click(object sender, EventArgs e)
{
- if (string.IsNullOrWhiteSpace(txtEmail.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
+ this.Enabled = false;
+ try
{
- MessageBox.Show("Empty Textbox");
- return;
+ session = await loginHandler.AuthenticateInteractively();
+ txtXboxUsername.Text = session.Username;
}
-
- gMojangLogin.Enabled = false;
- gOfflineLogin.Enabled = false;
-
- var th = new Thread(new ThreadStart(delegate
+ catch (Exception ex)
{
- var result = login.Authenticate(txtEmail.Text, txtPassword.Text);
- if (result.Result == MLoginResult.Success)
- {
- MessageBox.Show("Login Success"); // Success Login
- Invoke(new Action(() =>
- {
- UpdateSession(result.Session);
- }));
- }
- else
- {
- MessageBox.Show(result.Result.ToString() + "\n" + result.ErrorMessage); // Failed to login. Show error message
- Invoke(new Action(() =>
- {
- gMojangLogin.Enabled = true;
- gOfflineLogin.Enabled = true;
- }));
- }
- }));
- th.Start();
+ MessageBox.Show(ex.ToString());
+ }
+ this.Enabled = true;
}
- private void btnSignout_Click(object sender, EventArgs e)
+ private async void btnSignout_Click(object sender, EventArgs e)
{
- var result = login.Signout(txtEmail.Text, txtPassword.Text);
- if (result)
+ this.Enabled = false;
+ try
{
- MessageBox.Show("Success");
- gMojangLogin.Enabled = true;
+ await loginHandler.SignoutWithBrowser();
+ session = null;
+ txtXboxUsername.Clear();
}
- else
- MessageBox.Show("Fail");
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.ToString());
+ }
+ this.Enabled = true;
}
- private void btnInvalidate_Click(object sender, EventArgs e)
+ private void btnXboxLogin_Click(object sender, EventArgs e)
{
- var result = login.Invalidate();
- if (result)
+ if (session == null)
{
- MessageBox.Show("Success");
- gMojangLogin.Enabled = true;
+ MessageBox.Show("Click 'Add a new account' first");
}
else
- MessageBox.Show("Fail");
- }
-
- private void btnDeleteToken_Click(object sender, EventArgs e)
- {
- login.DeleteTokenFile();
- MessageBox.Show("Success");
- gMojangLogin.Enabled = true;
+ {
+ UpdateSession(session);
+ }
}
private void btnOfflineLogin_Click(object sender, EventArgs e)