Skip to content

Commit

Permalink
优化部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSpring114 committed Jan 28, 2024
1 parent f734854 commit 85a7585
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 62 deletions.
59 changes: 5 additions & 54 deletions MinecraftLaunch.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -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<DownloadRequest> {
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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
namespace MinecraftLaunch.Components.Authenticator {//W.I.P
public class MicrosoftAuthenticator(string clientId) : IAuthenticator<MicrosoftAccount> {
private MicrosoftAccount _account;

private string _clientId = clientId;

private OAuth2TokenResponse _oAuth2TokenResponse;

private IEnumerable<string> _scopes => ["XboxLive.signin", "offline_access", "openid", "profile", "email"];
private readonly IEnumerable<string> _scopes = ["XboxLive.signin", "offline_access", "openid", "profile", "email"];

public bool IsCheckOwnership { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@

namespace MinecraftLaunch.Components.Authenticator {
public class YggdrasilAuthenticator(YggdrasilAccount account) : IAuthenticator<IEnumerable<YggdrasilAccount>> {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace MinecraftLaunch.Components.Resolver;

public sealed class LauncherProfileResolver {

}

0 comments on commit 85a7585

Please sign in to comment.