mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-12-25 07:08:52 +00:00
fix: 修复注入配置空指针错误
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
e8571c7269
commit
4f7b4c9c0f
@ -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);
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user