-
Notifications
You must be signed in to change notification settings - Fork 869
优化微软登录未购买提示 #5611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
优化微软登录未购买提示 #5611
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a69465d
update
CiiLu 7e6d948
update
CiiLu 61c17cd
update
CiiLu 83938f9
Apply suggestions from code review
CiiLu 0951665
update
CiiLu 338e56d
Merge remote-tracking branch 'origin/msmmsmsmsmsmsm' into msmmsmsmsmsmsm
CiiLu e4f9a74
Merge branch 'HMCL-dev:main' into msmmsmsmsmsmsm
CiiLu 79b3c37
Merge branch 'main' into msmmsmsmsmsmsm
CiiLu be7f429
update
CiiLu 2a7b1e1
update
CiiLu 7787adf
update
CiiLu 18317ef
update
CiiLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -25,7 +25,10 @@ | |
| import org.jackhuang.hmcl.auth.OAuth; | ||
| import org.jackhuang.hmcl.auth.ServerDisconnectException; | ||
| import org.jackhuang.hmcl.auth.ServerResponseMalformedException; | ||
| import org.jackhuang.hmcl.auth.yggdrasil.*; | ||
| import org.jackhuang.hmcl.auth.yggdrasil.CompleteGameProfile; | ||
| import org.jackhuang.hmcl.auth.yggdrasil.RemoteAuthenticationException; | ||
| import org.jackhuang.hmcl.auth.yggdrasil.Texture; | ||
| import org.jackhuang.hmcl.auth.yggdrasil.TextureType; | ||
| import org.jackhuang.hmcl.util.StringUtils; | ||
| import org.jackhuang.hmcl.util.gson.*; | ||
| import org.jackhuang.hmcl.util.io.*; | ||
|
|
@@ -245,7 +248,14 @@ private static MinecraftProfileResponse getMinecraftProfile(String tokenType, St | |
| .createConnection(); | ||
| int responseCode = conn.getResponseCode(); | ||
| if (responseCode == HTTP_NOT_FOUND) { | ||
| throw new NoMinecraftJavaEditionProfileException(); | ||
| var license = HttpRequest.GET("https://api.minecraftservices.com/entitlements/license") | ||
| .authorization(tokenType, accessToken) | ||
| .getJson(MinecraftLicense.class); | ||
|
Comment on lines
+251
to
+253
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| boolean hasMinecraftLicense = license.items().stream() | ||
| .anyMatch(item -> "game_minecraft".equals(item.name())); | ||
|
CiiLu marked this conversation as resolved.
|
||
| if (!hasMinecraftLicense) { | ||
| throw new MinecraftJavaEditionLicenseNotFoundException(); | ||
| } | ||
|
CiiLu marked this conversation as resolved.
|
||
| } else if (responseCode != 200) { | ||
| throw new ResponseCodeException("https://api.minecraftservices.com/minecraft/profile", responseCode); | ||
| } | ||
|
|
@@ -324,7 +334,10 @@ public String getRedirect() { | |
| public final static class XBox400Exception extends AuthenticationException { | ||
| } | ||
|
|
||
| public final static class NoMinecraftJavaEditionProfileException extends AuthenticationException { | ||
| public final static class MinecraftJavaEditionProfileNotFoundException extends AuthenticationException { | ||
| } | ||
|
|
||
| public final static class MinecraftJavaEditionLicenseNotFoundException extends AuthenticationException { | ||
| } | ||
|
|
||
| public final static class NoXuiException extends AuthenticationException { | ||
|
|
@@ -425,6 +438,19 @@ public static class MinecraftProfileResponseCape { | |
|
|
||
| } | ||
|
|
||
| public record MinecraftLicense( | ||
| List<MinecraftLicenseItem> items, | ||
| String signature, | ||
| String keyId | ||
| ) { | ||
| } | ||
|
|
||
| public record MinecraftLicenseItem( | ||
| String name, | ||
| String signature | ||
| ) { | ||
| } | ||
|
|
||
|
CiiLu marked this conversation as resolved.
|
||
| public static class MinecraftProfileResponse extends MinecraftErrorResponse implements Validation { | ||
| @SerializedName("id") | ||
| UUID id; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.