Add initial support for Spigot/CB 1.9

This commit is contained in:
Mike Primm 2016-03-01 22:40:52 -06:00
parent 20320c578f
commit 94fc53ef91
2 changed files with 71 additions and 10 deletions

View file

@ -197,10 +197,22 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
}
return null;
}
/**
* Get private field
*/
protected Field getPrivateFieldNoFail(Class<?> cls, String[] ids, Class<?> type) {
return getPrivateField(cls, ids, type, true);
}
/**
* Get private field
*/
protected Field getPrivateField(Class<?> cls, String[] ids, Class<?> type) {
return getPrivateField(cls, ids, type, false);
}
/**
* Get private field
*/
protected Field getPrivateField(Class<?> cls, String[] ids, Class<?> type, boolean nofail) {
if((cls == null) || (type == null)) return null;
for(String id : ids) {
try {
@ -212,8 +224,10 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
} catch (NoSuchFieldException nsfx) {
}
}
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
failed = true;
if (!nofail) {
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
failed = true;
}
return null;
}
protected Object getFieldValue(Object obj, Field field, Object def) {