From c5edf07ad6c043169159918bb647ecd6f097e94a Mon Sep 17 00:00:00 2001 From: 502647092 Date: Tue, 1 Mar 2016 20:48:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=9C=A8upgrade=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BA=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E5=90=8D=E7=A7=B0...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 9 +++++++-- .../citycraft/Yum/manager/PluginsManager.java | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index db1f72d..032128d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cn.citycraft Yum - 2.0 + 2.0.1 Yum Minecraft 服务器插件管理系统 @@ -56,7 +56,12 @@ http://hs.yumc.pw:8080 &a全新 2.0 版本 震撼发布... - &a精简大量代码...;&a服务器启动后自动检查可更新插件...;&a优化检测流程... + + &b2.0.1 &6- &c插件在upgrade时自动重命名为原有名称... + &b2.0 &6- &a精简大量代码... + &a 服务器启动后自动检查可更新插件... + &a 优化检测流程... + DEBUG UTF-8 diff --git a/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java b/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java index ae5985c..3ffa090 100644 --- a/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java +++ b/src/main/java/cn/citycraft/Yum/manager/PluginsManager.java @@ -45,14 +45,14 @@ public class PluginsManager { private final Set ignoreList = new HashSet<>(); private final Plugin main; - public static String getVersion(final Plugin plugin) { - return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15); - } - public PluginsManager(final Plugin plugin) { this.main = plugin; } + public static String getVersion(final Plugin plugin) { + return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15); + } + /** * 添加到忽略列表 * @@ -655,13 +655,21 @@ public class PluginsManager { if (plugin != null && !name.equals(plugin.getName())) { continue; } + final Plugin oldplugin = Bukkit.getPluginManager().getPlugin(name); result = true; + File dest = null; if (!unload(sender, name)) { sender.sendMessage("§6升级: §d开始安装 §b" + name + " §d插件!"); - FileUtil.copyFile(file, new File(Bukkit.getUpdateFolderFile().getParentFile(), File.separatorChar + file.getName())); + dest = new File(Bukkit.getUpdateFolderFile().getParentFile(), File.separatorChar + file.getName()); } else { + if (oldplugin != null) { + dest = new File(Bukkit.getUpdateFolderFile(), File.separatorChar + getPluginFile(oldplugin).getName()); + } sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!"); } + if (dest != null) { + file.renameTo(dest); + } load(sender, name); } catch (final InvalidDescriptionException e) { sender.sendMessage("§4异常: §c" + e.getMessage());