Class ReflectionUtil

java.lang.Object
com.fren_gor.ultimateAdvancementAPI.nms.util.ReflectionUtil

public class ReflectionUtil extends Object
Reflection utility class.
  • Field Details

    • MINECRAFT_VERSION

      public static final String MINECRAFT_VERSION
      The Minecraft version.

      For example 1.17.1.

    • MINOR_VERSION

      public static final int MINOR_VERSION
      The Minecraft minor version.

      For example, for 1.19.2 it is 1.

    • VERSION

      public static final int VERSION
      The NMS version.

      For example, for v1_17_R1 it is 17.

  • Method Details

    • classExists

      public static boolean classExists(@NotNull @NotNull String className)
      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 to net.minecraft).
      Returns:
      The required NMS class, or null if the class couldn't be found.
    • getCBClass

      @Nullable public static @Nullable Class<?> getCBClass(@NotNull @NotNull String name)
      Gets a CraftBukkit class using reflections.
      Parameters:
      name - The name of the CraftBukkit class, starting with its package (relative to org.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.