diff --git a/src/main/java/pw/yumc/Yum/Yum.java b/src/main/java/pw/yumc/Yum/Yum.java index c9a79c8..f429a06 100644 --- a/src/main/java/pw/yumc/Yum/Yum.java +++ b/src/main/java/pw/yumc/Yum/Yum.java @@ -13,8 +13,8 @@ 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.SecurityListener; import pw.yumc.Yum.manager.NetworkManager; -import pw.yumc.Yum.manager.SecurityManager; /** * MC插件仓库 @@ -42,7 +42,7 @@ public class Yum extends JavaPlugin { new YumCommand(this); new NetCommand(this); new FileCommand(this); - new SecurityManager(this); + new SecurityListener(this); new VersionChecker(this); YumAPI.updaterepo(Bukkit.getConsoleSender()); YumAPI.updatecheck(Bukkit.getConsoleSender()); diff --git a/src/main/java/pw/yumc/Yum/api/YumAPI.java b/src/main/java/pw/yumc/Yum/api/YumAPI.java index 9dc9b7a..63bddf6 100644 --- a/src/main/java/pw/yumc/Yum/api/YumAPI.java +++ b/src/main/java/pw/yumc/Yum/api/YumAPI.java @@ -12,9 +12,9 @@ import org.bukkit.plugin.Plugin; import cn.citycraft.CommonData.UpdatePlugin; import pw.yumc.Yum.manager.DownloadManager; -import pw.yumc.Yum.manager.PluginInfo; import pw.yumc.Yum.manager.PluginsManager; import pw.yumc.Yum.manager.RepositoryManager; +import pw.yumc.Yum.manager.module.PluginInfo; /** * Yum管理中心 diff --git a/src/main/java/pw/yumc/Yum/commands/YumCommand.java b/src/main/java/pw/yumc/Yum/commands/YumCommand.java index 467c803..a44dab1 100644 --- a/src/main/java/pw/yumc/Yum/commands/YumCommand.java +++ b/src/main/java/pw/yumc/Yum/commands/YumCommand.java @@ -25,8 +25,8 @@ 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.RepoSerialization.Repositories; import pw.yumc.Yum.manager.RepositoryManager; +import pw.yumc.Yum.manager.module.RepoSerialization.Repositories; /** * Yum命令基类 diff --git a/src/main/java/pw/yumc/Yum/manager/SecurityManager.java b/src/main/java/pw/yumc/Yum/listeners/SecurityListener.java similarity index 88% rename from src/main/java/pw/yumc/Yum/manager/SecurityManager.java rename to src/main/java/pw/yumc/Yum/listeners/SecurityListener.java index e654ecb..84310aa 100644 --- a/src/main/java/pw/yumc/Yum/manager/SecurityManager.java +++ b/src/main/java/pw/yumc/Yum/listeners/SecurityListener.java @@ -1,4 +1,4 @@ -package pw.yumc.Yum.manager; +package pw.yumc.Yum.listeners; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; @@ -14,11 +14,11 @@ import pw.yumc.injected.event.SetOpEvent; * @since 2016年3月31日 下午3:01:22 * @author 喵♂呜 */ -public class SecurityManager implements Listener { +public class SecurityListener implements Listener { public String warn = "§6[§bYum §a安全系统§6] §c插件 §e%s §c已设置玩家 §a%s §c为OP §4请注意服务器安全!"; public String prevent = "§6[§bYum §a安全系统§6] §c黑名单插件 §e%s §c尝试设置玩家 §a%s §c为OP §a安全系统已成功拦截!"; - public SecurityManager(final Yum yum) { + public SecurityListener(final Yum yum) { Bukkit.getPluginManager().registerEvents(this, yum); } diff --git a/src/main/java/pw/yumc/Yum/manager/RepositoryManager.java b/src/main/java/pw/yumc/Yum/manager/RepositoryManager.java index 4faa49b..731c518 100644 --- a/src/main/java/pw/yumc/Yum/manager/RepositoryManager.java +++ b/src/main/java/pw/yumc/Yum/manager/RepositoryManager.java @@ -14,14 +14,16 @@ import org.bukkit.command.CommandSender; import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.jsonresult.JsonHandle; -import cn.citycraft.PluginHelper.utils.IOUtil; -import cn.citycraft.PluginHelper.utils.StringUtil; -import pw.yumc.Yum.manager.RepoSerialization.PackageInfo; -import pw.yumc.Yum.manager.RepoSerialization.Plugin; -import pw.yumc.Yum.manager.RepoSerialization.Repositories; -import pw.yumc.Yum.manager.RepoSerialization.Repository; -import pw.yumc.Yum.manager.RepoSerialization.TagInfo; -import pw.yumc.Yum.manager.RepoSerialization.URLType; +import cn.citycraft.PluginHelper.kit.HttpKit; +import cn.citycraft.PluginHelper.kit.StrKit; +import pw.yumc.Yum.manager.module.PluginInfo; +import pw.yumc.Yum.manager.module.RepoCache; +import pw.yumc.Yum.manager.module.RepoSerialization.PackageInfo; +import pw.yumc.Yum.manager.module.RepoSerialization.Plugin; +import pw.yumc.Yum.manager.module.RepoSerialization.Repositories; +import pw.yumc.Yum.manager.module.RepoSerialization.Repository; +import pw.yumc.Yum.manager.module.RepoSerialization.TagInfo; +import pw.yumc.Yum.manager.module.RepoSerialization.URLType; /** * 仓库管理类 @@ -40,7 +42,7 @@ public class RepositoryManager { } public boolean addPackage(final CommandSender sender, final String urlstring) { - final String json = IOUtil.getData(urlstring); + final String json = HttpKit.get(urlstring); if (json == null || json.isEmpty()) { return false; } @@ -135,7 +137,7 @@ public class RepositoryManager { } public Repositories getRepoCache(final String urlstring) { - return repocache.repos.get(handerRepoUrl(urlstring)); + return repocache.getRepos().get(handerRepoUrl(urlstring)); } public Map getRepos() { @@ -168,10 +170,10 @@ public class RepositoryManager { public void updatePackage(final CommandSender sender, final PackageInfo pkg) { for (final Plugin plugin : pkg.plugins) { final PluginInfo pi = new PluginInfo(); - pi.name = StringUtil.getNotNull(plugin.name, plugin.artifactId); - pi.branch = StringUtil.getNotNull(plugin.branch, "master"); - pi.pom = StringUtil.getNotNull(plugin.pom, pkg.pom); - pi.url = StringUtil.getNotNull(plugin.url, pkg.url); + pi.name = StrKit.getNotNull(plugin.name, plugin.artifactId); + pi.branch = StrKit.getNotNull(plugin.branch, "master"); + pi.pom = StrKit.getNotNull(plugin.pom, pkg.pom); + pi.url = StrKit.getNotNull(plugin.url, pkg.url); pi.type = plugin.type != null ? plugin.type : pkg.type; pi.type = pi.type != null ? pi.type : URLType.Maven; pi.plugin = plugin; diff --git a/src/main/java/pw/yumc/Yum/manager/PluginInfo.java b/src/main/java/pw/yumc/Yum/manager/module/PluginInfo.java similarity index 91% rename from src/main/java/pw/yumc/Yum/manager/PluginInfo.java rename to src/main/java/pw/yumc/Yum/manager/module/PluginInfo.java index d7e3f16..8983b58 100644 --- a/src/main/java/pw/yumc/Yum/manager/PluginInfo.java +++ b/src/main/java/pw/yumc/Yum/manager/module/PluginInfo.java @@ -1,4 +1,4 @@ -package pw.yumc.Yum.manager; +package pw.yumc.Yum.manager.module; import java.io.Serializable; @@ -7,9 +7,9 @@ import org.bukkit.command.CommandSender; import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.utils.IOUtil; -import pw.yumc.Yum.manager.RepoSerialization.Plugin; -import pw.yumc.Yum.manager.RepoSerialization.TagInfo; -import pw.yumc.Yum.manager.RepoSerialization.URLType; +import pw.yumc.Yum.manager.module.RepoSerialization.Plugin; +import pw.yumc.Yum.manager.module.RepoSerialization.TagInfo; +import pw.yumc.Yum.manager.module.RepoSerialization.URLType; public class PluginInfo implements Serializable { public static final String NMSVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; diff --git a/src/main/java/pw/yumc/Yum/manager/RepoCache.java b/src/main/java/pw/yumc/Yum/manager/module/RepoCache.java similarity index 93% rename from src/main/java/pw/yumc/Yum/manager/RepoCache.java rename to src/main/java/pw/yumc/Yum/manager/module/RepoCache.java index cb738d5..ed242cd 100644 --- a/src/main/java/pw/yumc/Yum/manager/RepoCache.java +++ b/src/main/java/pw/yumc/Yum/manager/module/RepoCache.java @@ -1,4 +1,4 @@ -package pw.yumc.Yum.manager; +package pw.yumc.Yum.manager.module; import java.io.Serializable; import java.util.ArrayList; @@ -10,7 +10,7 @@ import java.util.Map.Entry; import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.jsonresult.JsonHandle; import cn.citycraft.PluginHelper.utils.IOUtil; -import pw.yumc.Yum.manager.RepoSerialization.Repositories; +import pw.yumc.Yum.manager.module.RepoSerialization.Repositories; public class RepoCache implements Serializable { PluginHelperLogger logger = PluginHelperLogger.getLogger(); diff --git a/src/main/java/pw/yumc/Yum/manager/RepoSerialization.java b/src/main/java/pw/yumc/Yum/manager/module/RepoSerialization.java similarity index 93% rename from src/main/java/pw/yumc/Yum/manager/RepoSerialization.java rename to src/main/java/pw/yumc/Yum/manager/module/RepoSerialization.java index e06cb6a..56f6be5 100644 --- a/src/main/java/pw/yumc/Yum/manager/RepoSerialization.java +++ b/src/main/java/pw/yumc/Yum/manager/module/RepoSerialization.java @@ -1,7 +1,7 @@ /** * */ -package pw.yumc.Yum.manager; +package pw.yumc.Yum.manager.module; import java.io.Serializable; import java.util.ArrayList;