Add Dev Command
All checks were successful
SteamWarCI Build successful

This commit is contained in:
2025-10-26 01:29:59 +02:00
parent fb2ef0cb86
commit 57148c3693

View File

@ -12,8 +12,11 @@ import com.github.ajalt.clikt.parameters.options.help
import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file import com.github.ajalt.clikt.parameters.types.file
import com.github.ajalt.clikt.parameters.types.long import com.github.ajalt.clikt.parameters.types.long
import com.github.ajalt.clikt.parameters.types.path
import com.sun.security.auth.module.UnixSystem import com.sun.security.auth.module.UnixSystem
import java.io.File import java.io.File
import kotlin.io.path.absolute
import kotlin.io.path.absolutePathString
const val LOG4J_CONFIG = """<?xml version="1.0" encoding="UTF-8"?> const val LOG4J_CONFIG = """<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util"> <Configuration status="WARN" packages="com.mojang.util">
@ -52,11 +55,11 @@ class DevCommand : CliktCommand("dev") {
if (System.getProperty("os.name").lowercase() == "windows" if (System.getProperty("os.name").lowercase() == "windows"
) 2050 else (UnixSystem().uid + 1010) ) 2050 else (UnixSystem().uid + 1010)
).help("Port for Server") ).help("Port for Server")
val world by option("--world", "-w").help("User World") val world by option("--world", "-w").path(canBeFile = false).help("User World")
val plugins by option("--plugins", "-p").help("Plugin Dir") val plugins by option("--plugins", "-p").path(true, canBeFile = false).help("Plugin Dir")
val profile by option().flag().help("Add Profiling Arguments") val profile by option().flag().help("Add Profiling Arguments")
val forceUpgrade by option().flag().help("Force Upgrade") val forceUpgrade by option().flag().help("Force Upgrade")
val jar by option().file().help("Jar File") val jar by option().file(true, canBeDir = false).help("Jar File")
val jvmArgs by argument().multiple() val jvmArgs by argument().multiple()
override val printHelpOnEmptyArgs = true override val printHelpOnEmptyArgs = true
@ -76,7 +79,7 @@ class DevCommand : CliktCommand("dev") {
} else { } else {
setLogConfig(args) setLogConfig(args)
val version = findVersion(server) ?: throw CliktError("Unknown Server Version") val version = findVersion(server) ?: throw CliktError("Unknown Server Version")
val worldFile = world?.let { File(workingDir, it) } ?: File(serverDir, "devtempworld") val worldFile = world?.let { it.absolute().toFile() } ?: File(serverDir, "devtempworld")
val jarFile = jar?.absolutePath ?: JARS[server]?.let { VERSIONS[it] } ?: VERSIONS[version] val jarFile = jar?.absolutePath ?: JARS[server]?.let { VERSIONS[it] } ?: VERSIONS[version]
?: throw CliktError("Unknown Server Version") ?: throw CliktError("Unknown Server Version")
@ -101,7 +104,7 @@ class DevCommand : CliktCommand("dev") {
"--level-name", worldFile.name, "--level-name", worldFile.name,
"--world-dir", workingDir.absolutePath, "--world-dir", workingDir.absolutePath,
"--nogui", "--nogui",
*(if (plugins != null) arrayOf("--plugins", plugins!!) else arrayOf()) *(if (plugins != null) arrayOf("--plugins", plugins!!.absolutePathString()) else arrayOf())
), serverDir ), serverDir
) )