@@ -10,6 +10,8 @@ import me.scoretwo.fastscript.config.SettingConfig
1010import me.scoretwo.fastscript.api.script.ScriptManager
1111import me.scoretwo.fastscript.api.utils.ExecType
1212import me.scoretwo.fastscript.api.utils.ExecUtils
13+ import me.scoretwo.fastscript.api.utils.maven.MavenArtifact
14+ import me.scoretwo.fastscript.api.utils.process.ProcessResultType
1315import me.scoretwo.fastscript.command.commands.ScriptCommand
1416import me.scoretwo.fastscript.utils.Assist
1517import me.scoretwo.fastscript.utils.assist
@@ -25,6 +27,20 @@ class FastScript(val plugin: ScriptPlugin) {
2527
2628 fun setPlaceholder (player : GlobalPlayer , string : String ) = plugin.setPlaceholder(player, string)
2729
30+ private val libs = arrayOf(
31+ MavenArtifact (" org.openjdk.nashorn:nashorn-core:15.2" ),
32+ MavenArtifact (" org.ow2.asm:asm-commons:7.3.1" ),
33+ MavenArtifact (" org.ow2.asm:asm-analysis:7.3.1" ),
34+ MavenArtifact (" org.ow2.asm:asm:7.3.1" ),
35+ MavenArtifact (" org.ow2.asm:asm-util:7.3.1" ),
36+ MavenArtifact (" org.ow2.asm:asm-tree:7.3.1" ),
37+
38+ MavenArtifact (" org.scala-lang:scala-compiler:2.12.9" ),
39+ MavenArtifact (" org.scala-lang:scala-library:2.12.9" ),
40+ MavenArtifact (" org.scala-lang:scala-reflect:2.12.9" ),
41+ MavenArtifact (" org.scala-lang.modules:scala-xml_2.12:1.1.0" ),
42+ )
43+
2844 init {
2945 instance = this
3046 me.scoretwo.fastscript.plugin = plugin
@@ -51,9 +67,29 @@ class FastScript(val plugin: ScriptPlugin) {
5167 languages = LanguageManager ()
5268 plugin.server.console.sendMessage(FormatHeader .TREE , " Loaded config and language system.§8(${System .currentTimeMillis() - startTime} ms)" )
5369
54- ExecUtils .execPeriod(ExecType .Loaded , " configs " ) {
70+ ExecUtils .execPeriod(ExecType .Loaded , languages[ " EXEC-ID.CONFIGS " ] ) {
5571 reload(" config" )
5672 }
73+
74+ ExecUtils .execPeriod(ExecType .Loaded , languages[" EXEC-ID.LIBS" ]) {
75+ fun download (artifact : MavenArtifact ) {
76+ val start = System .currentTimeMillis()
77+ val processResult = artifact.download()
78+ if (processResult.type == ProcessResultType .FAILED ) {
79+ plugin.server.console.sendMessage(FormatHeader .ERROR , languages[" DOWNLOAD-LIBS-FAILED" ])
80+ throw Throwable (languages[" DOWNLOAD-LIBS-FAILED" ])
81+ }
82+ if (processResult.type == ProcessResultType .SUCCESS ) {
83+ plugin.server.console.sendMessage(FormatHeader .INFO , languages[" DOWNLOADED-LIB" ].setPlaceholder(mapOf (
84+ " lib_name" to " ${artifact.artifactId} -${artifact.version} .jar" ,
85+ " millisecond" to " ${System .currentTimeMillis() - start} "
86+ )))
87+ }
88+ }
89+ libs.forEach { download(it) }
90+ plugin.libs.forEach { download(it) }
91+ }
92+
5793 ExecUtils .execPeriod(ExecType .Initialized , " script manager" ) {
5894 scriptManager = ScriptManager ()
5995 }
@@ -98,6 +134,10 @@ class FastScript(val plugin: ScriptPlugin) {
98134 " script" -> {
99135 initInternalScripts()
100136 scriptManager.loadScripts()
137+ // Try to Fix Mohist and CatServer
138+ if (::commandNexus.isInitialized) {
139+ commandNexus = FSCommandNexus ()
140+ }
101141 commandNexus.findSubCommand(" script" )?.also { (it as ScriptCommand ).reload() }
102142 }
103143 " plugin" -> {
0 commit comments