Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2022-11-04 18:07:42 +01:00
parent e047444567
commit a49f337559
1 changed files with 24 additions and 5 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB * @name BDFDB
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.9.5 * @version 2.9.6
* @description Required Library for DevilBro's Plugins * @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -2186,10 +2186,29 @@ module.exports = (_ => {
if (!PluginStores.modulePatches[patchType]) PluginStores.modulePatches[patchType] = {}; if (!PluginStores.modulePatches[patchType]) PluginStores.modulePatches[patchType] = {};
for (let type of plugin.modulePatches[patchType]) { for (let type of plugin.modulePatches[patchType]) {
if (InternalData.PatchModules[type]) { if (InternalData.PatchModules[type]) {
if (!PluginStores.modulePatches[patchType][type]) PluginStores.modulePatches[patchType][type] = []; let found = false;
if (!PluginStores.modulePatches[patchType][type][patchPriority]) PluginStores.modulePatches[patchType][type][patchPriority] = []; if (patchType == "before" || patchType == "after") {
PluginStores.modulePatches[patchType][type][patchPriority].push(plugin); let exports = (BDFDB.ModuleUtils.find(m => Internal.isCorrectModule(m, type) && m, {defaultExport: false}) || {}).exports;
if (PluginStores.modulePatches[patchType][type][patchPriority].length > 1) PluginStores.modulePatches[patchType][type][patchPriority] = BDFDB.ArrayUtils.keySort(PluginStores.modulePatches[patchType][type][patchPriority], "name"); if (exports && !exports.default) for (let key of Object.keys(exports)) if (typeof exports[key] == "function" && !(exports[key].prototype && exports[key].prototype.render) && Internal.isCorrectModule(exports[key], type, false) && exports[key].toString().length < 50000) {
found = true;
BDFDB.PatchUtils.patch(plugin, exports, key, {[patchType]: e => Internal.initiatePatch(plugin, type, {
arguments: e.methodArguments,
instance: e.instance,
returnvalue: e.returnValue,
component: exports[key],
name: type,
methodname: "render",
patchtypes: [patchType]
})}, {name: type});
break;
}
}
if (!found) {
if (!PluginStores.modulePatches[patchType][type]) PluginStores.modulePatches[patchType][type] = [];
if (!PluginStores.modulePatches[patchType][type][patchPriority]) PluginStores.modulePatches[patchType][type][patchPriority] = [];
PluginStores.modulePatches[patchType][type][patchPriority].push(plugin);
if (PluginStores.modulePatches[patchType][type][patchPriority].length > 1) PluginStores.modulePatches[patchType][type][patchPriority] = BDFDB.ArrayUtils.keySort(PluginStores.modulePatches[patchType][type][patchPriority], "name");
}
} }
else BDFDB.LogUtils.warn(`[${type}] not found in PatchModules InternalData`, plugin); else BDFDB.LogUtils.warn(`[${type}] not found in PatchModules InternalData`, plugin);
} }