diff --git a/injector.html b/injector.html index dfca69d..54ea6d8 100644 --- a/injector.html +++ b/injector.html @@ -46,6 +46,9 @@ patchedFile = patchedFile.replace("\r", "").replace("var main;\n(function() {", ModAPI.hooks._rippedData.push(data); /*/EaglerForge Client Patch/*/` ); + + patchedFile = patchedFile.replace(` id="game_frame">`, ` id="game_frame">\ - \ No newline at end of file diff --git a/postinit.js b/postinit.js new file mode 100644 index 0000000..1b5ff0b --- /dev/null +++ b/postinit.js @@ -0,0 +1,43 @@ +//EaglerForge post initialisation code. +ModAPI.hooks._classMap = {}; +ModAPI.hooks._rippedConstructorKeys = Object.keys(ModAPI.hooks._rippedConstructors); +ModAPI.hooks._rippedMethodKeys = Object.keys(ModAPI.hooks._rippedMethodTypeMap); +ModAPI.hooks._rippedData.forEach(block => { + block.forEach(item => { + if (typeof item === "function") { + var compiledName = item.name; + if (!item.$meta || typeof item.$meta.name !== "string") { + return; + } + var classId = item.$meta.name; + if (!ModAPI.hooks._classMap[classId]) { + ModAPI.hooks._classMap[classId] = { + "name": classId.split(".")[classId.split(".").length - 1], + "id": classId, + "binaryName": item.$meta.binaryName, + "constructors": [], + "methods": [], + "staticMethods": [], + "class": item, + "compiledName": compiledName + } + } + if (typeof item.$meta.superclass === "function" && item.$meta.superclass.$meta) { + ModAPI.hooks._classMap[classId].superclass = item.$meta.superclass.$meta.name; + } + if (item["$$constructor$$"]) { + //Class does not have any hand written constructors + //Eg: class MyClass {} + ModAPI.hooks._classMap[classId].constructors.push(item["$$constructor$$"]); + } else { + //Class has hand written constructors, we need to search in the stash + ModAPI.hooks._rippedConstructorKeys.forEach(constructor => { + if (constructor.startsWith(compiledName + "__init_") && !constructor.includes("$lambda$")) { + ModAPI.hooks._classMap[classId].constructors.push(ModAPI.hooks._rippedConstructors[constructor]); + } + }); + } + + } + }) +}); \ No newline at end of file