detach hook-calling to make prototype function able to run anytime.

This commit is contained in:
Rintim 2023-09-27 00:05:16 +08:00
parent 6aa4e18982
commit 08de74b1ab
1 changed files with 8 additions and 4 deletions

View File

@ -33426,13 +33426,15 @@
addNature:(nature,translation,config)=>{ addNature:(nature,translation,config)=>{
if(!nature) throw new TypeError(); if(!nature) throw new TypeError();
if(translation&&translation.length) lib.translate['nature_'+nature]=translation; if(translation&&translation.length) lib.translate['nature_'+nature]=translation;
lib.onload.add(()=>{ var hookCall=()=>{
for(const hook of lib.hooks.addNature){ for(const hook of lib.hooks.addNature){
if(hook!=null&&typeof hook=="function"){ if(hook!=null&&typeof hook=="function"){
hook(nature,translation,config); hook(nature,translation,config);
} }
} }
}) };
if ("onload" in lib) lib.onload.add(hookCall);
else hookCall();
return nature; return nature;
}, },
//设置卡牌信息/事件的属性 //设置卡牌信息/事件的属性
@ -33500,13 +33502,15 @@
lib.group.add(id); lib.group.add(id);
if(short)lib.translate[id] = short; if(short)lib.translate[id] = short;
if(name)lib.translate[`${id}2`] = name; if(name)lib.translate[`${id}2`] = name;
lib.onload.add(()=>{ var hookCall=()=>{
for(const hook of lib.hooks.addGroup){ for(const hook of lib.hooks.addGroup){
if(hook!=null&&typeof hook=="function"){ if(hook!=null&&typeof hook=="function"){
hook(id,short,name,config); hook(id,short,name,config);
} }
} }
}) };
if ("onload" in lib) lib.onload.add(hookCall);
else hookCall();
return id; return id;
}, },
//Yingbian //Yingbian