From 4f7b4c9c0f4cd1a00a38928cdd59ff4ac41f5f8a Mon Sep 17 00:00:00 2001 From: 502647092 Date: Sat, 27 May 2017 20:47:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=A9=BA=E6=8C=87=E9=92=88=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../pw/yumc/YumCore/config/inject/AbstractInjectConfig.java | 2 +- src/main/java/pw/yumc/YumCore/config/inject/InjectParse.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java b/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java index 1100c23..55321dd 100644 --- a/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java +++ b/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java @@ -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); diff --git a/src/main/java/pw/yumc/YumCore/config/inject/InjectParse.java b/src/main/java/pw/yumc/YumCore/config/inject/InjectParse.java index f130a8f..c9781ab 100644 --- a/src/main/java/pw/yumc/YumCore/config/inject/InjectParse.java +++ b/src/main/java/pw/yumc/YumCore/config/inject/InjectParse.java @@ -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)) {