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 @Override
public void onDisable() { public void onDisable() {
NetworkManager.unregister(); NetworkManager.unregister();
} }
@Override @Override
@ -58,9 +57,11 @@ public class Yum extends JavaPlugin {
initListeners(); initListeners();
initRunnable(); initRunnable();
new VersionChecker(this); new VersionChecker(this);
YumAPI.updateInject();
YumAPI.updateRepo(Bukkit.getConsoleSender()); YumAPI.updateRepo(Bukkit.getConsoleSender());
YumAPI.updateCheck(Bukkit.getConsoleSender()); YumAPI.updateCheck(Bukkit.getConsoleSender());
if (ConfigManager.i().isMonitorEnable()) {
YumAPI.updateInject();
}
} }
@Override @Override
@ -87,7 +88,6 @@ public class Yum extends JavaPlugin {
* 初始化监听 * 初始化监听
*/ */
private void initListeners() { private void initListeners() {
new PluginListener();
if (ConfigManager.i().isSetOpEnable()) { if (ConfigManager.i().isSetOpEnable()) {
try { try {
final ClassLoader cl = Class.forName("pw.yumc.injected.event.SetOpEvent").getClassLoader(); final ClassLoader cl = Class.forName("pw.yumc.injected.event.SetOpEvent").getClassLoader();
@ -110,6 +110,9 @@ public class Yum extends JavaPlugin {
new ThreadSafetyListener(this); new ThreadSafetyListener(this);
PluginKit.scp("§a线程管理系统已启用..."); 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 setop;
public final FileConfig network; public final FileConfig network;
public final FileConfig thread; public final FileConfig thread;
public final FileConfig monitor;
public static ConfigManager i() {
return i;
}
public ConfigManager(final JavaPlugin plugin) { public ConfigManager(final JavaPlugin plugin) {
config = new FileConfig(plugin); config = new FileConfig(plugin);
setop = new FileConfig(plugin, "setop.yml"); setop = new FileConfig(plugin, "setop.yml");
network = new FileConfig(plugin, "network.yml"); network = new FileConfig(plugin, "network.yml");
thread = new FileConfig(plugin, "thread.yml"); thread = new FileConfig(plugin, "thread.yml");
monitor = new FileConfig(plugin, "monitor.yml");
}
public static ConfigManager i() {
return i;
} }
public List<String> getBlackList() { public List<String> getBlackList() {
@ -66,6 +68,10 @@ public class ConfigManager {
return thread.getBoolean("MainThreadCheck", true); return thread.getBoolean("MainThreadCheck", true);
} }
public boolean isMonitorEnable() {
return monitor.getBoolean(ENABLE, true);
}
public boolean isNetworkDebug() { public boolean isNetworkDebug() {
return network.getBoolean("NetworkDebug", false); return network.getBoolean("NetworkDebug", false);
} }