82327c1d |
1 | package net.encode.wurmesp.util; |
2 | |
3 | import java.lang.reflect.Field; |
4 | import java.util.logging.Level; |
5 | import java.util.logging.Logger; |
6 | import net.encode.wurmesp.feature.hook.Hook; |
7 | import org.gotti.wurmunlimited.modloader.ReflectionUtil; |
8 | |
9 | public class ReUtils { |
10 | @SuppressWarnings("unchecked") |
11 | public static <T> T getField(Object proxy, String fieldname) { |
12 | Class<?> cls = proxy.getClass(); |
13 | Object returnedObject = null; |
14 | try { |
15 | Field field = ReflectionUtil.getField(cls, (String)fieldname); |
16 | returnedObject = ReflectionUtil.getPrivateField((Object)proxy, (Field)field); |
17 | } |
18 | catch (ClassCastException | IllegalAccessException | IllegalArgumentException | NoSuchFieldException ex) { |
19 | Logger.getLogger(Hook.class.getName()).log(Level.SEVERE, null, ex); |
20 | } |
21 | return (T)returnedObject; |
22 | } |
23 | } |
24 | |