fix null error add unload info...

This commit is contained in:
502647092 2015-09-01 08:53:12 +08:00
parent abfdd97a28
commit c310706d33
2 changed files with 8 additions and 4 deletions

View File

@ -73,6 +73,7 @@ public class FileConfig extends YamlConfiguration {
private void check(File file) { private void check(File file) {
String filename = file.getName(); String filename = file.getName();
InputStream stream = plugin.getResource(filename); InputStream stream = plugin.getResource(filename);
try { try {
if (!file.exists()) { if (!file.exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
@ -84,6 +85,9 @@ public class FileConfig extends YamlConfiguration {
loger.info("配置文件 " + filename + " 不存在 从插件释放..."); loger.info("配置文件 " + filename + " 不存在 从插件释放...");
} }
} else { } else {
if (stream == null) {
return;
}
FileConfig newcfg = new FileConfig(stream); FileConfig newcfg = new FileConfig(stream);
FileConfig oldcfg = new FileConfig(file); FileConfig oldcfg = new FileConfig(file);
String newver = newcfg.getString("version"); String newver = newcfg.getString("version");

View File

@ -454,7 +454,7 @@ public class PluginsManager {
if (command.getPlugin() == next) { if (command.getPlugin() == next) {
command.unregister(commandMap); command.unregister(commandMap);
it.remove(); it.remove();
sender.sendMessage("§6卸载: §a插件: " + name + "命令!"); sender.sendMessage("§6卸载: §a插件 " + name + " " + command.getDescription() + " 命令已卸载!");
} }
} }
} }
@ -467,7 +467,7 @@ public class PluginsManager {
RegisteredListener value = it.next(); RegisteredListener value = it.next();
if (value.getPlugin().getName().equals(name)) { if (value.getPlugin().getName().equals(name)) {
it.remove(); it.remove();
sender.sendMessage("§6卸载: §a插件: " + name + "监听器!"); sender.sendMessage("§6卸载: §a插件 " + name + " " + value.getListener().getClass() + " 监听器已卸载!");
} }
} }
} }
@ -476,11 +476,11 @@ public class PluginsManager {
if ((cl instanceof URLClassLoader)) { if ((cl instanceof URLClassLoader)) {
try { try {
((URLClassLoader) cl).close(); ((URLClassLoader) cl).close();
sender.sendMessage("§6卸载: §a插件: " + name + " 类加载器!"); sender.sendMessage("§6卸载: §a插件 " + name + " 类加载器已卸载!");
} catch (IOException ex) { } catch (IOException ex) {
} }
} }
sender.sendMessage("§6卸载: §a插件: " + name + " 已成功卸载!"); sender.sendMessage("§6卸载: §a插件 " + name + " 已成功卸载!");
return true; return true;
} }