Make use of the runtime selected in Per-Version config

This commit is contained in:
artdeell 2021-07-15 11:49:38 +03:00
parent c57fe8300f
commit b8a25f3791
2 changed files with 15 additions and 3 deletions

View File

@ -130,7 +130,6 @@ public class BaseMainActivity extends LoggableActivity {
// FIXME: is it safe fot multi thread?
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
MultiRTUtils.setRuntimeNamed(this,LauncherPreferences.PREF_DEFAULT_RUNTIME);
logFile = new File(Tools.DIR_GAME_HOME, "latestlog.txt");
logFile.delete();
logFile.createNewFile();
@ -140,7 +139,16 @@ public class BaseMainActivity extends LoggableActivity {
mVersionInfo = Tools.getVersionInfo(null,mProfile.selectedVersion);
setTitle("Minecraft " + mProfile.selectedVersion);
PerVersionConfig.VersionConfig cfg = PerVersionConfig.configMap.get(mProfile.selectedVersion);
String runtime = LauncherPreferences.PREF_DEFAULT_RUNTIME;
if(cfg != null) {
if(cfg.selectedRuntime != null) {
if(MultiRTUtils.forceReread(cfg.selectedRuntime).versionString != null) {
runtime = cfg.selectedRuntime;
}
}
}
MultiRTUtils.setRuntimeNamed(this,runtime);
// Minecraft 1.13+
isInputStackCall = mVersionInfo.arguments != null;

View File

@ -162,10 +162,14 @@ public class MultiRTUtils {
}
public static void setRuntimeNamed(Context ctx, String name) throws IOException {
File dest = new File(runtimeFolder,"/"+name);
if(!dest.exists()) return;
if((!dest.exists()) || MultiRTUtils.forceReread(name).versionString == null) throw new RuntimeException("Selected runtime is broken!");
Tools.DIR_HOME_JRE = dest.getAbsolutePath();
JREUtils.relocateLibPath(ctx);
}
public static Runtime forceReread(String name) {
cache.remove(name);
return read(name);
}
public static Runtime read(String name) {
if(cache.containsKey(name)) return cache.get(name);
Runtime retur;