From 49a32421c088d6c7d8ac7975b3d86aa58ca97b32 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 11 Feb 2024 13:48:24 +0100 Subject: [PATCH] Fixing reflection --- .../paper/reflect/wrapper/craftbukkit/CraftPlayer.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftPlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftPlayer.java index e6818b2..9a21e69 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftPlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftPlayer.java @@ -1,16 +1,14 @@ package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; import fr.pandacube.lib.paper.reflect.OBCReflect; -import fr.pandacube.lib.reflect.ReflectField; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer; import fr.pandacube.lib.reflect.ReflectClass; +import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectMethod; - +import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.util.Map; import java.util.Set; @@ -22,7 +20,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CraftPlayer extends ReflectWrapperTyped { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer")); private static final ReflectMethod getHandle = wrapEx(() -> REFLECT.method("getHandle")); - private static final ReflectMethod getPluginWeakReference = wrapEx(() -> REFLECT.method("getPluginWeakReference")); + private static final ReflectMethod getPluginWeakReference = wrapEx(() -> REFLECT.method("getPluginWeakReference", Plugin.class)); private static final ReflectField invertedVisibilityEntities = wrapEx(() -> REFLECT.field("invertedVisibilityEntities")); public ServerPlayer getHandle() { @@ -36,7 +34,7 @@ public class CraftPlayer extends ReflectWrapperTyped { } @SuppressWarnings("unchecked") - public static WeakReference getPluginWeakReference(@Nullable Plugin plugin) { + public static WeakReference getPluginWeakReference(Plugin plugin) { return (WeakReference) wrapReflectEx(() -> getPluginWeakReference.invokeStatic(plugin)); }