From 85a7585492e06ffdad31a15bf4bc58173979e3a3 Mon Sep 17 00:00:00 2001 From: YangSpring114 Date: Sun, 28 Jan 2024 21:42:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MinecraftLaunch.Test/Program.cs | 59 ++----------------- .../Authenticator/MicrosoftAuthenticator.cs | 5 +- .../Authenticator/YggdrasilAuthenticator.cs | 5 +- .../Resolver/LauncherProfileResolver.cs | 5 ++ 4 files changed, 12 insertions(+), 62 deletions(-) create mode 100644 MinecraftLaunch/Components/Resolver/LauncherProfileResolver.cs diff --git a/MinecraftLaunch.Test/Program.cs b/MinecraftLaunch.Test/Program.cs index eae58b7..187b14b 100644 --- a/MinecraftLaunch.Test/Program.cs +++ b/MinecraftLaunch.Test/Program.cs @@ -1,61 +1,12 @@ -using MinecraftLaunch.Components.Launcher; +using System.IO.Compression; +using MinecraftLaunch.Extensions; +using MinecraftLaunch.Components.Launcher; using MinecraftLaunch.Components.Resolver; using MinecraftLaunch.Classes.Models.Launch; -using MinecraftLaunch.Components.Authenticator; -using System.IO.Compression; -using MinecraftLaunch.Classes.Models.Download; using MinecraftLaunch.Components.Downloader; -using MinecraftLaunch.Extensions; - - -var list = new List { - new() { - Url = "https://download.mcbbs.net/version/1.20.4/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "1.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.20.3/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "2.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.20.2/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "3.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.20.1/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "4.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.16.5/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "5.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.7.10/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "6.jar" - }, - new() { - Url = "https://download.mcbbs.net/version/1.12.2/client", - Path = "C:\\Users\\w\\Desktop\\temp\\cache", - Name = "7.jar" - }, -}; - -BatchDownloader downloader = new(); -downloader.Setup(list); - -downloader.ProgressChanged += (_, args) => { - Console.WriteLine($"{args.ToSpeedText()} - {args.ToPercentage() * 100:0.00}%"); -}; +using MinecraftLaunch.Classes.Models.Download; +using MinecraftLaunch.Components.Authenticator; -var result = await downloader.DownloadAsync(); -Console.WriteLine(result); -return; var account = new OfflineAuthenticator("Yang114").Authenticate(); var resolver = new GameResolver(".minecraft"); diff --git a/MinecraftLaunch/Components/Authenticator/MicrosoftAuthenticator.cs b/MinecraftLaunch/Components/Authenticator/MicrosoftAuthenticator.cs index e9cf949..3a41173 100644 --- a/MinecraftLaunch/Components/Authenticator/MicrosoftAuthenticator.cs +++ b/MinecraftLaunch/Components/Authenticator/MicrosoftAuthenticator.cs @@ -11,12 +11,9 @@ namespace MinecraftLaunch.Components.Authenticator {//W.I.P public class MicrosoftAuthenticator(string clientId) : IAuthenticator { private MicrosoftAccount _account; - private string _clientId = clientId; - private OAuth2TokenResponse _oAuth2TokenResponse; - - private IEnumerable _scopes => ["XboxLive.signin", "offline_access", "openid", "profile", "email"]; + private readonly IEnumerable _scopes = ["XboxLive.signin", "offline_access", "openid", "profile", "email"]; public bool IsCheckOwnership { get; set; } diff --git a/MinecraftLaunch/Components/Authenticator/YggdrasilAuthenticator.cs b/MinecraftLaunch/Components/Authenticator/YggdrasilAuthenticator.cs index 3323e8f..a405bc4 100644 --- a/MinecraftLaunch/Components/Authenticator/YggdrasilAuthenticator.cs +++ b/MinecraftLaunch/Components/Authenticator/YggdrasilAuthenticator.cs @@ -15,13 +15,10 @@ namespace MinecraftLaunch.Components.Authenticator { public class YggdrasilAuthenticator(YggdrasilAccount account) : IAuthenticator> { - private string _url = account?.YggdrasilServerUrl; - private string _email; - private string _password; - private YggdrasilAccount _account = account; + private string _url = account?.YggdrasilServerUrl; public YggdrasilAuthenticator(string url, string email, string password) : this(default) { _url = url; diff --git a/MinecraftLaunch/Components/Resolver/LauncherProfileResolver.cs b/MinecraftLaunch/Components/Resolver/LauncherProfileResolver.cs new file mode 100644 index 0000000..d4837b6 --- /dev/null +++ b/MinecraftLaunch/Components/Resolver/LauncherProfileResolver.cs @@ -0,0 +1,5 @@ +namespace MinecraftLaunch.Components.Resolver; + +public sealed class LauncherProfileResolver { + +} \ No newline at end of file