Merge pull request #684 from universe-st/PR-Branch

新增函数,可以在某扩展加载后调用一段方法
This commit is contained in:
Spmario233 2023-11-28 23:56:06 +08:00 committed by GitHub
commit ca5fa929c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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=>{