diff --git a/src/main/java/pw/yumc/Yum/Yum.java b/src/main/java/pw/yumc/Yum/Yum.java index f429a06..d9d4081 100644 --- a/src/main/java/pw/yumc/Yum/Yum.java +++ b/src/main/java/pw/yumc/Yum/Yum.java @@ -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(); // 启用网络注入 diff --git a/src/main/java/pw/yumc/Yum/api/YumAPI.java b/src/main/java/pw/yumc/Yum/api/YumAPI.java index 63bddf6..162d81a 100644 --- a/src/main/java/pw/yumc/Yum/api/YumAPI.java +++ b/src/main/java/pw/yumc/Yum/api/YumAPI.java @@ -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管理中心 diff --git a/src/main/java/pw/yumc/Yum/commands/FileCommand.java b/src/main/java/pw/yumc/Yum/commands/FileCommand.java index 84cbad6..5df87e8 100644 --- a/src/main/java/pw/yumc/Yum/commands/FileCommand.java +++ b/src/main/java/pw/yumc/Yum/commands/FileCommand.java @@ -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命令基类 diff --git a/src/main/java/pw/yumc/Yum/commands/YumCommand.java b/src/main/java/pw/yumc/Yum/commands/YumCommand.java index a44dab1..b030175 100644 --- a/src/main/java/pw/yumc/Yum/commands/YumCommand.java +++ b/src/main/java/pw/yumc/Yum/commands/YumCommand.java @@ -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命令基类 diff --git a/src/main/java/pw/yumc/Yum/managers/ConfigManager.java b/src/main/java/pw/yumc/Yum/managers/ConfigManager.java new file mode 100644 index 0000000..f185dd4 --- /dev/null +++ b/src/main/java/pw/yumc/Yum/managers/ConfigManager.java @@ -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 blackList; + private static List ignoreList; + + public static List getBlackList() { + return blackList; + } + + public static List 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; + } +}