插件在upgrade时自动重命名为原有名称...

This commit is contained in:
502647092 2016-03-01 20:48:47 +08:00
parent c996cc43dd
commit c5edf07ad6
2 changed files with 20 additions and 7 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.citycraft</groupId> <groupId>cn.citycraft</groupId>
<artifactId>Yum</artifactId> <artifactId>Yum</artifactId>
<version>2.0</version> <version>2.0.1</version>
<name>Yum</name> <name>Yum</name>
<description>Minecraft 服务器插件管理系统</description> <description>Minecraft 服务器插件管理系统</description>
<build> <build>
@ -56,7 +56,12 @@
<properties> <properties>
<jenkins.url>http://hs.yumc.pw:8080</jenkins.url> <jenkins.url>http://hs.yumc.pw:8080</jenkins.url>
<update.description>&amp;a全新 2.0 版本 震撼发布...</update.description> <update.description>&amp;a全新 2.0 版本 震撼发布...</update.description>
<update.changes>&amp;a精简大量代码...;&amp;a服务器启动后自动检查可更新插件...;&amp;a优化检测流程...</update.changes> <update.changes>
&amp;b2.0.1 &amp;6- &amp;c插件在upgrade时自动重命名为原有名称...
&amp;b2.0 &amp;6- &amp;a精简大量代码...
&amp;a 服务器启动后自动检查可更新插件...
&amp;a 优化检测流程...
</update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>

View File

@ -45,14 +45,14 @@ public class PluginsManager {
private final Set<String> ignoreList = new HashSet<>(); private final Set<String> ignoreList = new HashSet<>();
private final Plugin main; private final Plugin main;
public static String getVersion(final Plugin plugin) {
return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
}
public PluginsManager(final Plugin plugin) { public PluginsManager(final Plugin plugin) {
this.main = 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())) { if (plugin != null && !name.equals(plugin.getName())) {
continue; continue;
} }
final Plugin oldplugin = Bukkit.getPluginManager().getPlugin(name);
result = true; result = true;
File dest = null;
if (!unload(sender, name)) { if (!unload(sender, name)) {
sender.sendMessage("§6升级: §d开始安装 §b" + name + " §d插件!"); 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 { } else {
if (oldplugin != null) {
dest = new File(Bukkit.getUpdateFolderFile(), File.separatorChar + getPluginFile(oldplugin).getName());
}
sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!"); sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!");
} }
if (dest != null) {
file.renameTo(dest);
}
load(sender, name); load(sender, name);
} catch (final InvalidDescriptionException e) { } catch (final InvalidDescriptionException e) {
sender.sendMessage("§4异常: §c" + e.getMessage()); sender.sendMessage("§4异常: §c" + e.getMessage());