1- package cf.wayzer
1+ package cf.wayzer.scriptAgent.mindustry
22
33import arc.ApplicationListener
44import arc.Core
5+ import arc.files.Fi
56import arc.util.CommandHandler
67import arc.util.Log
7- import cf.wayzer.ConfigExt.clientCommands
8- import cf.wayzer.ConfigExt.mainScript
9- import cf.wayzer.ConfigExt.serverCommands
10- import cf.wayzer.ConfigExt.version
118import cf.wayzer.scriptAgent.*
129import cf.wayzer.scriptAgent.define.LoaderApi
1310import kotlinx.coroutines.runBlocking
1411import mindustry.Vars
15- import mindustry.plugin .Plugin
12+ import mindustry.mod .Plugin
1613import java.io.File
1714
1815@OptIn(LoaderApi ::class )
19- class ScriptAgent4Mindustry : Plugin () {
20- init {
21- if (System .getProperty(" java.util.logging.SimpleFormatter.format" ) == null )
22- System .setProperty(
23- " java.util.logging.SimpleFormatter.format" ,
24- " [%1\$ tF | %1\$ tT | %4\$ s] [%3\$ s] %5\$ s%6\$ s%n"
25- )
26- ScriptAgent .load()
27- }
16+ class Main (private val loader : Plugin ) : Plugin() {
17+ override fun getConfig (): Fi = loader.config
2818
2919 override fun registerClientCommands (handler : CommandHandler ) {
30- Config .clientCommands = handler
20+ // after init() is too late
21+ // Config.clientCommands = handler
3122 }
3223
3324 override fun registerServerCommands (handler : CommandHandler ) {
@@ -36,13 +27,17 @@ class ScriptAgent4Mindustry : Plugin() {
3627
3728 override fun init () {
3829 val defaultMain = " main/bootStrap"
39- val version = Vars .mods.getMod(javaClass).meta.version
30+ val version = Vars .mods.getMod(loader. javaClass).meta.version
4031 val main = System .getenv(" SAMain" ) ? : defaultMain
4132 Log .info(" SAMain=$main " )
4233
4334 Config .version = version
4435 Config .mainScript = main
4536 Config .rootDir = Vars .dataDirectory.child(" scripts" ).file()
37+ Config .clientCommands = Vars .netServer?.clientCommands ? : CommandHandler (" /" )
38+ if (! Vars .headless) {
39+ Config .serverCommands = CommandHandler (" " )
40+ }
4641
4742 tryExtract(" /res/$defaultMain .kts" , Config .rootDir.resolve(" $defaultMain .kts" ))
4843 tryExtract(" /res/$defaultMain .ktc" , Config .cacheFile(defaultMain, false ))
0 commit comments