turns out it just doesnt work on linux, reverting and organizing

This commit is contained in:
Bryson Steck 2023-05-14 13:37:55 -06:00
parent efd5388d33
commit 8fbd006b49
8 changed files with 59 additions and 35 deletions

View file

@ -15,7 +15,7 @@ class App : Application() {
override fun start(stage: Stage) { override fun start(stage: Stage) {
var scene = Scene(loadFXML("primary"), 963.0, 713.0) 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.setResizable(false)
stage.title = "Server For Dummies" stage.title = "Server For Dummies"
stage.scene = scene stage.scene = scene

View file

@ -23,39 +23,47 @@ class InfoController {
private fun openHyperlink(e: ActionEvent) { private fun openHyperlink(e: ActionEvent) {
val link = e.source as Hyperlink val link = e.source as Hyperlink
link.isVisited = false 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() val desktop = Desktop.getDesktop()
if (desktop.isSupported(Desktop.Action.BROWSE)) {
println("hi")
try { try {
when { when {
split[1].equals("email") -> { split[1].equals("email") -> {
println("email") if (!os.contains("linux")) {
desktop.browse(URI("mailto:" + websites[split[0]])) desktop.browse(URI("mailto:" + emails[split[0]]))
} else {
Runtime.getRuntime().exec("xdg-open mailto:" + emails[split[0]])
}
} }
split[1].equals("website") -> { split[1].equals("website") -> {
println("website") if (!os.contains("linux")) {
desktop.browse(URI(websites[split[0]])) desktop.browse(URI(websites[split[0]]))
} else {
Runtime.getRuntime().exec("xdg-open " + websites[split[0]])
}
} }
split[0].equals("source") -> { split[0].equals("source") -> {
println("source") if (!os.contains("linux")) {
desktop.browse(URI(source)) desktop.browse(URI(source))
} else {
Runtime.getRuntime().exec("xdg-open " + source)
}
} }
split[0].equals("license") -> { split[0].equals("license") -> {
println("license") println("license")
if (!os.contains("linux")) {
desktop.browse(URI(license)) desktop.browse(URI(license))
} else {
Runtime.getRuntime().exec("xdg-open " + license)
} }
else -> {
println("unknown")
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
} }
} }
println("done")
}
@FXML @FXML
private fun closeInfo(e: ActionEvent) { private fun closeInfo(e: ActionEvent) {

View file

@ -1,4 +1,4 @@
package xyz.brysonsteck.serverfordummies package xyz.brysonsteck.serverfordummies.controllers
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.javafx.JavaFx import kotlinx.coroutines.javafx.JavaFx
@ -52,8 +52,8 @@ import javafx.stage.Stage
import javafx.event.EventHandler import javafx.event.EventHandler
import org.rauschig.jarchivelib.* import org.rauschig.jarchivelib.*
import Download
import xyz.brysonsteck.serverfordummies.server.Server import xyz.brysonsteck.serverfordummies.server.Server
import xyz.brysonsteck.serverfordummies.server.Download
import xyz.brysonsteck.serverfordummies.App import xyz.brysonsteck.serverfordummies.App
class PrimaryController { class PrimaryController {
@ -218,7 +218,7 @@ class PrimaryController {
private fun onInfo() { private fun onInfo() {
val stage = Stage() val stage = Stage()
val scene = Scene(FXMLLoader(App().javaClass.getResource("info.fxml")).load(), 398.0, 358.0) 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.setResizable(false)
stage.initModality(Modality.APPLICATION_MODAL); stage.initModality(Modality.APPLICATION_MODAL);
stage.title = "About ServerCraft" stage.title = "About ServerCraft"
@ -400,6 +400,10 @@ class PrimaryController {
var line = br.readLine() var line = br.readLine()
while (line != null) { while (line != null) {
if (asyncResult) { if (asyncResult) {
withContext(Dispatchers.JavaFx) {
statusBar.text = "Killing Minecraft server..."
startButton.isDisable = true
}
proc.destroy() proc.destroy()
} }
println(line); println(line);
@ -420,6 +424,7 @@ class PrimaryController {
parentPane.isDisable = false parentPane.isDisable = false
buildButton.isDisable = false buildButton.isDisable = false
defaultsButton.isDisable = false defaultsButton.isDisable = false
startButton.isDisable = false
startButton.text = "Start Server" startButton.text = "Start Server"
started = false started = false
} }
@ -430,6 +435,7 @@ class PrimaryController {
var result = false var result = false
val resources = App().javaClass.getResource("icons/warning.png") val resources = App().javaClass.getResource("icons/warning.png")
val dialog = Stage() val dialog = Stage()
dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png")))
dialog.setResizable(false) dialog.setResizable(false)
dialog.initModality(Modality.APPLICATION_MODAL); dialog.initModality(Modality.APPLICATION_MODAL);
dialog.title = directory dialog.title = directory
@ -467,12 +473,19 @@ class PrimaryController {
eula.onMouseClicked = EventHandler<MouseEvent>() { eula.onMouseClicked = EventHandler<MouseEvent>() {
val desktop = Desktop.getDesktop() val desktop = Desktop.getDesktop()
if (desktop.isSupported(Desktop.Action.BROWSE)) { if (desktop.isSupported(Desktop.Action.BROWSE)) {
println("made it!") // most likely running on Windows or macOS
try { try {
desktop.browse(URI("https://account.mojang.com/documents/minecraft_eula")) desktop.browse(URI("https://account.mojang.com/documents/minecraft_eula"))
} catch (e: Exception) { } catch (e: Exception) {
println(e) 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) ButtonBar.setButtonData(eula, ButtonBar.ButtonData.LEFT)
@ -491,6 +504,7 @@ class PrimaryController {
var result = false var result = false
val resources = App().javaClass.getResource("icons/$type.png") val resources = App().javaClass.getResource("icons/$type.png")
val dialog = Stage() val dialog = Stage()
dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png")))
dialog.setResizable(false) dialog.setResizable(false)
dialog.initModality(Modality.APPLICATION_MODAL); dialog.initModality(Modality.APPLICATION_MODAL);
dialog.title = directory dialog.title = directory

View file

@ -1,3 +1,5 @@
package xyz.brysonsteck.serverfordummies.server
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View file

@ -48,8 +48,8 @@
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" /> <Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
</padding> </padding>
</Label> </Label>
<Hyperlink fx:id="license" layoutX="127.0" layoutY="101.0" onAction="#openHyperlink" text="License" /> <Hyperlink fx:id="license" layoutX="127.0" layoutY="110.0" onAction="#openHyperlink" text="License" />
<Hyperlink fx:id="source" layoutX="189.0" layoutY="101.0" onAction="#openHyperlink" text="Source Code" /> <Hyperlink fx:id="source" layoutX="189.0" layoutY="110.0" onAction="#openHyperlink" text="Source Code" />
</children> </children>
<padding> <padding>
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" /> <Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
@ -61,7 +61,7 @@
<content> <content>
<Pane prefHeight="200.0" prefWidth="200.0"> <Pane prefHeight="200.0" prefWidth="200.0">
<children> <children>
<Label layoutX="107.0" layoutY="101.0" text="Want to join the list? Contribute!" textAlignment="CENTER" /> <Label layoutX="78.0" layoutY="109.0" text="Want to join the list? Contribute with a PR!" textAlignment="CENTER" />
<VBox> <VBox>
<children> <children>
<Label text="Bryson Steck" VBox.vgrow="ALWAYS"> <Label text="Bryson Steck" VBox.vgrow="ALWAYS">

View file

@ -20,7 +20,7 @@
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<Pane fx:id="primary" maxHeight="713.0" maxWidth="963.0" minHeight="713.0" minWidth="963.0" prefHeight="713.0" prefWidth="963.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="xyz.brysonsteck.serverfordummies.PrimaryController"> <Pane fx:id="primary" maxHeight="713.0" maxWidth="963.0" minHeight="713.0" minWidth="963.0" prefHeight="713.0" prefWidth="963.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="xyz.brysonsteck.serverfordummies.controllers.PrimaryController">
<children> <children>
<HBox fx:id="directoryPane" prefHeight="39.0" prefWidth="963.0"> <HBox fx:id="directoryPane" prefHeight="39.0" prefWidth="963.0">
<children> <children>