diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java index eab43f0b52..ba025c6577 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java @@ -37,9 +37,8 @@ public static void main(String[] args) throws Throwable { Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable th) { - Tools.showError(th); - // Block this thread from exiting - while (true) {} + th.printStackTrace(); + System.exit(1); } }); diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java index 40c1b97bde..4ab2d5ed6f 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -225,24 +225,7 @@ public static String generateLaunchClassPath(JMinecraftVersionList.Version info) return libStr.toString(); } - - public static void showError(Throwable e) { - showError(e, false); - } - - public static void showError(final Throwable e, final boolean exitIfOk) { - showError("Error", e, exitIfOk, false); - } - - public static void showError(final String title, final Throwable e, final boolean exitIfOk) { - showError(title, e, exitIfOk, false); - } - - private static void showError(final String title, final Throwable e, final boolean exitIfOk, final boolean showMore) { - e.printStackTrace(); - System.exit(1); - } - + public static void moveInside(String from, String to) { File fromFile = new File(from); for (File fromInside : fromFile.listFiles()) { diff --git a/Natives/LauncherNavigationController.m b/Natives/LauncherNavigationController.m index a06c12b0be..b131e20681 100644 --- a/Natives/LauncherNavigationController.m +++ b/Natives/LauncherNavigationController.m @@ -372,10 +372,8 @@ - (void)invokeAfterJITEnabled:(void(^)(void))handler { BOOL hasTrollStoreJIT = getEntitlementValue(@"com.apple.private.local.sandboxed-jit"); if (isJITEnabled(false)) { - dispatch_async(dispatch_get_main_queue(), ^{ - [ALTServerManager.sharedManager stopDiscovering]; - handler(); - }); + [ALTServerManager.sharedManager stopDiscovering]; + handler(); return; } else if (hasTrollStoreJIT) { NSURL *jitURL = [NSURL URLWithString:[NSString stringWithFormat:@"apple-magnifier://enable-jit?bundle-id=%@", NSBundle.mainBundle.bundleIdentifier]]; diff --git a/Natives/main.m b/Natives/main.m index c7a2528b27..efdf566547 100644 --- a/Natives/main.m +++ b/Natives/main.m @@ -127,41 +127,6 @@ void init_logDeviceAndVer(char *argument) { //printEntitlementAvailability(@"dynamic-codesigning"); } -void init_migrateDirIfNecessary() { - NSString *oldDir = @"/usr/share/pojavlauncher"; - if ([fm fileExistsAtPath:oldDir]) { - NSString *newDir = @""; - if ([@(getenv("HOME")) isEqualToString:@"/var/mobile"]) { - newDir = [NSString stringWithFormat:@"%s/Documents/PojavLauncher", getenv("HOME")]; - } else { - newDir = [NSString stringWithFormat:@"%s/Documents", getenv("HOME")]; - } - [fm moveItemAtPath:oldDir toPath:newDir error:nil]; - [fm removeItemAtPath:oldDir error:nil]; - } -} - -void init_migrateToPlist(char* prefKey, char* filename) { - NSError *error; - NSString *path_str = [NSString stringWithFormat:@"%s/%s", getenv("POJAV_HOME"), filename]; - NSDebugLog(@"[Pre-Init] Beginning migration for file \"%s\"", filename); - NSString *str = [NSString stringWithContentsOfFile:path_str encoding:NSUTF8StringEncoding error:&error]; - if (error == nil && ![str hasPrefix:@"#README"]) { - NSString *finalized = @""; - for (NSString *line in [str componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]) { - if (![line hasPrefix:@"#"]) { - finalized = [finalized stringByAppendingString:[NSString stringWithFormat:@"%@ ", line]]; - } - } - - setPrefObject(@(prefKey), finalized); - [@"#README - this file has been merged into launcher_preferences.plist" writeToFile:path_str atomically:YES encoding:NSUTF8StringEncoding error:nil]; - NSLog(@"[Pre-Init] File \"%s\" has been migrated", filename); - } else { - NSDebugLog(@"[Pre-Init] File \"%s\" was already migrated", filename); - } -} - void init_redirectStdio() { NSLog(@"[Pre-init] Starting logging STDIO to latestlog.txt\n"); @@ -246,16 +211,20 @@ void init_setupMultiDir() { } const char *home = getenv("POJAV_HOME"); - NSString *jvmPath = [NSString stringWithFormat:@"%s/java_runtimes", home]; NSString *lasmPath = [NSString stringWithFormat:@"%s/Library/Application Support/minecraft", home]; NSString *multidirPath = [NSString stringWithFormat:@"%s/instances/%@", home, multidir]; - NSString *demoPath = [NSString stringWithFormat:@"%s/.demo", home]; - [fm createDirectoryAtPath:jvmPath withIntermediateDirectories:YES attributes:nil error:nil]; - [fm createDirectoryAtPath:demoPath withIntermediateDirectories:YES attributes:nil error:nil]; - [fm createDirectoryAtPath:multidirPath withIntermediateDirectories:YES attributes:nil error:nil]; + + NSArray *dirsToCreate = @[ + [NSString stringWithFormat:@"%s/.demo", home], + [NSString stringWithFormat:@"%s/java_runtimes", home], + lasmPath.stringByDeletingLastPathComponent, + multidirPath + ]; + for (NSString *dir in dirsToCreate) { + [fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil]; + } [fm removeItemAtPath:lasmPath error:nil]; - [fm createDirectoryAtPath:lasmPath.stringByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil]; [fm createSymbolicLinkAtPath:lasmPath withDestinationPath:multidirPath error:nil]; [fm changeCurrentDirectoryPath:lasmPath]; setenv("POJAV_GAME_DIR", lasmPath.UTF8String, 1); @@ -318,7 +287,6 @@ int main(int argc, char *argv[]) { setenv("BUNDLE_PATH", dirname(argv[0]), 1); isJailbroken = init_checkForJailbreak(); - init_migrateDirIfNecessary(); init_setupHomeDirectory(); init_redirectStdio(); init_logDeviceAndVer(argv[0]); @@ -337,9 +305,6 @@ int main(int argc, char *argv[]) { init_setupAccounts(); init_setupCustomControls(); - init_migrateToPlist("java.java_args", "overrideargs.txt"); - init_migrateToPlist("java.env_variables", "custom_env.txt"); - // If sandbox is disabled, W^X JIT can be enabled by PojavLauncher itself if (!isJITEnabled(true) && getEntitlementValue(@"com.apple.private.security.no-sandbox")) { NSLog(@"[Pre-init] no-sandbox: YES, trying to enable JIT"); diff --git a/Natives/main_hook.m b/Natives/main_hook.m index 872afc4067..74996066c2 100644 --- a/Natives/main_hook.m +++ b/Natives/main_hook.m @@ -55,12 +55,6 @@ void hooked_exit(int code) { } handle_fatal_exit(code); -/* - if (runtimeJavaVMPtr != NULL) { - (*runtimeJavaVMPtr)->DestroyJavaVM(runtimeJavaVMPtr); - } -*/ - orig_exit(code); }