aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt5
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt11
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
index 940a07b..211c18c 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
@@ -336,10 +336,10 @@ class PrimaryController {
}
prop == "difficulty" -> {
if (value == "Hardcore") {
- server.setProp("hardcode", "true")
+ server.setProp("hardcore", "true")
server.setProp(prop, "hard")
} else {
- server.setProp("hardcode", "false")
+ server.setProp("hardcore", "false")
server.setProp(prop, value.lowercase())
}
}
@@ -777,6 +777,7 @@ class PrimaryController {
buildButton.text = "Build Server"
}
statusBar.text = "Ready."
+ server.dir = dir
server.loadProps()
return result
}
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
index b591074..0c3a7d1 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
@@ -33,16 +33,23 @@ public class Server {
props.setProperty("level-seed", "")
props.setProperty("level-type", "minecraft:normal")
props.setProperty("motd", "A server for a dummy")
+ writeProps()
}
public fun loadProps(dir: String) {
- val ins = File(dir + File.separator + "server.properties").inputStream()
+ var ins = File(dir + File.separator + "server.properties").inputStream()
+ props.load(ins)
+ ins = File(dir + File.separator + "ServerCraft" + File.separator + "ServerCraft.properties").inputStream()
props.load(ins)
}
private fun writeProps() {
- val outs = File(dir + File.separator + "server.properties").outputStream()
+ var outs = File(dir + File.separator + "server.properties").outputStream()
props.store(outs, "Minecraft server properties\nCreated with ServerCraft: https://codeberg.org/brysonsteck/ServerCraft")
+ val temp = Properties()
+ outs = File(dir + File.separator + "ServerCraft" + File.separator + "ServerCraft.properties").outputStream()
+ temp.setProperty("jvm-ram", props.getProperty("jvm-ram"))
+ temp.store(outs, "ServerCraft settings backup\nSometimes, Minecraft will completely overwrite the server.properties file,\ncompletely destroying these app-specific settings. This file backs up these settings\njust in case. :)\nhttps://codeberg.org/brysonsteck/ServerCraft")
}
public fun getProp(prop: String): String {