refactor: 调整项目包结构

This commit is contained in:
502647092 2016-04-08 20:35:34 +08:00
parent d298c2c6a6
commit fe04035658
8 changed files with 30 additions and 28 deletions

View File

@ -13,8 +13,8 @@ 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.SecurityListener;
import pw.yumc.Yum.manager.NetworkManager; import pw.yumc.Yum.manager.NetworkManager;
import pw.yumc.Yum.manager.SecurityManager;
/** /**
* MC插件仓库 * MC插件仓库
@ -42,7 +42,7 @@ public class Yum extends JavaPlugin {
new YumCommand(this); new YumCommand(this);
new NetCommand(this); new NetCommand(this);
new FileCommand(this); new FileCommand(this);
new SecurityManager(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());

View File

@ -12,9 +12,9 @@ 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.manager.DownloadManager;
import pw.yumc.Yum.manager.PluginInfo;
import pw.yumc.Yum.manager.PluginsManager; import pw.yumc.Yum.manager.PluginsManager;
import pw.yumc.Yum.manager.RepositoryManager; import pw.yumc.Yum.manager.RepositoryManager;
import pw.yumc.Yum.manager.module.PluginInfo;
/** /**
* Yum管理中心 * Yum管理中心

View File

@ -25,8 +25,8 @@ 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.manager.PluginsManager;
import pw.yumc.Yum.manager.RepoSerialization.Repositories;
import pw.yumc.Yum.manager.RepositoryManager; import pw.yumc.Yum.manager.RepositoryManager;
import pw.yumc.Yum.manager.module.RepoSerialization.Repositories;
/** /**
* Yum命令基类 * Yum命令基类

View File

@ -1,4 +1,4 @@
package pw.yumc.Yum.manager; package pw.yumc.Yum.listeners;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -14,11 +14,11 @@ import pw.yumc.injected.event.SetOpEvent;
* @since 2016年3月31日 下午3:01:22 * @since 2016年3月31日 下午3:01:22
* @author * @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 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 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); Bukkit.getPluginManager().registerEvents(this, yum);
} }

View File

@ -14,14 +14,16 @@ import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.PluginHelperLogger;
import cn.citycraft.PluginHelper.jsonresult.JsonHandle; import cn.citycraft.PluginHelper.jsonresult.JsonHandle;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.kit.HttpKit;
import cn.citycraft.PluginHelper.utils.StringUtil; import cn.citycraft.PluginHelper.kit.StrKit;
import pw.yumc.Yum.manager.RepoSerialization.PackageInfo; import pw.yumc.Yum.manager.module.PluginInfo;
import pw.yumc.Yum.manager.RepoSerialization.Plugin; import pw.yumc.Yum.manager.module.RepoCache;
import pw.yumc.Yum.manager.RepoSerialization.Repositories; import pw.yumc.Yum.manager.module.RepoSerialization.PackageInfo;
import pw.yumc.Yum.manager.RepoSerialization.Repository; import pw.yumc.Yum.manager.module.RepoSerialization.Plugin;
import pw.yumc.Yum.manager.RepoSerialization.TagInfo; import pw.yumc.Yum.manager.module.RepoSerialization.Repositories;
import pw.yumc.Yum.manager.RepoSerialization.URLType; 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) { 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()) { if (json == null || json.isEmpty()) {
return false; return false;
} }
@ -135,7 +137,7 @@ public class RepositoryManager {
} }
public Repositories getRepoCache(final String urlstring) { public Repositories getRepoCache(final String urlstring) {
return repocache.repos.get(handerRepoUrl(urlstring)); return repocache.getRepos().get(handerRepoUrl(urlstring));
} }
public Map<String, Repositories> getRepos() { public Map<String, Repositories> getRepos() {
@ -168,10 +170,10 @@ public class RepositoryManager {
public void updatePackage(final CommandSender sender, final PackageInfo pkg) { public void updatePackage(final CommandSender sender, final PackageInfo pkg) {
for (final Plugin plugin : pkg.plugins) { for (final Plugin plugin : pkg.plugins) {
final PluginInfo pi = new PluginInfo(); final PluginInfo pi = new PluginInfo();
pi.name = StringUtil.getNotNull(plugin.name, plugin.artifactId); pi.name = StrKit.getNotNull(plugin.name, plugin.artifactId);
pi.branch = StringUtil.getNotNull(plugin.branch, "master"); pi.branch = StrKit.getNotNull(plugin.branch, "master");
pi.pom = StringUtil.getNotNull(plugin.pom, pkg.pom); pi.pom = StrKit.getNotNull(plugin.pom, pkg.pom);
pi.url = StringUtil.getNotNull(plugin.url, pkg.url); pi.url = StrKit.getNotNull(plugin.url, pkg.url);
pi.type = plugin.type != null ? plugin.type : pkg.type; pi.type = plugin.type != null ? plugin.type : pkg.type;
pi.type = pi.type != null ? pi.type : URLType.Maven; pi.type = pi.type != null ? pi.type : URLType.Maven;
pi.plugin = plugin; pi.plugin = plugin;

View File

@ -1,4 +1,4 @@
package pw.yumc.Yum.manager; package pw.yumc.Yum.manager.module;
import java.io.Serializable; import java.io.Serializable;
@ -7,9 +7,9 @@ import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.PluginHelperLogger;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.IOUtil;
import pw.yumc.Yum.manager.RepoSerialization.Plugin; import pw.yumc.Yum.manager.module.RepoSerialization.Plugin;
import pw.yumc.Yum.manager.RepoSerialization.TagInfo; import pw.yumc.Yum.manager.module.RepoSerialization.TagInfo;
import pw.yumc.Yum.manager.RepoSerialization.URLType; import pw.yumc.Yum.manager.module.RepoSerialization.URLType;
public class PluginInfo implements Serializable { public class PluginInfo implements Serializable {
public static final String NMSVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; public static final String NMSVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];

View File

@ -1,4 +1,4 @@
package pw.yumc.Yum.manager; package pw.yumc.Yum.manager.module;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,7 +10,7 @@ import java.util.Map.Entry;
import cn.citycraft.PluginHelper.PluginHelperLogger; import cn.citycraft.PluginHelper.PluginHelperLogger;
import cn.citycraft.PluginHelper.jsonresult.JsonHandle; import cn.citycraft.PluginHelper.jsonresult.JsonHandle;
import cn.citycraft.PluginHelper.utils.IOUtil; 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 { public class RepoCache implements Serializable {
PluginHelperLogger logger = PluginHelperLogger.getLogger(); PluginHelperLogger logger = PluginHelperLogger.getLogger();

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package pw.yumc.Yum.manager; package pw.yumc.Yum.manager.module;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;