New reflected static method in CraftPlayer
This commit is contained in:
parent
8149d8fb54
commit
177733950d
@ -10,6 +10,7 @@ import fr.pandacube.lib.reflect.ReflectMethod;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -21,6 +22,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
public class CraftPlayer extends ReflectWrapperTyped<Player> {
|
public class CraftPlayer extends ReflectWrapperTyped<Player> {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer"));
|
||||||
private static final ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
private static final ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
||||||
|
private static final ReflectMethod<?> getPluginWeakReference = wrapEx(() -> REFLECT.method("getPluginWeakReference"));
|
||||||
private static final ReflectField<?> invertedVisibilityEntities = wrapEx(() -> REFLECT.field("invertedVisibilityEntities"));
|
private static final ReflectField<?> invertedVisibilityEntities = wrapEx(() -> REFLECT.field("invertedVisibilityEntities"));
|
||||||
|
|
||||||
public ServerPlayer getHandle() {
|
public ServerPlayer getHandle() {
|
||||||
@ -33,6 +35,11 @@ public class CraftPlayer extends ReflectWrapperTyped<Player> {
|
|||||||
return (Map<UUID, Set<WeakReference<Plugin>>>) wrapReflectEx(() -> invertedVisibilityEntities.getValue(__getRuntimeInstance()));
|
return (Map<UUID, Set<WeakReference<Plugin>>>) wrapReflectEx(() -> invertedVisibilityEntities.getValue(__getRuntimeInstance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static WeakReference<Plugin> getPluginWeakReference(@Nullable Plugin plugin) {
|
||||||
|
return (WeakReference<Plugin>) wrapReflectEx(() -> getPluginWeakReference.invokeStatic(plugin));
|
||||||
|
}
|
||||||
|
|
||||||
protected CraftPlayer(Object obj) {
|
protected CraftPlayer(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user