1 package net
.encode
.wurmesp
.util
;
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
;
10 @SuppressWarnings("unchecked")
11 public static <T
> T
getField(Object proxy
, String fieldname
) {
12 Class
<?
> cls
= proxy
.getClass();
13 Object returnedObject
= null;
15 Field field
= ReflectionUtil
.getField(cls
, (String
)fieldname
);
16 returnedObject
= ReflectionUtil
.getPrivateField((Object
)proxy
, (Field
)field
);
18 catch (ClassCastException
| IllegalAccessException
| IllegalArgumentException
| NoSuchFieldException ex
) {
19 Logger
.getLogger(Hook
.class.getName()).log(Level
.SEVERE
, null, ex
);
21 return (T
)returnedObject
;