aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2023-05-24 00:16:49 -0600
committerBryson Steck <brysonsteck@protonmail.com>2023-05-24 00:16:49 -0600
commit01f6beb5139d98b29a13bfe389e59bb36c9861a3 (patch)
tree51764d24e43fba7b1ffc6475f97416384d2ccc8b
parente57a3d6864287c30bb8dfc6f5afdb240f379fbbc (diff)
downloadServerCraft-01f6beb5139d98b29a13bfe389e59bb36c9861a3.tar
ServerCraft-01f6beb5139d98b29a13bfe389e59bb36c9861a3.tar.gz
ServerCraft-01f6beb5139d98b29a13bfe389e59bb36c9861a3.tar.bz2
fixed jvm settings being overwritten, hardcore error
-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 {