public class ReflectionUtils extends Object
ParticleConstants| Modifier and Type | Field and Description |
|---|---|
static int |
MINECRAFT_VERSION
Represents the current Minecraft version as an int.
|
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
existsClass(String path)
Checks if a class exists
|
static Constructor |
getConstructorOrNull(Class targetClass,
Class... parameterTypes)
Gets a constructor without throwing exceptions
|
static Class<?> |
getCraftBukkitClass(String path)
Method to directly get the class object over the path
|
static String |
getCraftBukkitPackagePath() |
static String |
getCraftBukkitPath(String path)
Gets the craftbukkit path of a class without depending on versions
|
static Field |
getFieldOrNull(Class targetClass,
String fieldName,
boolean declared)
Method to not get disturbed by the forced try catch block
|
static Method |
getMethodOrNull(Class targetClass,
String methodName,
Class<?>... parameterTypes)
Method to not get disturbed by the forced try catch block
|
static Object |
getMinecraftKey(String key)
Creates a new MinecraftKey with the given data.
|
static String |
getNetMinecraftServerPackagePath() |
static Class<?> |
getNMSClass(String path)
Directly gets the class object over the path
|
static String |
getNMSPath(String path)
Gets the nms path of a class without depending on versions
|
static Object |
getPlayerConnection(org.bukkit.entity.Player target)
Gets the PlayerConnection of a
Player |
static Object |
getPlayerHandle(org.bukkit.entity.Player player)
Gets the EntityPlayer instance of a CraftPlayer
|
static Object |
readDeclaredField(Class targetClass,
String fieldName,
Object object)
Gets the specified declared Field over the specified fieldName and the given
targetClass.
|
static Object |
readDeclaredField(Field field,
Object object)
|
static Object |
readField(Class targetClass,
String fieldName,
Object object)
Gets the specified Field over the specified fieldName and the given targetClass.
|
static Object |
readField(Field field,
Object object)
|
static void |
sendPacket(org.bukkit.entity.Player player,
Object packet)
Sends a packet to a defined player.
|
static void |
writeDeclaredField(Class targetClass,
String fieldName,
Object object,
Object value)
Gets the specified declared
Field over the specified fieldName and the given
targetClass. |
static void |
writeDeclaredField(Field field,
Object object,
Object value)
|
static void |
writeField(Class targetClass,
String fieldName,
Object object,
Object value)
Gets the specified
Field over the specified fieldName and the given
targetClass. |
static void |
writeField(Field field,
Object object,
Object value)
|
public static final int MINECRAFT_VERSION
public static String getNMSPath(String path)
e.g. getNMSPath("Block") = "net.minecraft.server.v1_14_R1.Block" getNMSPath("Entity") = "net.minecraft.server.v1_12_R1.Entity"
path - the path that should be added
to the nms pathpublic static Class<?> getNMSClass(String path)
path - the path of the classpublic static String getCraftBukkitPath(String path)
e.g. getCraftBukkitPath("CraftChunk") = "org.bukkit.craftbukkit.v1_15_R1.CraftChunk" getCraftBukkitPath("event.CraftEventFactory") = "org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory"
path - the path that should be added to the craftbukkit pathpublic static Class<?> getCraftBukkitClass(String path)
path - the path of the classpublic static Method getMethodOrNull(Class targetClass, String methodName, Class<?>... parameterTypes)
public static Field getFieldOrNull(Class targetClass, String fieldName, boolean declared)
public static Constructor getConstructorOrNull(Class targetClass, Class... parameterTypes)
targetClass - the Class the Constructor is inparameterTypes - the parameterTypes of the ConstructorConstructor. If not found null.public static boolean existsClass(String path)
path - the path of the class that should be checkedpublic static Object readDeclaredField(Class targetClass, String fieldName, Object object)
public static void writeDeclaredField(Class targetClass, String fieldName, Object object, Object value)
public static void writeField(Class targetClass, String fieldName, Object object, Object value)
public static String getNetMinecraftServerPackagePath()
public static String getCraftBukkitPackagePath()
public static Object getMinecraftKey(String key)
key - the data that should be
used in the constructor
of the key.public static Object getPlayerHandle(org.bukkit.entity.Player player)
player - the CraftPlayernull if either the given parameter is invalid or an error occurs.public static Object getPlayerConnection(org.bukkit.entity.Player target)
Playertarget - the target PlayerPlayerpublic static void sendPacket(org.bukkit.entity.Player player,
Object packet)
player - the player that should receive the packetpacket - the packet that should be sentCopyright © 2020. All rights reserved.