diff --git a/src/main/kotlin/Globals.kt b/src/main/kotlin/Globals.kt index 18d020c..40e9e4f 100644 --- a/src/main/kotlin/Globals.kt +++ b/src/main/kotlin/Globals.kt @@ -10,10 +10,10 @@ fun Component.placeAt(x: Int, y: Int, width: Int, height: Int){ fun launchClient() { println("Launching client now.") - var proc = Runtime.getRuntime().exec("java -jar " + Settings.SAVE_NAME, null, File(System.getProperty("user.home"))) + var proc = Runtime.getRuntime().exec("java -jar " + Settings.SAVE_NAME, null, File(Settings.SAVE_DIR)) if(proc.isAlive && SettingsWindow.closeLauncherOnLaunch.isToggled){ exitProcess(0) } else if(SettingsWindow.closeLauncherOnLaunch.isToggled) { MainWindow.loadingLabel.text = "Error starting the client." } -} \ No newline at end of file +} diff --git a/src/main/kotlin/Settings.kt b/src/main/kotlin/Settings.kt index 3751b1c..d6958ba 100644 --- a/src/main/kotlin/Settings.kt +++ b/src/main/kotlin/Settings.kt @@ -1,5 +1,9 @@ object Settings { - val SAVE_DIR = System.getProperty("user.home") + val os = System.getProperty("os.name").toLowerCase() + var SAVE_DIR = when(os.contains("nix") || os.contains("nux") || os.contains("aix")) { + true -> System.getProperty("user.home") + "/.local/share/2009scape" + false -> System.getProperty("user.home") + } val SAVE_NAME = "2009scape.jar" val DOWNLOAD_URL = "http://play.2009scape.org/2009scape.jar" val LAUNCHER_URL = "https://gitlab.com/2009scape/09launcher/-/jobs/artifacts/master/raw/build/libs/2009scape.jar?job=build" @@ -9,4 +13,4 @@ object Settings { field = value println(value) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/settingseditor/Json.kt b/src/main/kotlin/settingseditor/Json.kt index 7c5ee38..dc685a9 100644 --- a/src/main/kotlin/settingseditor/Json.kt +++ b/src/main/kotlin/settingseditor/Json.kt @@ -8,11 +8,24 @@ import java.io.FileWriter object Json { - val HOME = System.getProperty("user.home") + val os = System.getProperty("os.name").toLowerCase() + var HOME = when(os.contains("nix") || os.contains("nux") || os.contains("aix")) { + true -> System.getProperty("user.home") + "/.local/share/2009scape" + false -> System.getProperty("user.home") + } val CONF = HOME + File.separator + "config.json" + var data: JSONObject = JSONObject() + init { + val dir = File(HOME) + if (!dir.exists()) { + dir.mkdirs() + } + } + fun save(){ + val osName = System.getProperty("os.name").toLowerCase() val customization = data["customization"] as JSONObject val xpDrops = customization["xpdrops"] as JSONObject val slayer = customization["slayer"] as JSONObject