diff --git a/injector.html b/injector.html
index 24995b2..4e0a935 100644
--- a/injector.html
+++ b/injector.html
@@ -269,7 +269,7 @@ var main;(function(){`
}
);
const extractInstanceMethodRegex =
- /^[\t ]*function \S+?_\S+?_\S+?\(/gm; // /^[\t ]*function \S+?_\S+?_\S+?\(\$this/gm
+ /^[\t ]*function \S+?_\S+?_\S+?\((\$this)?/gm; // /^[\t ]*function \S+?_\S+?_\S+?\(\$this/gm
const extractInstanceMethodFullNameRegex = /function (\S*?)\(/gm; // /function (\S*?)\(\$this/gm
patchedFile = patchedFile.replaceAll(
extractInstanceMethodRegex,
@@ -288,8 +288,8 @@ var main;(function(){`
return ModAPI.hooks.methods[\`${fullName}\`].apply(this, args);
}
ModAPI.hooks._rippedMethodTypeMap[\`${fullName}\`] = \`${
- match.includes("($this")
- ? "instance" //Todo: fix static/instance detection
+ match.endsWith("($this")
+ ? "instance"
: "static"
}\`;
ModAPI.hooks.methods[\`${fullName}\`]=` +
@@ -714,6 +714,28 @@ var main;(function(){`
}
return sendChatMessage.apply(this, [$this, ModAPI.util.str(data.message) || $message]);
}
+
+ ModAPI.events.newEvent("tick");
+ const serverTickMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.server.MinecraftServer", "tick");
+ const serverTickMethod = ModAPI.hooks.methods[serverTickMethodName];
+ ModAPI.hooks.methods[serverTickMethodName] = function ($this) {
+ var data = { preventDefault: false }
+ ModAPI.events.callEvent("tick", data);
+ if (data.preventDefault) {
+ return;
+ }
+ return serverTickMethod.apply(this, [$this]);
+ }
+
+ ModAPI.events.newEvent("serverstart");
+ const serverStartMethodName = ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.sp.server.EaglerMinecraftServer", "startServer");
+ const serverStartMethod = ModAPI.hooks.methods[serverStartMethodName];
+ ModAPI.hooks.methods[serverStartMethodName] = function ($this) {
+ var x = serverStartMethod.apply(this, [$this]);
+ ModAPI.server = ModAPI.serverInstance = new Proxy($this, ModAPI.util.TeaVM_to_Recursive_BaseData_ProxyConf);
+ ModAPI.events.callEvent("serverstart", {});
+ return x;
+ }
})();`;
diff --git a/postinit.js b/postinit.js
index d24241d..084e32b 100644
--- a/postinit.js
+++ b/postinit.js
@@ -350,4 +350,26 @@
}
return sendChatMessage.apply(this, [$this, ModAPI.util.str(data.message) || $message]);
}
+
+ ModAPI.events.newEvent("tick");
+ const serverTickMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.server.MinecraftServer", "tick");
+ const serverTickMethod = ModAPI.hooks.methods[serverTickMethodName];
+ ModAPI.hooks.methods[serverTickMethodName] = function ($this) {
+ var data = { preventDefault: false }
+ ModAPI.events.callEvent("tick", data);
+ if (data.preventDefault) {
+ return;
+ }
+ return serverTickMethod.apply(this, [$this]);
+ }
+
+ ModAPI.events.newEvent("serverstart");
+ const serverStartMethodName = ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.sp.server.EaglerMinecraftServer", "startServer");
+ const serverStartMethod = ModAPI.hooks.methods[serverStartMethodName];
+ ModAPI.hooks.methods[serverStartMethodName] = function ($this) {
+ var x = serverStartMethod.apply(this, [$this]);
+ ModAPI.server = ModAPI.serverInstance = new Proxy($this, ModAPI.util.TeaVM_to_Recursive_BaseData_ProxyConf);
+ ModAPI.events.callEvent("serverstart", {});
+ return x;
+ }
})();
\ No newline at end of file