aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/processor/annotations
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-02-26 20:16:48 +0100
committer zaaarf <zaaarf@proton.me>2023-02-26 20:16:48 +0100
commit96b2bc553664892d476e0ca35a919eb20c7d1cb2 (patch)
treebbfaf86da6af6bbdc47fa5b8a27d0395e3631c13 /src/main/java/ftbsc/lll/processor/annotations
parenteca2d1f312acd22a3515a377663686b23d9e234b (diff)
chore: added proper documentation, cleaned up build.gradle, added exceptions
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/annotations')
-rw-r--r--src/main/java/ftbsc/lll/processor/annotations/Injector.java15
-rw-r--r--src/main/java/ftbsc/lll/processor/annotations/Patch.java17
-rw-r--r--src/main/java/ftbsc/lll/processor/annotations/Target.java9
3 files changed, 37 insertions, 4 deletions
diff --git a/src/main/java/ftbsc/lll/processor/annotations/Injector.java b/src/main/java/ftbsc/lll/processor/annotations/Injector.java
index 6184610..32c91c3 100644
--- a/src/main/java/ftbsc/lll/processor/annotations/Injector.java
+++ b/src/main/java/ftbsc/lll/processor/annotations/Injector.java
@@ -3,8 +3,19 @@ package ftbsc.lll.processor.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.MethodNode;
+
+/**
+ * Marks a method as the injector method for purposes of generation.
+ * The method itself should be {@code public static}, and take in a {@link ClassNode}
+ * and a {@link MethodNode} as parameters. It will be discarded otherwise.
+ * It will also be discarded unless the containing class is not annotated with {@link Patch}
+ * and no other method within the class is annotated with {@link Target}.
+ * @see Patch
+ * @see Target
+ */
@Retention(RetentionPolicy.SOURCE)
-@Target(ElementType.METHOD)
+@java.lang.annotation.Target(ElementType.METHOD)
public @interface Injector {}
diff --git a/src/main/java/ftbsc/lll/processor/annotations/Patch.java b/src/main/java/ftbsc/lll/processor/annotations/Patch.java
index adbb674..9b0f5da 100644
--- a/src/main/java/ftbsc/lll/processor/annotations/Patch.java
+++ b/src/main/java/ftbsc/lll/processor/annotations/Patch.java
@@ -3,11 +3,24 @@ package ftbsc.lll.processor.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+/**
+ * Marks the class as containing an injector for a user-specified {@link Class}.
+ * It will be discarded unless {@link ftbsc.lll.processor.annotations.Target} and
+ * {@link Injector} are properly placed within.
+ * @see Target
+ * @see Injector
+ */
@Retention(RetentionPolicy.SOURCE)
-@Target(ElementType.TYPE)
+@java.lang.annotation.Target(ElementType.TYPE)
public @interface Patch {
+ /**
+ * @return the Minecraft {@link Class} to target for patching
+ */
Class<?> value();
+
+ /**
+ * @return the patching reason, for logging, defaults to "No reason specified."
+ */
String reason() default "No reason specified.";
}
diff --git a/src/main/java/ftbsc/lll/processor/annotations/Target.java b/src/main/java/ftbsc/lll/processor/annotations/Target.java
index e408755..14b4e7c 100644
--- a/src/main/java/ftbsc/lll/processor/annotations/Target.java
+++ b/src/main/java/ftbsc/lll/processor/annotations/Target.java
@@ -4,6 +4,15 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+/**
+ * Marks a method as the target method.
+ * The method itself should have the same name, return type and parameters as the desired
+ * Minecraft method.
+ * It will also be discarded unless the containing class is not annotated with {@link Patch}
+ * and no other method within the class is annotated with {@link Injector}.
+ * @see Patch
+ * @see Injector
+ */
@Retention(RetentionPolicy.SOURCE)
@java.lang.annotation.Target(ElementType.METHOD)
public @interface Target {}