Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
fix some java 21 stuff
  • Loading branch information
SolDev69 committed Apr 10, 2024
1 parent 6d4ceb7 commit 5a876df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
public class JRE21Util {
public static final String NEW_JRE_NAME = "Internal-21";
public static boolean checkInternalNewJre(AssetManager assetManager) {
String launcher_jre17_version;
String installed_jre17_version = MultiRTUtils.__internal__readBinpackVersion(NEW_JRE_NAME);
String launcher_jre21_version;
String installed_jre21_version = MultiRTUtils.__internal__readBinpackVersion(NEW_JRE_NAME);
try {
launcher_jre17_version = Tools.read(assetManager.open("components/jre-new/version"));
launcher_jre21_version = Tools.read(assetManager.open("components/jre-new/version"));
}catch (IOException exc) {
//we don't have a runtime included!
return installed_jre17_version != null; //if we have one installed -> return true -> proceed (no updates but the current one should be functional)
return installed_jre21_version != null; //if we have one installed -> return true -> proceed (no updates but the current one should be functional)
//if we don't -> return false -> Cannot find compatible Java runtime
}
if(!launcher_jre17_version.equals(installed_jre17_version)) // this implicitly checks for null, so it will unpack the runtime even if we don't have one installed
return unpackJre17(assetManager, launcher_jre17_version);
if(!launcher_jre21_version.equals(installed_jre21_version)) // this implicitly checks for null, so it will unpack the runtime even if we don't have one installed
return unpackJre21(assetManager, launcher_jre21_version);
else return true;
}

private static boolean unpackJre17(AssetManager assetManager, String rt_version) {
private static boolean unpackJre21(AssetManager assetManager, String rt_version) {
try {
MultiRTUtils.installRuntimeNamedBinpack(
assetManager.open("components/jre-new/universal.tar.xz"),
Expand Down Expand Up @@ -73,7 +73,7 @@ public static boolean installNewJreIfNeeded(Activity activity, JMinecraftVersion
minecraftProfile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + appropriateRuntime;
LauncherProfiles.load();
} else {
if (versionInfo.javaVersion.majorVersion <= 17) { // there's a chance we have an internal one for this case
if (versionInfo.javaVersion.majorVersion <= 21) { // there's a chance we have an internal one for this case
if (!JRE21Util.checkInternalNewJre(activity.getAssets())){
showRuntimeFail(activity, versionInfo);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void downloadGame(Activity activity, JMinecraftVersionList.Version verIn
mDownloaderThreadException = new AtomicReference<>(null);

if(!downloadAndProcessMetadata(activity, verInfo, versionName)) {
throw new RuntimeException(activity.getString(R.string.exception_failed_to_unpack_jre17));
throw new RuntimeException(activity.getString(R.string.exception_failed_to_unpack_jre21));
}

ArrayBlockingQueue<Runnable> taskQueue =
Expand Down Expand Up @@ -190,7 +190,7 @@ private MinecraftClientInfo getClientInfo(JMinecraftVersionList.Version verInfo)
* @param activity Activity, used for automatic installation of JRE 17 if needed
* @param verInfo The JMinecraftVersionList.Version from the version list, if available
* @param versionName The version ID (necessary)
* @return false if JRE17 installation failed, true otherwise
* @return false if JRE21 installation failed, true otherwise
* @throws IOException if the download of any of the metadata files fails
*/
private boolean downloadAndProcessMetadata(Activity activity, JMinecraftVersionList.Version verInfo, String versionName) throws IOException, MirrorTamperedException {
Expand Down
2 changes: 1 addition & 1 deletion app_solcraftlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
<string name="preference_ask_for_notification_description">Click to re-request the notification permission, required for game/modpack background downloads to work properly.</string>
<string name="preference_vsync_in_zink_title">Allow V-Sync with Zink</string>
<string name="preference_vsync_in_zink_description">Allows the launcher to use internal system APIs to enable V-Sync for Zink. Turn this off if your launcher suddenly crashes with Zink after a system update.</string>
<string name="exception_failed_to_unpack_jre17">Failed to install JRE 17</string>
<string name="exception_failed_to_unpack_jre21">Failed to install JRE 17</string>
<string name="newdl_starting">Reading game metadata…</string>
<string name="newdl_downloading_metadata">Downloading game metadata (%s)</string>
<string name="newdl_downloading_game_files">Downloading game files… (%d/%d, %.2f MB)</string>
Expand Down

0 comments on commit 5a876df

Please sign in to comment.