Class NMSHelper

java.lang.Object
redempt.redlib.nms.NMSHelper

public class NMSHelper extends Object
A set of utility methods useful for handling NMS
  • Constructor Details

    • NMSHelper

      public NMSHelper()
  • Method Details

    • getNMSPackage

      public static String getNMSPackage()
      Gets the full name of the NMS package
      Returns:
      The full name of the NMS package
    • getNMSVersion

      public static String getNMSVersion()
      Returns:
      The version section of the NMS package, like v1_15_R1
    • unwrapArgs

      public static void unwrapArgs(Object... args)
      Unwraps an array of arguments, replacing NMSObjects with their wrapped values
      Parameters:
      args - The arguments to unwrap
    • getArgTypes

      public static Class<?>[] getArgTypes(Object... args)
      Gets the class list of argument types for finding methods
      Parameters:
      args - The arguments to convert to their class types
      Returns:
      The class types of each argument
    • getMethod

      public static Method getMethod(Class<?> clazz, String name, Class<?>[] argTypes)
      Gets a method by its name and parameter types, accounts for cases where the given class might not be the exact same type as the parameter the method requires, but is a subclass.
      Parameters:
      clazz - The class to get the method in
      name - The name of the method
      argTypes - The class types for the method parameters
      Returns:
      The method in the class, or null if none was found
    • getConstructor

      public static Constructor getConstructor(Class<?> clazz, Class<?>[] argTypes)
      Gets a constructor by its parameter types, accounts for cases where the given class might not be the exact same type as the parameter the method requires, but is a subclass.
      Parameters:
      clazz - The class to get the constructor in
      argTypes - The class types for the constructor parameters
      Returns:
      The constructor in the class, or null if none was found
    • getNMSClass

      public static NMSClass getNMSClass(String name)
      Gets an NMS class (a class whose package is net.minecraft.server followed by the version package) by name.
      Parameters:
      name - The name of the class
      Returns:
      The NMSClass wrapping the resulting class
    • getClass

      public static NMSClass getClass(String name)
      Gets any class and wraps it in an NMSClass
      Parameters:
      name - The full name of the class
      Returns:
      The wrapped NMSClass