Class ReflectionUtil
java.lang.Object
com.fren_gor.ultimateAdvancementAPI.nms.util.ReflectionUtil
Reflection utility class.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The Minecraft version.static final int
The Minecraft minor version.static final int
The NMS version. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
classExists
(@NotNull String className) Returns whether the provided class exists.getCBClass
(@NotNull String name) Gets a CraftBukkit class using reflections.getNMSClass
(@NotNull String name, @NotNull String mcPackage) Gets an NMS class using reflections.getWrapperClass
(@NotNull Class<T> clazz) Gets the NMS-specific wrapper class of the provided class.
-
Field Details
-
MINECRAFT_VERSION
The Minecraft version.For example
1.17.1
. -
MINOR_VERSION
public static final int MINOR_VERSIONThe Minecraft minor version.For example, for
1.19.2
it is1
. -
VERSION
public static final int VERSIONThe NMS version.For example, for
v1_17_R1
it is17
.
-
-
Method Details
-
classExists
Returns whether the provided class exists.- Parameters:
className
- The fully qualified name of the class.- Returns:
- Whether the provided class exists.
-
getNMSClass
@Nullable public static @Nullable Class<?> getNMSClass(@NotNull @NotNull String name, @NotNull @NotNull String mcPackage) Gets an NMS class using reflections.For example, to get the NMS
Advancement
class this method should be called like:getNMSClass("Advancement", "advancements")
.Note that its fully qualified name in 1.17+ is
net.minecraft.advancements.Advancement
.- Parameters:
name
- The NMS class name.mcPackage
- The NMS class package (relative tonet.minecraft
).- Returns:
- The required NMS class, or
null
if the class couldn't be found.
-
getCBClass
Gets a CraftBukkit class using reflections.- Parameters:
name
- The name of the CraftBukkit class, starting with its package (relative toorg.bukkit.craftbukkit
).- Returns:
- The required CraftBukkit class, or
null
if the class couldn't be found.
-
getWrapperClass
@Nullable public static <T> @Nullable Class<? extends T> getWrapperClass(@NotNull @NotNull Class<T> clazz) Gets the NMS-specific wrapper class of the provided class.- Parameters:
clazz
- The non-NMS-specific wrapper class.- Returns:
- The NMS-specific wrapper class of the provided class, or
null
if the class couldn't be found.
-