3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-02 00:10:06 +02:00

Fix reflection field search on Spigot 1.20.2 (#3503)

Dieser Commit ist enthalten in:
fren_gor 2023-10-28 05:47:59 +02:00 committet von GitHub
Ursprung f618cdec99
Commit a022620712
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -63,8 +63,8 @@ public class JoinListener implements Listener {
}
// 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 {
for (Field field : all ? clazz.getFields() : clazz.getDeclaredFields()) {
private static Field findField(boolean checkSuperClass, Class<?> clazz, String... types) throws NoSuchFieldException {
for (Field field : clazz.getDeclaredFields()) {
String fieldTypeName = field.getType().getSimpleName();
for (String type : types) {
if (!fieldTypeName.equals(type)) {
@ -77,6 +77,11 @@ public class JoinListener implements Listener {
return field;
}
}
if (checkSuperClass && clazz != Object.class && clazz.getSuperclass() != null) {
return findField(true, clazz.getSuperclass(), types);
}
throw new NoSuchFieldException(types[0]);
}