Added ReflectionUtils helper class to find Fields with @Interpolate annotation in superclasses (Interpolators didn't account for Fields in AdvancedPosition inherited by Position)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import eu.crushedpixel.replaymod.interpolation.Interpolate;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReflectionUtils {
|
||||
|
||||
public static List<Field> getFieldsToInterpolate(Class clazz) {
|
||||
List<Field> fields = new ArrayList<Field>();
|
||||
for(Field f : clazz.getDeclaredFields()) {
|
||||
if(f.isAnnotationPresent(Interpolate.class)) fields.add(f);
|
||||
}
|
||||
|
||||
if(clazz.getSuperclass() != Object.class) {
|
||||
fields.addAll(getFieldsToInterpolate(clazz.getSuperclass()));
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user