Source:
private void cleanupStart(Stage stage) { logger.info("Starting cleanup tool because --cleanup argument was specified"); final OperatingSystem os = OperatingSystem.getOS(); if (os == OperatingSystem.UNKNOWN) { logger.error("The operating system is not supported! '{}' '{}' '{}'", System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version")); Platform.exit(); System.exit(1); } try { final File launcherDirectory = DirectoryUtils.getApplicationDirectory(os, DirectoryUtils.LAUNCHER_APPLICATION_DIR_NAME); final BaseLauncherSettings launcherSettings = new BaseLauncherSettings(launcherDirectory); launcherSettings.load(); launcherSettings.init(); if (!CleanupUtils.getDirectory(launcherSettings, CleanupUtils.Directory.LAUNCHER).exists()) { logger.info("Launcher directory does not exist, no cleanup is necessary"); Platform.exit(); System.exit(0); } stage.setResizable(false); FXMLLoader fxmlLoader; Parent root; try { fxmlLoader = BundleUtils.getFXMLLoader("cleanup"); root = fxmlLoader.load(); } catch (IOException e) { fxmlLoader = BundleUtils.getFXMLLoader("cleanup"); fxmlLoader.setResources(ResourceBundle.getBundle("org.terasology.launcher.bundle.LabelsBundle", Languages.DEFAULT_LOCALE)); root = fxmlLoader.load(); } final CleanupController cleanupController = fxmlLoader.getController(); cleanupController.initialize(launcherSettings); Scene scene = new Scene(root); decorateStage(stage); stage.setScene(scene); stage.setOnHiding((final WindowEvent event) -> { Platform.exit(); System.exit(1); }); stage.show(); } catch (IOException e) { logger.error("IOException in cleanupStart: ", e.getMessage()); } }

Target:
private void cleanupStart(Stage stage) { logger.info("Starting in cleanup mode"); final OperatingSystem os = OperatingSystem.getOS(); if (os == OperatingSystem.UNKNOWN) { logger.error("The operating system is not supported! '{}' '{}' '{}'", System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version")); Platform.exit(); System.exit(1); } try { final File launcherDirectory = DirectoryUtils.getApplicationDirectory(os, DirectoryUtils.LAUNCHER_APPLICATION_DIR_NAME); final BaseLauncherSettings launcherSettings = new BaseLauncherSettings(launcherDirectory); launcherSettings.load(); launcherSettings.init(); if (!CleanupUtils.getDirectory(launcherSettings, CleanupUtils.Directory.LAUNCHER).exists()) { logger.info("Launcher directory does not exist, no cleanup is necessary"); Platform.exit(); System.exit(0); } stage.setResizable(false); FXMLLoader fxmlLoader; Parent root; try { fxmlLoader = BundleUtils.getFXMLLoader("cleanup"); root = fxmlLoader.load(); } catch (IOException e) { fxmlLoader = BundleUtils.getFXMLLoader("cleanup"); fxmlLoader.setResources(ResourceBundle.getBundle("org.terasology.launcher.bundle.LabelsBundle", Languages.DEFAULT_LOCALE)); root = fxmlLoader.load(); } final CleanupController cleanupController = fxmlLoader.getController(); cleanupController.initialize(launcherSettings); Scene scene = new Scene(root); decorateStage(stage); stage.setScene(scene); stage.setOnHiding((final WindowEvent event) -> { Platform.exit(); System.exit(1); }); stage.show(); } catch (IOException e) { logger.error("IOException in cleanupStart: ", e.getMessage()); } }