fixed jvm settings being overwritten, hardcore error
This commit is contained in:
parent
e57a3d6864
commit
01f6beb513
2 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue