From ae52cbf22f9ff85bae3e278b7f15b8d7163f3123 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Sun, 6 Dec 2015 17:29:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9F=AD=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E5=89=8D=E5=8F=B0=E6=8F=90=E7=A4=BA...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/cn/citycraft/Yum/Yum.java | 1 - .../java/cn/citycraft/Yum/commands/CommandDelete.java | 2 +- .../cn/citycraft/Yum/commands/CommandInstall.java | 2 +- .../java/cn/citycraft/Yum/commands/CommandList.java | 2 +- .../java/cn/citycraft/Yum/commands/CommandRepo.java | 2 +- .../java/cn/citycraft/Yum/commands/CommandUpdate.java | 2 +- .../cn/citycraft/Yum/commands/CommandUpdateAll.java | 2 +- .../cn/citycraft/Yum/commands/CommandUpgrade.java | 2 +- .../cn/citycraft/Yum/manager/DownloadManager.java | 2 +- .../java/cn/citycraft/Yum/manager/PluginsManager.java | 8 ++++---- src/main/java/cn/citycraft/Yum/manager/RepoCache.java | 9 ++++----- .../cn/citycraft/Yum/manager/RepositoryManager.java | 11 ++++++----- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/cn/citycraft/Yum/Yum.java b/src/main/java/cn/citycraft/Yum/Yum.java index a34b66a..dfc88c9 100644 --- a/src/main/java/cn/citycraft/Yum/Yum.java +++ b/src/main/java/cn/citycraft/Yum/Yum.java @@ -21,7 +21,6 @@ public class Yum extends JavaPlugin { @Override public void onDisable() { YumAPI.getRepo().cacheToJson(config); - config.save(); } @Override diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java b/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java index 8e2264b..92595e4 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java @@ -22,7 +22,7 @@ public class CommandDelete extends BaseCommand { Yum main; public CommandDelete(final Yum main) { - super("remove"); + super("d"); this.main = main; setMinimumArguments(1); setDescription("删除插件"); diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java b/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java index b631a0c..dc7168d 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java @@ -29,7 +29,7 @@ public class CommandInstall extends BaseCommand { * @param name */ public CommandInstall(final Yum main) { - super(); + super("i"); this.main = main; setMinimumArguments(1); setDescription("安装插件"); diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandList.java b/src/main/java/cn/citycraft/Yum/commands/CommandList.java index b767937..90fc5f1 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandList.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandList.java @@ -25,7 +25,7 @@ public class CommandList extends BaseCommand { * @param name */ public CommandList(final Yum main) { - super(); + super("l"); this.main = main; setDescription("列出已安装插件列表"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java b/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java index bd5ec91..3068f17 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java @@ -29,7 +29,7 @@ public class CommandRepo extends BaseCommand { * @param name */ public CommandRepo(final Yum main) { - super(); + super("r"); this.main = main; setMinimumArguments(1); setDescription("插件源命令"); diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java b/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java index 99184ca..7e77aea 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java @@ -20,7 +20,7 @@ public class CommandUpdate extends BaseCommand { Yum main; public CommandUpdate(final Yum main) { - super(); + super("u"); this.main = main; setMinimumArguments(1); setDescription("更新插件"); diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUpdateAll.java b/src/main/java/cn/citycraft/Yum/commands/CommandUpdateAll.java index 99dcdba..4fbc706 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUpdateAll.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUpdateAll.java @@ -19,7 +19,7 @@ public class CommandUpdateAll extends BaseCommand { Yum main; public CommandUpdateAll(final Yum main) { - super(); + super("ua"); this.main = main; setDescription("更新所有可更新插件"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java b/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java index e8cfbc7..45af04b 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java @@ -23,7 +23,7 @@ public class CommandUpgrade extends BaseCommand { * @param name */ public CommandUpgrade(final Yum main) { - super(); + super("ug"); this.main = main; setDescription("升级插件"); setPossibleArguments("[插件名称]"); diff --git a/src/main/java/cn/citycraft/Yum/manager/DownloadManager.java b/src/main/java/cn/citycraft/Yum/manager/DownloadManager.java index 116f6ab..df8ac81 100644 --- a/src/main/java/cn/citycraft/Yum/manager/DownloadManager.java +++ b/src/main/java/cn/citycraft/Yum/manager/DownloadManager.java @@ -104,7 +104,7 @@ public class DownloadManager { final int fileLength = url.openConnection().getContentLength(); if (fileLength < 0) { sender.sendMessage("§6下载: §c文件 " + file.getName() + " 获取长度错误(可能是网络问题)!"); - sender.sendMessage("§6文件: §c " + file.getName() + " 下载失败!"); + sender.sendMessage("§6文件: §c" + file.getName() + " 下载失败!"); return false; } sender.sendMessage("§6文件长度: §3" + fileLength); diff --git a/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java b/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java index fd7b063..6092759 100644 --- a/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java +++ b/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java @@ -544,7 +544,7 @@ public class PluginsManager { } } } - sender.sendMessage("§6卸载: §a注销插件 " + name + " 的所有命令!"); + sender.sendMessage("§6卸载: §a注销插件 §b" + name + " §a的所有命令!"); } final ClassLoader cl = next.getClass().getClassLoader(); try { @@ -602,9 +602,9 @@ public class PluginsManager { updateDirectory = directory; } try { - sender.sendMessage("§6升级: §b从 " + updateDirectory.getCanonicalPath() + " 文件夹检索插件插件!"); + sender.sendMessage("§6升级: §b从 §d" + updateDirectory.getCanonicalPath() + " §b文件夹检索插件插件!"); } catch (SecurityException | IOException e1) { - sender.sendMessage("§4异常: §c文件夹 " + updateDirectory.getName() + " 权限不足或IO错误!"); + sender.sendMessage("§4异常: §c文件夹 §d" + updateDirectory.getName() + " §c权限不足或IO错误!"); return false; } for (final File file : updateDirectory.listFiles()) { @@ -650,7 +650,7 @@ public class PluginsManager { * @return 是否成功 */ public boolean upgrade(final File directory) { - Bukkit.getConsoleSender().sendMessage("§6升级: §a开始升级 " + directory.getName() + " 目录下的所有插件!"); + Bukkit.getConsoleSender().sendMessage("§6升级: §a开始升级 §d" + directory.getName() + " §a目录下的所有插件!"); return upgrade(Bukkit.getConsoleSender(), directory, null); } } diff --git a/src/main/java/cn/citycraft/Yum/manager/RepoCache.java b/src/main/java/cn/citycraft/Yum/manager/RepoCache.java index 44f42de..a8fa0d6 100644 --- a/src/main/java/cn/citycraft/Yum/manager/RepoCache.java +++ b/src/main/java/cn/citycraft/Yum/manager/RepoCache.java @@ -6,17 +6,16 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import cn.citycraft.PluginHelper.jsonresult.JsonResult; +import cn.citycraft.PluginHelper.jsonresult.JsonHandler; import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.Yum.manager.RepoSerialization.Repositories; public class RepoCache { - protected static JsonResult jr = JsonResult.newJsonResult(); Map plugins = new HashMap(); Map repos = new HashMap(); public static RepoCache fromJson(final String json) { - return jr.fromJson(json, RepoCache.class); + return JsonHandler.fromJson(json, RepoCache.class); } public void addPlugins(final String name, final PluginInfo info) { @@ -53,7 +52,7 @@ public class RepoCache { if (json == null || json.isEmpty()) { return null; } - final Repositories reposes = jr.fromJson(json, Repositories.class); + final Repositories reposes = JsonHandler.fromJson(json, Repositories.class); if (reposes == null || reposes.repos.isEmpty()) { return null; } @@ -74,6 +73,6 @@ public class RepoCache { @Override public String toString() { - return jr.toJson(this); + return JsonHandler.toJson(this); } } diff --git a/src/main/java/cn/citycraft/Yum/manager/RepositoryManager.java b/src/main/java/cn/citycraft/Yum/manager/RepositoryManager.java index 904acb1..bc09438 100644 --- a/src/main/java/cn/citycraft/Yum/manager/RepositoryManager.java +++ b/src/main/java/cn/citycraft/Yum/manager/RepositoryManager.java @@ -15,7 +15,8 @@ import org.bukkit.configuration.file.FileConfiguration; import com.google.gson.JsonSyntaxException; -import cn.citycraft.PluginHelper.jsonresult.JsonResult; +import cn.citycraft.PluginHelper.config.FileConfig; +import cn.citycraft.PluginHelper.jsonresult.JsonHandler; import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.StringUtil; import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo; @@ -29,7 +30,6 @@ import cn.citycraft.Yum.manager.RepoSerialization.Repository; * @author 蒋天蓓 */ public class RepositoryManager { - JsonResult jr = JsonResult.newJsonResult(); org.bukkit.plugin.Plugin main; RepoCache repocache; @@ -60,8 +60,9 @@ public class RepositoryManager { return updateRepositories(sender, repo); } - public void cacheToJson(final FileConfiguration config) { + public void cacheToJson(final FileConfig config) { config.set("reposcache", repocache.toString()); + config.save(); } public void clean() { @@ -161,14 +162,14 @@ public class RepositoryManager { public PackageInfo jsonToPackage(final String json) { try { - return jr.fromJson(json, PackageInfo.class); + return JsonHandler.fromJson(json, PackageInfo.class); } catch (final JsonSyntaxException e) { return null; } } public Repositories jsonToRepositories(final String json) { - return jr.fromJson(json, Repositories.class); + return JsonHandler.fromJson(json, Repositories.class); } public void updatePackage(final CommandSender sender, final PackageInfo pkg) {