diff options
Diffstat (limited to 'app/src/main/kotlin/xyz/brysonsteck/serverfordummies')
-rw-r--r-- | app/src/main/kotlin/xyz/brysonsteck/serverfordummies/App.kt | 2 | ||||
-rw-r--r-- | app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt | 48 | ||||
-rw-r--r-- | app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt (renamed from app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt) | 22 | ||||
-rw-r--r-- | app/src/main/kotlin/xyz/brysonsteck/serverfordummies/server/Download.kt (renamed from app/src/main/kotlin/xyz/brysonsteck/serverfordummies/Download.kt) | 2 |
4 files changed, 49 insertions, 25 deletions
diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/App.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/App.kt index 0a3cab9..3ff7c46 100644 --- a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/App.kt +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/App.kt @@ -15,7 +15,7 @@ class App : Application() { override fun start(stage: Stage) { var scene = Scene(loadFXML("primary"), 963.0, 713.0) - stage.icons.add(Image(this.javaClass.getResourceAsStream("app-256x256.png"))) + stage.icons.add(Image(this.javaClass.getResourceAsStream("app.png"))) stage.setResizable(false) stage.title = "Server For Dummies" stage.scene = scene diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt index 5f98c83..a0b7915 100644 --- a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt @@ -23,38 +23,46 @@ class InfoController { private fun openHyperlink(e: ActionEvent) { val link = e.source as Hyperlink link.isVisited = false - val split = link.id.split('_') + val split = link.id.split('_').toMutableList() + split.add("") + val os = System.getProperty("os.name").lowercase() val desktop = Desktop.getDesktop() - if (desktop.isSupported(Desktop.Action.BROWSE)) { - println("hi") - try { - when { - split[1].equals("email") -> { - println("email") - desktop.browse(URI("mailto:" + websites[split[0]])) + try { + when { + split[1].equals("email") -> { + if (!os.contains("linux")) { + desktop.browse(URI("mailto:" + emails[split[0]])) + } else { + Runtime.getRuntime().exec("xdg-open mailto:" + emails[split[0]]) } - split[1].equals("website") -> { - println("website") + } + split[1].equals("website") -> { + if (!os.contains("linux")) { desktop.browse(URI(websites[split[0]])) + } else { + Runtime.getRuntime().exec("xdg-open " + websites[split[0]]) } - split[0].equals("source") -> { - println("source") + } + split[0].equals("source") -> { + if (!os.contains("linux")) { desktop.browse(URI(source)) + } else { + Runtime.getRuntime().exec("xdg-open " + source) } - split[0].equals("license") -> { - println("license") + } + split[0].equals("license") -> { + println("license") + if (!os.contains("linux")) { desktop.browse(URI(license)) - } - else -> { - println("unknown") + } else { + Runtime.getRuntime().exec("xdg-open " + license) } } - } catch (e: Exception) { - println(e) } + } catch (e: Exception) { + println(e) } - println("done") } @FXML diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt index f5eab39..81a860e 100644 --- a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt @@ -1,4 +1,4 @@ -package xyz.brysonsteck.serverfordummies +package xyz.brysonsteck.serverfordummies.controllers import kotlinx.coroutines.* import kotlinx.coroutines.javafx.JavaFx @@ -52,8 +52,8 @@ import javafx.stage.Stage import javafx.event.EventHandler import org.rauschig.jarchivelib.* -import Download import xyz.brysonsteck.serverfordummies.server.Server +import xyz.brysonsteck.serverfordummies.server.Download import xyz.brysonsteck.serverfordummies.App class PrimaryController { @@ -218,7 +218,7 @@ class PrimaryController { private fun onInfo() { val stage = Stage() val scene = Scene(FXMLLoader(App().javaClass.getResource("info.fxml")).load(), 398.0, 358.0) - stage.icons.add(Image(App().javaClass.getResourceAsStream("app-256x256.png"))) + stage.icons.add(Image(App().javaClass.getResourceAsStream("app.png"))) stage.setResizable(false) stage.initModality(Modality.APPLICATION_MODAL); stage.title = "About ServerCraft" @@ -400,6 +400,10 @@ class PrimaryController { var line = br.readLine() while (line != null) { if (asyncResult) { + withContext(Dispatchers.JavaFx) { + statusBar.text = "Killing Minecraft server..." + startButton.isDisable = true + } proc.destroy() } println(line); @@ -420,6 +424,7 @@ class PrimaryController { parentPane.isDisable = false buildButton.isDisable = false defaultsButton.isDisable = false + startButton.isDisable = false startButton.text = "Start Server" started = false } @@ -430,6 +435,7 @@ class PrimaryController { var result = false val resources = App().javaClass.getResource("icons/warning.png") val dialog = Stage() + dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png"))) dialog.setResizable(false) dialog.initModality(Modality.APPLICATION_MODAL); dialog.title = directory @@ -467,12 +473,19 @@ class PrimaryController { eula.onMouseClicked = EventHandler<MouseEvent>() { val desktop = Desktop.getDesktop() if (desktop.isSupported(Desktop.Action.BROWSE)) { - println("made it!") + // most likely running on Windows or macOS try { desktop.browse(URI("https://account.mojang.com/documents/minecraft_eula")) } catch (e: Exception) { println(e) } + } else { + // assume running on linux + try { + Runtime.getRuntime().exec("xdg-open https://account.mojang.com/documents/minecraft_eula"); + } catch (e: Exception) { + println(e) + } } } ButtonBar.setButtonData(eula, ButtonBar.ButtonData.LEFT) @@ -491,6 +504,7 @@ class PrimaryController { var result = false val resources = App().javaClass.getResource("icons/$type.png") val dialog = Stage() + dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png"))) dialog.setResizable(false) dialog.initModality(Modality.APPLICATION_MODAL); dialog.title = directory diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/Download.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/server/Download.kt index b98b511..d7e5aed 100644 --- a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/Download.kt +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/server/Download.kt @@ -1,3 +1,5 @@ +package xyz.brysonsteck.serverfordummies.server + import java.io.*; import java.net.*; import java.util.*; |