소스 검색

Fix superclass listeners not getting registered

Lortseam 4 년 전
부모
커밋
fd39398191

+ 0 - 8
lib/src/main/java/me/lortseam/completeconfig/data/Entry.java

@@ -61,14 +61,6 @@ public class Entry<T> extends EntryBase<T> implements DataPart {
         });
     }
 
-    static EntryBase<?> of(String fieldName, Class<? extends ConfigContainer> parentClass) {
-        try {
-            return of(parentClass.getDeclaredField(fieldName), parentClass);
-        } catch (NoSuchFieldException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     static EntryBase<?> of(Field field, Class<? extends ConfigContainer> parentClass) {
         return entries.computeIfAbsent(new Key(field, parentClass), absentField -> new Draft<>(field));
     }

+ 6 - 1
lib/src/main/java/me/lortseam/completeconfig/data/EntrySet.java

@@ -68,7 +68,12 @@ public class EntrySet extends DataSet<Entry> {
                 if (method.getParameterCount() != 1) {
                     throw new IllegalArgumentException("Listener method " + method + " has wrong number of parameters");
                 }
-                EntryBase<?> entry = Entry.of(fieldName, fieldClass);
+                EntryBase<?> entry;
+                try {
+                    entry = Entry.of(fieldClass.getDeclaredField(fieldName), container.getClass());
+                } catch (NoSuchFieldException e) {
+                    throw new RuntimeException(e);
+                }
                 if (!method.getParameterTypes()[0].equals(entry.getType())) {
                     throw new IllegalArgumentException("Listener method " + method + " has wrong argument type");
                 }