From 57ff40491bc452fbbae4ede3f36c2f605f277b86 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 7 Feb 2023 03:01:28 +0100 Subject: chore: minor documentation improvements --- src/main/java/ftbsc/lll/IInjector.java | 50 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/main/java/ftbsc/lll') diff --git a/src/main/java/ftbsc/lll/IInjector.java b/src/main/java/ftbsc/lll/IInjector.java index d0c28f0..df4ae3a 100644 --- a/src/main/java/ftbsc/lll/IInjector.java +++ b/src/main/java/ftbsc/lll/IInjector.java @@ -3,6 +3,12 @@ package ftbsc.lll; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; +/** + * Patch classes should implement this interface and be declared as services in + * the META-INF/services folder (or through modules in Java 9+, but only Java 8 + * is officially supported). + */ + public interface IInjector { /** @@ -11,46 +17,46 @@ public interface IInjector { String name(); /** - * @return reason for patching for this injector, for loggin + * @return reason for this patch, for logging */ default String reason() { return ""; } /** * This is used by the Launch Plugin to identify which classes should be - * altered, and on which classes this injector should operate. - * - * Class name should be dot-separated, for example "net.minecraft.client.Minecraft" - * - * @return target class to operate onto + * altered, and on which classes should this injector operate. + * Class name should be dot-separated, for example "net.minecraft.client.Minecraft". + * @return class to transform */ String targetClass(); /** - * This is used by the Launch Plugin to identify which methods to provide - * to this injector for patching. It should return the Searge name of wanted function. - * example: "func_71407_l", which is "tick()" on "Minecraft" class in 1.16.5 + * This is used by the Launch Plugin to identify the method to transform within + * the class. It should return the Searge name of target. + * Example: "func_71407_l", which is "tick()" on "Minecraft" class in 1.16.5 * - * @return target method name to operate onto + * @return method to transform */ String methodName(); /** - * This is used by the Launch Plugin to identify which methods to provide - * to this injector for patching. It should return the method descriptor, with - * parameters and return types. example: "()V" for void parameters and return. - * - * TODO better example... - * - * @return target method name to operate onto + * This should return the target method's descriptor. + * Methods in Java may have the same name but different parameters: a descriptor + * compiles that information, as well as the return type, in as little space as + * possible. + * Examples: + * (IF)V - returns void, takes in int and float + * (Ljava/lang/Object;)I - returns int, takes in a java.lang.Object + * (ILjava/lang/String;)[I - returns int[], takes in an int and a String + * See https://asm.ow2.io/asm4-guide.pdf for a more detailed explanation. + * @return descriptor of method to target. */ String methodDesc(); /** - * Once the Launch Plugin has identified classes and methods for injectors, - * this method will be called providing the correct class and method nodes for patching. - * - * @param clazz class node which is being patched - * @param method main method node of requested function for patching + * This method will be called once the Launch Plugin has identified the right class and + * method to patch. Override this for the actual patching. + * @param clazz class node currently being patched + * @param method node of method currently being patched */ void inject(ClassNode clazz, MethodNode method); } -- cgit v1.2.3-56-ga3b1