sync
This commit is contained in:
@@ -37,9 +37,12 @@ object ProtocolListener : Listener {
|
||||
val subServer = SubServer(serverInfo.uid, packet.type, serverInfo.server!!.split(":")[1].toInt())
|
||||
serverCache[serverInfo.uid] = subServer
|
||||
pluginScope.launch {
|
||||
subServer.initServer()
|
||||
subServer.startServer()
|
||||
NetClient.sendPacket(PPacketServerStarted(serverInfo))
|
||||
try {
|
||||
subServer.initServer()
|
||||
subServer.startServer()
|
||||
} catch (e: Exception) {
|
||||
NetClient.sendPacket(PPacketServerStarted())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.maxmc.msm.child.misc
|
||||
|
||||
import cc.maxmc.msm.child.MultiServerMan
|
||||
import cc.maxmc.msm.child.settings.Settings
|
||||
import cc.maxmc.msm.child.utils.ScriptRunner
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -27,7 +28,7 @@ class SubServer(
|
||||
}
|
||||
|
||||
suspend fun startServer() = suspendCoroutine {
|
||||
runner.launch(port.toString())
|
||||
runner.launch(Settings.Patterns.arguments(type).joinToString(" ").replace("\${port}", port.toString()))
|
||||
runner.onOutput("For help, type \"help\" or \"?\"") {
|
||||
it.resume(Unit)
|
||||
}
|
||||
|
||||
@@ -17,4 +17,11 @@ object Settings {
|
||||
val port: Int
|
||||
get() = config.getInt("parent.port", 23333)
|
||||
}
|
||||
|
||||
object Patterns {
|
||||
fun arguments(type: String): List<String> {
|
||||
if (!config.contains("patterns.$type.args")) throw IllegalArgumentException("服务端样板 $type 的配置不存在,请检查settings.yml")
|
||||
return config.getStringList("patterns.$type.args")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user