Skip to content

Commit e966647

Browse files
committed
🐛(coreLib/commands/control) sa reload 可能enable原本不启用的脚本
1 parent 2e28a76 commit e966647

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

scripts/coreLibrary/commands/control.kts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ command("load", "(重新)加载一个脚本或者模块".with(), commands = Comm
7272
runIgnoreCancel(!async) {
7373
ScriptManager.transaction {
7474
add(script)
75-
//因为其他原因本来就保持loaded
76-
if (script.run { failReason == null && scriptState.loaded && !scriptState.enabled })
77-
noEnable = true
75+
76+
addChildren(false) { it.scriptState.enabled }
77+
val oldEnabled = filter { it.enabled }
78+
disable()
79+
7880
unload(addAllAffect = true)
7981
load()
80-
if (!noEnable) enable()
82+
83+
//recover enabled
84+
clear()
85+
addAll(oldEnabled)
86+
enable()
8187
}
8288
script.failReason?.let {
8389
reply("[red]加载失败({state}): {reason}".with("state" to script.scriptState, "reason" to it))

0 commit comments

Comments
 (0)