New toggle option: Restart before launching game
This option allows the launcher to restart itself before launching the game, therefore all changes are applied such as JVM Arguments and Java version. The restart mechanism doesn't always work, so a toggle is here for now.
This commit is contained in:
1 parent
2e30a1470f
commit
1b0d564379
12 files changed
+148
-73
No files matched your search
@@ -40,10 +40,27 @@ public class PLaunchApp {
|
||||
UIKit.launchUI();
|
||||
}
|
||||
|
||||
public static String getSelectedVersion() {
|
||||
try {
|
||||
String plistContent = Tools.read(Tools.DIR_APP_DATA + "/launcher_preferences.plist");
|
||||
plistContent = plistContent.substring(plistContent.indexOf("<key>selected_version</key>") + 27);
|
||||
return plistContent.substring(
|
||||
plistContent.indexOf("<string>") + 8,
|
||||
plistContent.indexOf("</string>"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Called from SurfaceViewController
|
||||
public static void launchMinecraft() {
|
||||
System.out.println("Launching Minecraft " + mVersion.id);
|
||||
try {
|
||||
if (AccountJNI.CURRENT_ACCOUNT == null) {
|
||||
AccountJNI.CURRENT_ACCOUNT = MinecraftAccount.load(System.getProperty("pojav.selectedAccount"));
|
||||
mVersion = Tools.getVersionInfo(getSelectedVersion());
|
||||
}
|
||||
System.out.println("Launching Minecraft " + mVersion.id);
|
||||
String configPath;
|
||||
if (mVersion.logging.client.file.id.equals("client-1.12.xml")) {
|
||||
configPath = Tools.DIR_BUNDLE + "/log4j-rce-patch-1.12.xml";
|
||||
@@ -64,18 +81,7 @@ public class PLaunchApp {
|
||||
maxProgress = 0;
|
||||
|
||||
UIKit.updateProgressSafe(0, "Finding a version");
|
||||
String mcver = "1.16.5";
|
||||
|
||||
try {
|
||||
String plistContent = Tools.read(Tools.DIR_APP_DATA + "/launcher_preferences.plist");
|
||||
plistContent = plistContent.substring(plistContent.indexOf("<key>selected_version</key>") + 27);
|
||||
mcver = plistContent.substring(
|
||||
plistContent.indexOf("<string>") + 8,
|
||||
plistContent.indexOf("</string>"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
UIKit.updateProgressSafe(0, "Could not parse plist, defaulting to Minecraft 1.16.5");
|
||||
}
|
||||
String mcver = getSelectedVersion();
|
||||
|
||||
AccountJNI.CURRENT_ACCOUNT.selectedVersion = mcver;
|
||||
try {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class AccountJNI {
|
||||
public static volatile MinecraftAccount CURRENT_ACCOUNT;
|
||||
|
||||
// Call back about account credentials for login
|
||||
public static boolean loginAccount(int type,
|
||||
public static String loginAccount(int type,
|
||||
String data // One of:
|
||||
// Local username
|
||||
// Mojang json response
|
||||
@@ -61,12 +61,12 @@ public class AccountJNI {
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return CURRENT_ACCOUNT.username;
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(th);
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
Reference in new issue
Block a user