新增函数,可以在某扩展加载后调用一段方法

This commit is contained in:
kuangthree 2023-11-28 22:57:28 +08:00
parent 71164321fe
commit 0c4645acc2
1 changed files with 13 additions and 0 deletions

View File

@ -40690,6 +40690,19 @@ new Promise(resolve=>{
return extensionName !== void 0 && _status.extensionLoaded.includes(extensionName);
},
runAfterExtensionLoaded(extensionName,runnable) {
if(game.hasExtensionLoaded(extensionName)){
runnable();
}else{
let eventName = `Noname.Init.Extension.${extensionName}.onLoad`;
let callback = ()=>{
lib.announce.unsubscribe(eventName,callback);
runnable();
};
lib.announce.subscribe(eventName,callback);
}
},
removeExtension:(extensionName,keepFile)=>{
const prefix=`extension_${extensionName}`;
Object.keys(lib.config).forEach(key=>{