Skip to content

Commit

Permalink
Fix goofy login error
Browse files Browse the repository at this point in the history
  • Loading branch information
SolDev69 committed Apr 30, 2024
2 parents 52e7f61 + 3d1f24e commit b24a091
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ dependencies {
// implementation 'com.intuit.ssp:ssp-android:1.0.5'

implementation 'org.tukaani:xz:1.8'
implementation 'com.github.PojavLauncherTeam:exp4j:60eaec6f78'
// Our version of exp4j can be built from source at
// https://github.com/PojavLauncherTeam/exp4j
implementation 'net.sourceforge.htmlcleaner:htmlcleaner:2.6.1'
implementation 'com.bytedance:bytehook:1.0.9'

Expand Down
Binary file added app_pojavlauncher/libs/exp4j-0.4.9-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class MicrosoftBackgroundLogin {
private static final String xstsAuthUrl = "https://xsts.auth.xboxlive.com/xsts/authorize";
private static final String mcLoginUrl = "https://api.minecraftservices.com/authentication/login_with_xbox";
private static final String mcProfileUrl = "https://api.minecraftservices.com/minecraft/profile";
private static final String mcStoreUrl = "https://api.minecraftservices.com/entitlements/mcstore";

private final boolean mIsRefresh;
private final String mAuthCode;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void performLogin(@Nullable final ProgressListener progressListener,
notifyProgress(progressListener, 4);
String mcToken = acquireMinecraftToken(xsts[0], xsts[1]);
notifyProgress(progressListener, 5);
fetchOwnedItems(mcToken);
checkMcProfile(mcToken);

MinecraftAccount acc = MinecraftAccount.load(mcName);
Expand Down Expand Up @@ -255,6 +257,21 @@ private String acquireMinecraftToken(String xblUhs, String xblXsts) throws IOExc
}
}

private void fetchOwnedItems(String mcAccessToken) throws IOException {
URL url = new URL(mcStoreUrl);

HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Authorization", "Bearer " + mcAccessToken);
conn.setUseCaches(false);
conn.connect();
if(conn.getResponseCode() < 200 || conn.getResponseCode() >= 300) {
throw getResponseThrowable(conn);
}
// We don't need any data from this request, it just needs to happen in order for
// the MS servers to work properly. The data from this is practically useless
// as it does not indicate whether the user owns the game through Game Pass.
}

private void checkMcProfile(String mcAccessToken) throws IOException, JSONException {
URL url = new URL(mcProfileUrl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public void run() {

@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if(v.equals(mParentView)) repositionView();
// We need to check whether dimensions match or not because here we are looking specifically for changes of dimensions
// and Android keeps calling this without dimensions actually changing for some reason.
if(v.equals(mParentView) && (left != oldLeft || right != oldRight || top != oldTop || bottom != oldBottom)) {
// Need to post this, because it is not correct to resize the view
// during a layout pass.
post(this::repositionView);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/main_touchpad"
android:translationZ="1dp"
android:focusable="false"
android:visibility="gone"/>


Expand Down

0 comments on commit b24a091

Please sign in to comment.