Annotate interfaces and methods with proper nullability and internal use annotations, and clean up formatting.
This commit is contained in:
1 parent
2b94a49352
commit
abc6c6c53e
3 files changed
+9
-6
No files matched your search
@@ -36,9 +36,7 @@ public sealed interface Anchor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(ClassNode node) {
|
||||
this.resolve(node);
|
||||
}
|
||||
public void verify(ClassNode node) { this.resolve(node); }
|
||||
}
|
||||
|
||||
/** A static or instance call to {@code owner.name desc} inside the method {@code in}. */
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package dev.overlord.zomboidforge.patcher;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
/** A build-time change to one class of the vanilla server jar. */
|
||||
@Internal
|
||||
public interface ClassPatch {
|
||||
/** Internal name of the class to patch, e.g. {@code zombie/network/GameServer}. */
|
||||
String target();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.overlord.zomboidforge.patcher;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
@@ -19,7 +21,7 @@ public abstract class HookInjectionPatch implements ClassPatch
|
||||
private final Anchor.Call anchor;
|
||||
private final Hook hook;
|
||||
|
||||
protected HookInjectionPatch(String target, Anchor.Call anchor, Hook hook)
|
||||
protected HookInjectionPatch(String target, Anchor.Call anchor, @NotNull Hook hook)
|
||||
{
|
||||
if (!hook.desc().equals(HookInjectionPatch.HOOK_DESC))
|
||||
throw new IllegalArgumentException("Hook '" + hook + "' must have descriptor '" + HookInjectionPatch.HOOK_DESC + "'.");
|
||||
@@ -34,7 +36,7 @@ public abstract class HookInjectionPatch implements ClassPatch
|
||||
@Override
|
||||
public final Anchor.Call anchor() { return this.anchor; }
|
||||
@Override
|
||||
public final Hook hook() { return this.hook; }
|
||||
public final @NotNull Hook hook() { return this.hook; }
|
||||
|
||||
@Override
|
||||
public final void apply(ClassNode node)
|
||||
@@ -42,7 +44,7 @@ public abstract class HookInjectionPatch implements ClassPatch
|
||||
MethodInsnNode call = this.anchor.resolve(node);
|
||||
|
||||
this.anchor.in().resolve(node).instructions.insert(
|
||||
call, new MethodInsnNode(
|
||||
call, new MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
this.hook.owner(),
|
||||
this.hook.name(),
|
||||
|
||||
Reference in new issue
Block a user