From a49f3375591d029c88c627efc7586ca7b51b935d Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 4 Nov 2022 18:07:42 +0100 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 3bc870ab11..21c47ab1ce 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -2,7 +2,7 @@ * @name BDFDB * @author DevilBro * @authorId 278543574059057154 - * @version 2.9.5 + * @version 2.9.6 * @description Required Library for DevilBro's Plugins * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -2186,10 +2186,29 @@ module.exports = (_ => { if (!PluginStores.modulePatches[patchType]) PluginStores.modulePatches[patchType] = {}; for (let type of plugin.modulePatches[patchType]) { if (InternalData.PatchModules[type]) { - 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"); + let found = false; + if (patchType == "before" || patchType == "after") { + let exports = (BDFDB.ModuleUtils.find(m => Internal.isCorrectModule(m, type) && m, {defaultExport: false}) || {}).exports; + 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); }