diff --git a/src/main/java/pojlib/API.java b/src/main/java/pojlib/API.java index 4250da9e..a45c3ba5 100644 --- a/src/main/java/pojlib/API.java +++ b/src/main/java/pojlib/API.java @@ -212,7 +212,7 @@ public static void login(Activity activity) } MinecraftAccount acc = MinecraftAccount.load(activity.getFilesDir() + "/accounts"); - if(acc != null && (acc.expiresOn >= System.currentTimeMillis() || !hasWifi)) { + if(acc != null && (acc.expiresOn >= System.currentTimeMillis() || !hasWifi || acc.expiresOn == 0)) { currentAcc = acc; API.profileImage = MinecraftAccount.getSkinFaceUrl(API.currentAcc); API.profileName = API.currentAcc.username; diff --git a/src/main/java/pojlib/InstanceHandler.java b/src/main/java/pojlib/InstanceHandler.java index 7faefc06..c0c17257 100644 --- a/src/main/java/pojlib/InstanceHandler.java +++ b/src/main/java/pojlib/InstanceHandler.java @@ -17,6 +17,7 @@ import java.util.Locale; import pojlib.account.MinecraftAccount; +import pojlib.account.Msa; import pojlib.install.FabricMeta; import pojlib.install.Installer; import pojlib.install.MinecraftMeta; @@ -291,7 +292,7 @@ public static void launchInstance(Activity activity, MinecraftAccount account, M API.currentInstance = instance; JREUtils.redirectAndPrintJRELog(); VLoader.setAndroidInitInfo(activity); - JREUtils.launchJavaVM(activity, instance.generateLaunchArgs(account), instance); + JREUtils.launchJavaVM(activity, instance.generateLaunchArgs(account, !Msa.doesOwnGame), instance); } catch (Throwable e) { e.printStackTrace(); } diff --git a/src/main/java/pojlib/account/Msa.java b/src/main/java/pojlib/account/Msa.java index 637d7968..1b97a0d3 100644 --- a/src/main/java/pojlib/account/Msa.java +++ b/src/main/java/pojlib/account/Msa.java @@ -73,6 +73,11 @@ public MinecraftAccount performLogin(String msToken) throws MSAException { acc.username = mcName; acc.uuid = mcUuid; acc.expiresOn = mcExpiresOn; + } else { + acc.accessToken = "0"; + acc.username = "Player"; + acc.uuid = "00000000-0000-0000-0000-000000000000"; + acc.expiresOn = 0; } return acc; @@ -222,9 +227,9 @@ public static boolean checkMcProfile(String mcAccessToken) throws IOException, M mcUuid = uuidDashes; return true; } else { - Logger.getInstance().appendToLog("MicrosoftLogin | It seems that this Microsoft Account does not own the game."); + Logger.getInstance().appendToLog("MicrosoftLogin | It seems that this Microsoft Account does not own the game, setting game to demo mode."); doesOwnGame = false; - throw new MSAException("It seems like this account does not have a Minecraft profile. If you have Xbox Game Pass, please log in on https://minecraft.net/ and set it up."); + throw new MSAException("It seems like this account does not have a Minecraft profile, demo mode enabled. If you have Xbox Game Pass, please log in on https://minecraft.net/ and set it up."); } } diff --git a/src/main/java/pojlib/util/json/MinecraftInstances.java b/src/main/java/pojlib/util/json/MinecraftInstances.java index 8d43fd17..1eadf9c8 100644 --- a/src/main/java/pojlib/util/json/MinecraftInstances.java +++ b/src/main/java/pojlib/util/json/MinecraftInstances.java @@ -50,7 +50,7 @@ public static class Instance { public ProjectInfo[] extProjects; public boolean defaultMods; - public List generateLaunchArgs(MinecraftAccount account) { + public List generateLaunchArgs(MinecraftAccount account, boolean isDemoMode) { String[] mcArgs = {"--username", account.username, "--version", versionName, "--gameDir", gameDir, "--assetsDir", assetsDir, "--assetIndex", assetIndex, "--uuid", account.uuid.replace("-", ""), "--accessToken", account.accessToken, "--userType", account.userType, "--versionType", "release"}; @@ -58,6 +58,8 @@ public List generateLaunchArgs(MinecraftAccount account) { List allArgs = new ArrayList<>(Arrays.asList("-cp", classpath)); allArgs.add(mainClass); allArgs.addAll(Arrays.asList(mcArgs)); + if (isDemoMode) {allArgs.add("--demo");} + return allArgs; }