Package redempt.redlib.nms
Class NMSHelper
java.lang.Object
redempt.redlib.nms.NMSHelper
A set of utility methods useful for handling NMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>[]
getArgTypes
(Object... args) Gets the class list of argument types for finding methodsstatic NMSClass
Gets any class and wraps it in an NMSClassstatic 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.static Method
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.static NMSClass
getNMSClass
(String name) Gets an NMS class (a class whose package is net.minecraft.server followed by the version package) by name.static String
Gets the full name of the NMS packagestatic String
static void
unwrapArgs
(Object... args) Unwraps an array of arguments, replacing NMSObjects with their wrapped values
-
Constructor Details
-
NMSHelper
public NMSHelper()
-
-
Method Details
-
getNMSPackage
Gets the full name of the NMS package- Returns:
- The full name of the NMS package
-
getNMSVersion
- Returns:
- The version section of the NMS package, like v1_15_R1
-
unwrapArgs
Unwraps an array of arguments, replacing NMSObjects with their wrapped values- Parameters:
args
- The arguments to unwrap
-
getArgTypes
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
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 inname
- The name of the methodargTypes
- The class types for the method parameters- Returns:
- The method in the class, or null if none was found
-
getConstructor
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 inargTypes
- The class types for the constructor parameters- Returns:
- The constructor in the class, or null if none was found
-
getNMSClass
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
Gets any class and wraps it in an NMSClass- Parameters:
name
- The full name of the class- Returns:
- The wrapped NMSClass
-