From 5a9db32f99d50efbf163d05cb3b450480ca44b14 Mon Sep 17 00:00:00 2001 From: YangSpring114 Date: Sun, 2 Jun 2024 01:07:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E5=90=88=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MinecraftLaunch.Test/Program.cs | 14 +++++----- .../Converter/AccountJsonConverter.cs | 26 ++++++++++++++++++- MinecraftLaunch/MinecraftLaunch.csproj | 2 +- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/MinecraftLaunch.Test/Program.cs b/MinecraftLaunch.Test/Program.cs index 7b3db3b..1d1845f 100644 --- a/MinecraftLaunch.Test/Program.cs +++ b/MinecraftLaunch.Test/Program.cs @@ -3,6 +3,8 @@ using MinecraftLaunch.Components.Analyzer; using MinecraftLaunch.Components.Installer; using MinecraftLaunch.Components.Authenticator; +using MinecraftLaunch.Extensions; +using MinecraftLaunch.Classes.Models.Auth; MirrorDownloadManager.IsUseMirrorDownloadSource = true; @@ -118,14 +120,14 @@ #endregion #region Crash Analysis -GameResolver gameResolver = new("C:\\Users\\w\\Desktop\\总整包\\MC\\mc启动器\\BakaXL\\.minecraft"); +//GameResolver gameResolver = new("C:\\Users\\w\\Desktop\\总整包\\MC\\mc启动器\\BakaXL\\.minecraft"); -var crashAnalyzer = new GameCrashAnalyzer(gameResolver.GetGameEntity("1.20.1"), true); -var reports = crashAnalyzer.AnalysisLogs(); +//var crashAnalyzer = new GameCrashAnalyzer(gameResolver.GetGameEntity("1.20.1"), true); +//var reports = crashAnalyzer.AnalysisLogs(); -foreach (var report in reports) { - Console.WriteLine(report); -} +//foreach (var report in reports) { +// Console.WriteLine(report); +//} #endregion Console.ReadKey(); \ No newline at end of file diff --git a/MinecraftLaunch/Components/Converter/AccountJsonConverter.cs b/MinecraftLaunch/Components/Converter/AccountJsonConverter.cs index f29cdd3..25d6660 100644 --- a/MinecraftLaunch/Components/Converter/AccountJsonConverter.cs +++ b/MinecraftLaunch/Components/Converter/AccountJsonConverter.cs @@ -46,6 +46,30 @@ public override Account Read(ref Utf8JsonReader reader, Type typeToConvert, Json } public override void Write(Utf8JsonWriter writer, Account value, JsonSerializerOptions options) { - throw new NotImplementedException(); + writer.WriteStartObject(); + + // Write common properties + writer.WriteString("Name", value.Name); + writer.WriteString("Uuid", value.Uuid.ToString()); + writer.WriteString("AccessToken", value.AccessToken); + + // Write specific properties based on account type + switch (value) { + case OfflineAccount offlineAccount: + writer.WriteNumber("Type", (int)AccountType.Offline); + break; + case MicrosoftAccount microsoftAccount: + writer.WriteNumber("Type", (int)AccountType.Microsoft); + writer.WriteString("RefreshToken", microsoftAccount.RefreshToken); + break; + case YggdrasilAccount yggdrasilAccount: + writer.WriteNumber("Type", (int)AccountType.Yggdrasil); + writer.WriteString("ClientToken", yggdrasilAccount.ClientToken); + writer.WriteString("YggdrasilServerUrl", yggdrasilAccount.YggdrasilServerUrl); + break; + } + + writer.WriteEndObject(); } + } \ No newline at end of file diff --git a/MinecraftLaunch/MinecraftLaunch.csproj b/MinecraftLaunch/MinecraftLaunch.csproj index 2623f94..4e54b9e 100644 --- a/MinecraftLaunch/MinecraftLaunch.csproj +++ b/MinecraftLaunch/MinecraftLaunch.csproj @@ -1,6 +1,6 @@  - 3.1.0-preview02 + 3.1.0-preview03