mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-25 15:58:46 +00:00
feat: 重构部分方法 添加配置管理类
This commit is contained in:
parent
774c1ae62a
commit
cf69ffc442
@ -13,8 +13,10 @@ import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.Yum.commands.FileCommand;
|
||||
import pw.yumc.Yum.commands.NetCommand;
|
||||
import pw.yumc.Yum.commands.YumCommand;
|
||||
import pw.yumc.Yum.listeners.PluginNetworkListener;
|
||||
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插件仓库
|
||||
@ -31,6 +33,17 @@ public class Yum extends JavaPlugin {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void initCommands() {
|
||||
new YumCommand(this);
|
||||
new NetCommand(this);
|
||||
new FileCommand(this);
|
||||
}
|
||||
|
||||
public void initListeners() {
|
||||
new SecurityListener(this);
|
||||
new PluginNetworkListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
netmgr.unregister();
|
||||
@ -39,10 +52,8 @@ public class Yum extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new YumAPI(this);
|
||||
new YumCommand(this);
|
||||
new NetCommand(this);
|
||||
new FileCommand(this);
|
||||
new SecurityListener(this);
|
||||
initCommands();
|
||||
initListeners();
|
||||
new VersionChecker(this);
|
||||
YumAPI.updaterepo(Bukkit.getConsoleSender());
|
||||
YumAPI.updatecheck(Bukkit.getConsoleSender());
|
||||
@ -51,6 +62,8 @@ public class Yum extends JavaPlugin {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
config = new FileConfig(this);
|
||||
// 初始化配置
|
||||
ConfigManager.init(getConfig());
|
||||
// 初始化更新列
|
||||
UpdatePlugin.getUpdateList();
|
||||
// 启用网络注入
|
||||
|
@ -11,10 +11,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.CommonData.UpdatePlugin;
|
||||
import pw.yumc.Yum.manager.DownloadManager;
|
||||
import pw.yumc.Yum.manager.PluginsManager;
|
||||
import pw.yumc.Yum.manager.RepositoryManager;
|
||||
import pw.yumc.Yum.manager.module.PluginInfo;
|
||||
import pw.yumc.Yum.managers.DownloadManager;
|
||||
import pw.yumc.Yum.managers.PluginsManager;
|
||||
import pw.yumc.Yum.managers.RepositoryManager;
|
||||
import pw.yumc.Yum.models.PluginInfo;
|
||||
|
||||
/**
|
||||
* Yum管理中心
|
||||
|
@ -12,7 +12,7 @@ import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
|
||||
import cn.citycraft.PluginHelper.utils.FileUtil;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.Yum.manager.DownloadManager;
|
||||
import pw.yumc.Yum.managers.DownloadManager;
|
||||
|
||||
/**
|
||||
* File命令基类
|
||||
|
@ -24,9 +24,9 @@ import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
|
||||
import cn.citycraft.PluginHelper.utils.StringUtil;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.Yum.manager.PluginsManager;
|
||||
import pw.yumc.Yum.manager.RepositoryManager;
|
||||
import pw.yumc.Yum.manager.module.RepoSerialization.Repositories;
|
||||
import pw.yumc.Yum.managers.PluginsManager;
|
||||
import pw.yumc.Yum.managers.RepositoryManager;
|
||||
import pw.yumc.Yum.models.RepoSerialization.Repositories;
|
||||
|
||||
/**
|
||||
* Yum命令基类
|
||||
|
33
src/main/java/pw/yumc/Yum/managers/ConfigManager.java
Normal file
33
src/main/java/pw/yumc/Yum/managers/ConfigManager.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user