11package bootStrap
22
3- import cf.wayzer.scriptAgent.impl.LoaderBridgeHost
3+ import cf.wayzer.scriptAgent.events.ScriptStateChangeEvent
44import cf.wayzer.scriptAgent.util.CASScriptPacker
55import cf.wayzer.scriptAgent.util.DependencyManager
66import cf.wayzer.scriptAgent.util.maven.Dependency
@@ -26,10 +26,24 @@ suspend fun compileOnlyLoad(script: ScriptInfo) {
2626 script.failReason = " 编译失败: $msg "
2727 return
2828 }
29+ try {
30+ compiled.loadLibraries()
31+ } catch (e: Exception ) {
32+ script.failReason = " 依赖下载失败:$e "
33+ return
34+ }
2935 script.compiledScript = compiled
3036 script.stateUpdateForce(ScriptState .Loaded ).join()
3137}
3238
39+ // Replaced with compileOnlyLoad
40+ listenTo<ScriptStateChangeEvent .Cancellable > {
41+ if (next == ScriptState .Loading ) {
42+ cancelled = true
43+ compileOnlyLoad(script)
44+ }
45+ }
46+
3347onEnable {
3448 if (id != Config .mainScript)
3549 return @onEnable ScriptManager .disableScript(this , " 仅可通过SAMAIN启用" )
@@ -44,10 +58,7 @@ onEnable {
4458 else
4559 Config .args.forEach { add(it) }
4660
47- LoaderBridgeHost .withScriptLoader {
48- forEach { compileOnlyLoad(it) }
49- }
50-
61+ load()
5162 }
5263 val fail = ScriptRegistry .allScripts { it.failReason != null }
5364 println (" 共加载${ScriptRegistry .allScripts { it.scriptState != ScriptState .Found }.size} 个脚本,失败${fail.size} 个" )
0 commit comments