feat: 重构部分方法 添加配置管理类

This commit is contained in:
502647092 2016-04-09 00:37:11 +08:00
parent 774c1ae62a
commit cf69ffc442
5 changed files with 59 additions and 13 deletions

View File

@ -13,8 +13,10 @@ import pw.yumc.Yum.api.YumAPI;
import pw.yumc.Yum.commands.FileCommand; import pw.yumc.Yum.commands.FileCommand;
import pw.yumc.Yum.commands.NetCommand; import pw.yumc.Yum.commands.NetCommand;
import pw.yumc.Yum.commands.YumCommand; import pw.yumc.Yum.commands.YumCommand;
import pw.yumc.Yum.listeners.PluginNetworkListener;
import pw.yumc.Yum.listeners.SecurityListener; import pw.yumc.Yum.listeners.SecurityListener;
import pw.yumc.Yum.manager.NetworkManager; import pw.yumc.Yum.managers.ConfigManager;
import pw.yumc.Yum.managers.NetworkManager;
/** /**
* MC插件仓库 * MC插件仓库
@ -31,6 +33,17 @@ public class Yum extends JavaPlugin {
return config; return config;
} }
public void initCommands() {
new YumCommand(this);
new NetCommand(this);
new FileCommand(this);
}
public void initListeners() {
new SecurityListener(this);
new PluginNetworkListener(this);
}
@Override @Override
public void onDisable() { public void onDisable() {
netmgr.unregister(); netmgr.unregister();
@ -39,10 +52,8 @@ public class Yum extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
new YumAPI(this); new YumAPI(this);
new YumCommand(this); initCommands();
new NetCommand(this); initListeners();
new FileCommand(this);
new SecurityListener(this);
new VersionChecker(this); new VersionChecker(this);
YumAPI.updaterepo(Bukkit.getConsoleSender()); YumAPI.updaterepo(Bukkit.getConsoleSender());
YumAPI.updatecheck(Bukkit.getConsoleSender()); YumAPI.updatecheck(Bukkit.getConsoleSender());
@ -51,6 +62,8 @@ public class Yum extends JavaPlugin {
@Override @Override
public void onLoad() { public void onLoad() {
config = new FileConfig(this); config = new FileConfig(this);
// 初始化配置
ConfigManager.init(getConfig());
// 初始化更新列 // 初始化更新列
UpdatePlugin.getUpdateList(); UpdatePlugin.getUpdateList();
// 启用网络注入 // 启用网络注入

View File

@ -11,10 +11,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import cn.citycraft.CommonData.UpdatePlugin; import cn.citycraft.CommonData.UpdatePlugin;
import pw.yumc.Yum.manager.DownloadManager; import pw.yumc.Yum.managers.DownloadManager;
import pw.yumc.Yum.manager.PluginsManager; import pw.yumc.Yum.managers.PluginsManager;
import pw.yumc.Yum.manager.RepositoryManager; import pw.yumc.Yum.managers.RepositoryManager;
import pw.yumc.Yum.manager.module.PluginInfo; import pw.yumc.Yum.models.PluginInfo;
/** /**
* Yum管理中心 * Yum管理中心

View File

@ -12,7 +12,7 @@ import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
import cn.citycraft.PluginHelper.utils.FileUtil; import cn.citycraft.PluginHelper.utils.FileUtil;
import pw.yumc.Yum.Yum; import pw.yumc.Yum.Yum;
import pw.yumc.Yum.api.YumAPI; import pw.yumc.Yum.api.YumAPI;
import pw.yumc.Yum.manager.DownloadManager; import pw.yumc.Yum.managers.DownloadManager;
/** /**
* File命令基类 * File命令基类

View File

@ -24,9 +24,9 @@ import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
import cn.citycraft.PluginHelper.utils.StringUtil; import cn.citycraft.PluginHelper.utils.StringUtil;
import pw.yumc.Yum.Yum; import pw.yumc.Yum.Yum;
import pw.yumc.Yum.api.YumAPI; import pw.yumc.Yum.api.YumAPI;
import pw.yumc.Yum.manager.PluginsManager; import pw.yumc.Yum.managers.PluginsManager;
import pw.yumc.Yum.manager.RepositoryManager; import pw.yumc.Yum.managers.RepositoryManager;
import pw.yumc.Yum.manager.module.RepoSerialization.Repositories; import pw.yumc.Yum.models.RepoSerialization.Repositories;
/** /**
* Yum命令基类 * Yum命令基类

View File

@ -0,0 +1,33 @@
package pw.yumc.Yum.managers;
import java.util.List;
import cn.citycraft.PluginHelper.config.FileConfig;
public class ConfigManager {
private static boolean allowPrimaryThread;
private static boolean networkDebug;
private static List<String> blackList;
private static List<String> ignoreList;
public static List<String> getBlackList() {
return blackList;
}
public static List<String> getIgnoreList() {
return ignoreList;
}
public static void init(final FileConfig config) {
allowPrimaryThread = config.getBoolean("AllowPrimaryThread", false);
networkDebug = config.getBoolean("NetworkDebug", false);
}
public static boolean isAllowPrimaryThread() {
return allowPrimaryThread;
}
public static boolean isNetworkDebug() {
return networkDebug;
}
}