9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00

added native adventure component support

This commit is contained in:
XiaoMoMi
2025-03-28 20:11:29 +08:00
parent ebca2deef5
commit 29de340676
5 changed files with 194 additions and 13 deletions

View File

@@ -200,6 +200,30 @@ public class ReflectionUtils {
return null;
}
@Nullable
public static Method getMethod(final Class<?> clazz, Class<?> returnType, final String[] possibleMethodNames, final Class<?>... parameterTypes) {
outer:
for (Method method : clazz.getMethods()) {
if (method.getParameterCount() != parameterTypes.length) {
continue;
}
Class<?>[] types = method.getParameterTypes();
for (int i = 0; i < types.length; i++) {
if (types[i] != parameterTypes[i]) {
continue outer;
}
}
for (String name : possibleMethodNames) {
if (name.equals(method.getName())) {
if (returnType.isAssignableFrom(method.getReturnType())) {
return method;
}
}
}
}
return null;
}
@Nullable
public static Method getMethod(final Class<?> clazz, Class<?> returnType, int index) {
int i = 0;