package xyz.openmodloader.util;

import java.lang.reflect.Field;
import java.util.Arrays;

public class ReflectionHelper {

	public static <T, V> V getValue(Class<T> clazz, T object, String... names) throws ReflectiveOperationException {
		for (String name : names) {
			Field f = clazz.getDeclaredField(name);
			f.setAccessible(true);
			return (V)f.get(object);
		}
		throw new IllegalArgumentException(String.format("Class %s does not contain any of the fields %s", clazz.getName(), Arrays.toString(names)));
	}

}

@@ -261,16 +261,26 @@
 ames) %7B%0A
+%09%09%09try %7B%0A%09
 %09%09%09Field
@@ -314,16 +314,17 @@
 (name);%0A
+%09
 %09%09%09f.set
@@ -344,16 +344,17 @@
 ue);%0A%09%09%09
+%09
 return (
@@ -370,16 +370,522 @@
 bject);%0A
+%09%09%09%7D catch (NoSuchFieldException ignored) %7B%7D%0A%09%09%7D%0A%09%09throw new IllegalArgumentException(String.format(%22Class %25s does not contain any of the fields %25s%22, clazz.getName(), Arrays.toString(names)));%0A%09%7D%0A%0A%09public static %3CT%3E void setValue(Class%3CT%3E clazz, T object, Object value, String... names) throws ReflectiveOperationException %7B%0A%09%09for (String name : names) %7B%0A%09%09%09try %7B%0A%09%09%09%09Field f = clazz.getDeclaredField(name);%0A%09%09%09%09f.setAccessible(true);%0A%09%09%09%09f.set(object, value);%0A%09%09%09%7D catch (NoSuchFieldException ignored) %7B%7D%0A
 %09%09%7D%0A%09%09th

Fix ReflectionHelper.getValue and add ReflectionHelper.setValue for mod's use