From c75864ad9e5811ae2522f7bc4871dc97ce2b3412 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sun, 23 Aug 2015 23:32:19 +0800 Subject: [PATCH] add unload load message... Signed-off-by: j502647092 --- .../citycraft/Yum/utils/DownloadManager.java | 6 +++--- .../citycraft/Yum/utils/PluginsManager.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/cn/citycraft/Yum/utils/DownloadManager.java b/src/main/java/cn/citycraft/Yum/utils/DownloadManager.java index f91d830..d13e133 100644 --- a/src/main/java/cn/citycraft/Yum/utils/DownloadManager.java +++ b/src/main/java/cn/citycraft/Yum/utils/DownloadManager.java @@ -69,7 +69,7 @@ public class DownloadManager { in = new BufferedInputStream(url.openStream()); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); - sender.sendMessage("§d创建新目录: " + file.getParentFile().getAbsolutePath()); + sender.sendMessage("§6创建新目录: §d" + file.getParentFile().getAbsolutePath()); } if (file.exists()) { file.delete(); @@ -88,10 +88,10 @@ public class DownloadManager { sender.sendMessage(String.format("§6已下载: §a" + getPer(percent / 10) + " %s%%", percent)); } } - sender.sendMessage("§a文件: " + file.getName() + " 下载完成!"); + sender.sendMessage("§6文件: §a" + file.getName() + " 下载完成!"); return true; } catch (Exception ex) { - sender.sendMessage("§c文件" + file.getName() + "下载失败!"); + sender.sendMessage("§6文件: §c" + file.getName() + "下载失败!"); ex.printStackTrace(); return false; } finally { diff --git a/src/main/java/cn/citycraft/Yum/utils/PluginsManager.java b/src/main/java/cn/citycraft/Yum/utils/PluginsManager.java index 029cecd..cee68f6 100644 --- a/src/main/java/cn/citycraft/Yum/utils/PluginsManager.java +++ b/src/main/java/cn/citycraft/Yum/utils/PluginsManager.java @@ -173,12 +173,14 @@ public class PluginsManager { } File file = new File("plugins/YumCenter", filename + ".jar"); if (!file.exists()) { - sender.sendMessage("§c仓库不存在该插件!"); + sender.sendMessage("§4错误: §c仓库不存在 " + filename + " 插件!"); return false; } File pluginfile = new File("plugins", filename + ".jar"); copyFile(file, pluginfile); - load(sender, filename + ".jar"); + if (load(sender, filename + ".jar")) { + sender.sendMessage("§6安装: §a从Yum仓库安装插件 " + filename + " 成功!"); + } return false; } @@ -234,15 +236,14 @@ public class PluginsManager { sender.sendMessage("§c异常: " + e.getMessage() + " 文件: " + name + " 不是一个可载入的插件!"); return false; } catch (UnknownDependencyException e) { - sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 缺少部分依赖!"); + sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 缺少部分依赖项目!"); return false; } target.onLoad(); Bukkit.getPluginManager().enablePlugin(target); - + sender.sendMessage("§6载入: 插件 " + name + " 已成功载入到服务器!"); return true; - // "§a插件: " + name + " 已成功载入到服务器!"; } public static boolean load(Plugin plugin) { @@ -306,12 +307,9 @@ public class PluginsManager { Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands"); knownCommandsField.setAccessible(true); commands = (Map) knownCommandsField.get(commandMap); - } catch (NoSuchFieldException e) { + } catch (Exception e) { + sender.sendMessage("§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!"); return false; - // "§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!"; - } catch (IllegalAccessException e) { - return false; - // "§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!"; } } pluginManager.disablePlugin(plugin); @@ -351,8 +349,8 @@ public class PluginsManager { } } System.gc(); + sender.sendMessage("§6卸载: §a插件: " + name + " 已成功卸载!"); return true; - // "§a插件: " + name + " 已成功卸载!"; } public static boolean unload(Plugin plugin) {