From 8149d8fb54d17193eaffa8bcc06f5b5f5bd4fc06 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 11 Feb 2024 11:21:44 +0100 Subject: [PATCH] New reflected field in CraftPlayer --- .../reflect/wrapper/craftbukkit/CraftPlayer.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 2c038b2..232bd5e 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,24 +1,38 @@ 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.ReflectMethod; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.lang.ref.WeakReference; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CraftPlayer extends ReflectWrapperTyped { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer")); - public static final ReflectMethod getHandle = wrapEx(() -> REFLECT.method("getHandle")); + private static final ReflectMethod getHandle = wrapEx(() -> REFLECT.method("getHandle")); + private static final ReflectField invertedVisibilityEntities = wrapEx(() -> REFLECT.field("invertedVisibilityEntities")); public ServerPlayer getHandle() { return wrap(wrapReflectEx(() -> getHandle.invoke(__getRuntimeInstance())), ServerPlayer.class); } + + @SuppressWarnings("unchecked") + public Map>> getInvertedVisibilityEntities() { + return (Map>>) wrapReflectEx(() -> invertedVisibilityEntities.getValue(__getRuntimeInstance())); + } + protected CraftPlayer(Object obj) { super(obj); }