feat: 添加能耗监控开关

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-14 17:20:00 +08:00
parent 8570ec55c9
commit 94bf64e36b
2 changed files with 16 additions and 7 deletions

View File

@ -45,7 +45,6 @@ public class Yum extends JavaPlugin {
@Override
public void onDisable() {
NetworkManager.unregister();
}
@Override
@ -58,9 +57,11 @@ public class Yum extends JavaPlugin {
initListeners();
initRunnable();
new VersionChecker(this);
YumAPI.updateInject();
YumAPI.updateRepo(Bukkit.getConsoleSender());
YumAPI.updateCheck(Bukkit.getConsoleSender());
if (ConfigManager.i().isMonitorEnable()) {
YumAPI.updateInject();
}
}
@Override
@ -87,7 +88,6 @@ public class Yum extends JavaPlugin {
* 初始化监听
*/
private void initListeners() {
new PluginListener();
if (ConfigManager.i().isSetOpEnable()) {
try {
final ClassLoader cl = Class.forName("pw.yumc.injected.event.SetOpEvent").getClassLoader();
@ -110,6 +110,9 @@ public class Yum extends JavaPlugin {
new ThreadSafetyListener(this);
PluginKit.scp("§a线程管理系统已启用...");
}
if (ConfigManager.i().isMonitorEnable()) {
new PluginListener();
}
}
/**

View File

@ -18,16 +18,18 @@ public class ConfigManager {
public final FileConfig setop;
public final FileConfig network;
public final FileConfig thread;
public static ConfigManager i() {
return i;
}
public final FileConfig monitor;
public ConfigManager(final JavaPlugin plugin) {
config = new FileConfig(plugin);
setop = new FileConfig(plugin, "setop.yml");
network = new FileConfig(plugin, "network.yml");
thread = new FileConfig(plugin, "thread.yml");
monitor = new FileConfig(plugin, "monitor.yml");
}
public static ConfigManager i() {
return i;
}
public List<String> getBlackList() {
@ -66,6 +68,10 @@ public class ConfigManager {
return thread.getBoolean("MainThreadCheck", true);
}
public boolean isMonitorEnable() {
return monitor.getBoolean(ENABLE, true);
}
public boolean isNetworkDebug() {
return network.getBoolean("NetworkDebug", false);
}