aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt4
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt23
3 files changed, 23 insertions, 6 deletions
diff --git a/build.gradle b/build.gradle
index 379e417..adb9fba 100644
--- a/build.gradle
+++ b/build.gradle
@@ -68,8 +68,6 @@ distTar {
}
jar {
- // archiveFileName = 'ServerCraft.jar'
-
manifest {
attributes 'Main-Class': application.mainClass
}
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
index 211c18c..2282d13 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/controllers/PrimaryController.kt
@@ -765,8 +765,10 @@ class PrimaryController {
statusBar.text = "Ready."
if (result) {
startButton.isDisable = false
+ File(directory + "ServerCraft").mkdir()
+ buildButton.text = "Build Server"
+ server.loadProps(dir, convert=true)
}
- server.loadProps(dir)
return result
} else {
// assume clean directory
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
index 0c3a7d1..141b477 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Server.kt
@@ -2,6 +2,7 @@ package xyz.brysonsteck.ServerCraft.server
import java.io.File
import java.io.InputStream
+import java.io.FileNotFoundException
import java.util.Properties
public class Server {
@@ -36,11 +37,27 @@ public class Server {
writeProps()
}
- public fun loadProps(dir: String) {
+ public fun loadProps(dir: String, convert: Boolean = false) {
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)
+ try {
+ ins = File(dir + File.separator + "ServerCraft" + File.separator + "ServerCraft.properties").inputStream()
+ props.load(ins)
+ } catch (e: FileNotFoundException) {
+ if (convert) {
+ // create the file in question, as this is an external server being converted into a ServerCraft managed one
+ File(dir + File.separator + "ServerCraft" + File.separator + "ServerCraft.properties").createNewFile()
+ // also apply app-specific properties
+ props.setProperty("jvm-ram", 1024.toString())
+ // then write to file
+ val temp = Properties()
+ val 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")
+ } else {
+ println(e)
+ }
+ }
}
private fun writeProps() {