add unload load message...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-08-23 23:32:19 +08:00
parent 74b2123445
commit c75864ad9e
2 changed files with 12 additions and 14 deletions

View File

@ -69,7 +69,7 @@ public class DownloadManager {
in = new BufferedInputStream(url.openStream()); in = new BufferedInputStream(url.openStream());
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
sender.sendMessage("§d创建新目录: " + file.getParentFile().getAbsolutePath()); sender.sendMessage("§6创建新目录: §d" + file.getParentFile().getAbsolutePath());
} }
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
@ -88,10 +88,10 @@ public class DownloadManager {
sender.sendMessage(String.format("§6已下载: §a" + getPer(percent / 10) + " %s%%", percent)); sender.sendMessage(String.format("§6已下载: §a" + getPer(percent / 10) + " %s%%", percent));
} }
} }
sender.sendMessage("§a文件: " + file.getName() + " 下载完成!"); sender.sendMessage("§6文件: §a" + file.getName() + " 下载完成!");
return true; return true;
} catch (Exception ex) { } catch (Exception ex) {
sender.sendMessage("§c文件" + file.getName() + "下载失败!"); sender.sendMessage("§6文件: §c" + file.getName() + "下载失败!");
ex.printStackTrace(); ex.printStackTrace();
return false; return false;
} finally { } finally {

View File

@ -173,12 +173,14 @@ public class PluginsManager {
} }
File file = new File("plugins/YumCenter", filename + ".jar"); File file = new File("plugins/YumCenter", filename + ".jar");
if (!file.exists()) { if (!file.exists()) {
sender.sendMessage("§c仓库不存在该插件!"); sender.sendMessage("§4错误: §c仓库不存在 " + filename + " 插件!");
return false; return false;
} }
File pluginfile = new File("plugins", filename + ".jar"); File pluginfile = new File("plugins", filename + ".jar");
copyFile(file, pluginfile); copyFile(file, pluginfile);
load(sender, filename + ".jar"); if (load(sender, filename + ".jar")) {
sender.sendMessage("§6安装: §a从Yum仓库安装插件 " + filename + " 成功!");
}
return false; return false;
} }
@ -234,15 +236,14 @@ public class PluginsManager {
sender.sendMessage("§c异常: " + e.getMessage() + " 文件: " + name + " 不是一个可载入的插件!"); sender.sendMessage("§c异常: " + e.getMessage() + " 文件: " + name + " 不是一个可载入的插件!");
return false; return false;
} catch (UnknownDependencyException e) { } catch (UnknownDependencyException e) {
sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 缺少部分依赖!"); sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 缺少部分依赖项目!");
return false; return false;
} }
target.onLoad(); target.onLoad();
Bukkit.getPluginManager().enablePlugin(target); Bukkit.getPluginManager().enablePlugin(target);
sender.sendMessage("§6载入: 插件 " + name + " 已成功载入到服务器!");
return true; return true;
// "§a插件: " + name + " 已成功载入到服务器!";
} }
public static boolean load(Plugin plugin) { public static boolean load(Plugin plugin) {
@ -306,12 +307,9 @@ public class PluginsManager {
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands"); Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
knownCommandsField.setAccessible(true); knownCommandsField.setAccessible(true);
commands = (Map<String, Command>) knownCommandsField.get(commandMap); commands = (Map<String, Command>) knownCommandsField.get(commandMap);
} catch (NoSuchFieldException e) { } catch (Exception e) {
sender.sendMessage("§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!");
return false; return false;
// "§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!";
} catch (IllegalAccessException e) {
return false;
// "§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!";
} }
} }
pluginManager.disablePlugin(plugin); pluginManager.disablePlugin(plugin);
@ -351,8 +349,8 @@ public class PluginsManager {
} }
} }
System.gc(); System.gc();
sender.sendMessage("§6卸载: §a插件: " + name + " 已成功卸载!");
return true; return true;
// "§a插件: " + name + " 已成功卸载!";
} }
public static boolean unload(Plugin plugin) { public static boolean unload(Plugin plugin) {