1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-11-24 02:08:48 +00:00

fix: 修复注入配置空指针错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2017-05-27 20:47:09 +08:00
parent e8571c7269
commit 4f7b4c9c0f
2 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ public abstract class AbstractInjectConfig {
if (type.equals(String.class)) {
value = ChatColor.translateAlternateColorCodes('&', String.valueOf(value));
}
if (!type.isAssignableFrom(value.getClass())) {
if (value != null && !type.isAssignableFrom(value.getClass())) {
Log.w("字段 %s 默认类型为 %s 但解析后为 %s 可能存在转换错误!", field.getName(), type.getName(), value.getClass().getName());
}
field.set(this, value);

View File

@ -36,7 +36,7 @@ public class InjectParse {
public static Object parse(Class type, Object value, ConfigurationSection config, String path) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (allparse.containsKey(type)) { return allparse.get(type).parse(config, path); }
try {
return type.getDeclaredMethod("valueOf", String.class).invoke(null, value);
return type.getDeclaredMethod("valueOf", String.class).invoke(null, String.valueOf(value));
} catch (NoSuchMethodException | IllegalArgumentException ignored) {
}
if (InjectConfigurationSection.class.isAssignableFrom(type)) {