1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-12-25 07:08:52 +00:00

feat: 提升init方法到抽象类

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-11-08 17:12:07 +08:00
parent 7a82f63e83
commit 5acc85e53a
2 changed files with 14 additions and 16 deletions

View File

@ -1,15 +1,7 @@
package pw.yumc.YumCore.config.inject;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.commands.exception.CommandParseException;
import pw.yumc.YumCore.config.annotation.ConfigNode;
@ -18,6 +10,13 @@ import pw.yumc.YumCore.config.annotation.Nullable;
import pw.yumc.YumCore.config.annotation.ReadOnly;
import pw.yumc.YumCore.config.exception.ConfigParseException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
/**
* 抽象注入配置
*
@ -128,6 +127,12 @@ public abstract class AbstractInjectConfig {
Log.d("设置字段 %s 为 %s ", field.getName(), value);
}
/**
* 配置注入后的初始化操作(对象初始化也要在此处)
*/
protected void init() {
}
/**
* 注入配置数据
*
@ -136,6 +141,7 @@ public abstract class AbstractInjectConfig {
*/
public void inject(ConfigurationSection config) {
inject(config, false);
init();
}
/**

View File

@ -24,7 +24,6 @@ public abstract class InjectConfig extends AbstractInjectConfig {
public InjectConfig(FileConfig config) {
this.config = config;
inject(config);
init();
}
public InjectConfig(String name) {
@ -40,19 +39,12 @@ public abstract class InjectConfig extends AbstractInjectConfig {
return config;
}
/**
* 初始化配置(对象初始化也要在此处)
*/
public void init() {
}
/**
* 重载配置文件
*/
public void reload() {
config.reload();
inject(config);
init();
}
/**