-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4aeb2a
commit 22fe97f
Showing
9 changed files
with
117 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
using MinecraftLaunch.Components.Authenticator; | ||
using MinecraftLaunch.Components.Checker; | ||
using MinecraftLaunch.Components.Resolver; | ||
using System.Diagnostics; | ||
|
||
MicrosoftAuthenticator authenticator = new("9fd44410-8ed7-4eb3-a160-9f1cc62c824c"); | ||
string gameFolder = "C:\\Users\\w\\Desktop\\temp\\.minecraft"; | ||
|
||
var result = await authenticator.DeviceFlowAuthAsync(x => { | ||
Console.WriteLine(x.UserCode); | ||
}); | ||
GameResolver resolver = new(gameFolder); | ||
var gameEntry = resolver.GetGameEntity("1.12.2"); | ||
|
||
if(result != null) { | ||
var account = await authenticator.AuthenticateAsync(); | ||
Console.WriteLine(account.Name); | ||
Console.WriteLine(account.Uuid); | ||
} | ||
ResourceChecker checker = new(gameEntry); | ||
var result = await checker.CheckAsync(); | ||
|
||
Console.WriteLine(result); | ||
Console.ReadKey(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
MinecraftLaunch/Components/Converter/PlatformEnumToStringJsonConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using MinecraftLaunch.Classes.Enums; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MinecraftLaunch.Components.Converter { | ||
public class PlatformEnumToStringJsonConverter : JsonConverter<Platform> { | ||
public override Platform Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { | ||
var platform = reader.GetString(); | ||
return platform switch { | ||
"osx" => Platform.osx, | ||
"linux" => Platform.linux, | ||
"windows" => Platform.windows, | ||
_ => Platform.windows, | ||
}; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, Platform value, JsonSerializerOptions options) { | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using MinecraftLaunch.Components.Converter; | ||
using System.Text.Encodings.Web; | ||
using System.Text.Json; | ||
|
||
namespace MinecraftLaunch.Utilities { | ||
public class JsonConverterUtil { | ||
public static JsonSerializerOptions DefaultJsonConverterOptions => Get(); | ||
|
||
private static JsonSerializerOptions Get() { | ||
var options = new JsonSerializerOptions() { | ||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | ||
}; | ||
|
||
options.Converters.Add(new PlatformEnumToStringJsonConverter()); | ||
|
||
return options; | ||
} | ||
} | ||
} |