Fix reflection field search on Spigot 1.20.2 (#3503)
This commit is contained in:
parent
f618cdec99
commit
a022620712
|
@ -63,8 +63,8 @@ public class JoinListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loosely search a field with any name, as long as it matches a type name.
|
// Loosely search a field with any name, as long as it matches a type name.
|
||||||
private static Field findField(boolean all, Class<?> clazz, String... types) throws NoSuchFieldException {
|
private static Field findField(boolean checkSuperClass, Class<?> clazz, String... types) throws NoSuchFieldException {
|
||||||
for (Field field : all ? clazz.getFields() : clazz.getDeclaredFields()) {
|
for (Field field : clazz.getDeclaredFields()) {
|
||||||
String fieldTypeName = field.getType().getSimpleName();
|
String fieldTypeName = field.getType().getSimpleName();
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
if (!fieldTypeName.equals(type)) {
|
if (!fieldTypeName.equals(type)) {
|
||||||
|
@ -77,6 +77,11 @@ public class JoinListener implements Listener {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (checkSuperClass && clazz != Object.class && clazz.getSuperclass() != null) {
|
||||||
|
return findField(true, clazz.getSuperclass(), types);
|
||||||
|
}
|
||||||
|
|
||||||
throw new NoSuchFieldException(types[0]);
|
throw new NoSuchFieldException(types[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue