支持分标签获取插件版本...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-12-12 16:31:24 +08:00
parent 8dd7efea9e
commit 8a1e745325
2 changed files with 9 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package cn.citycraft.Yum.manager;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.IOUtil;
@ -9,6 +10,8 @@ import cn.citycraft.Yum.manager.RepoSerialization.Plugin;
import cn.citycraft.Yum.manager.RepoSerialization.TagInfo; import cn.citycraft.Yum.manager.RepoSerialization.TagInfo;
public class PluginInfo { public class PluginInfo {
public static final String NMSVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
public String branch; public String branch;
public String name; public String name;
public Plugin plugin; public Plugin plugin;
@ -39,8 +42,8 @@ public class PluginInfo {
if (ver == null) { if (ver == null) {
if (tags != null) { if (tags != null) {
for (final TagInfo tagInfo : tags) { for (final TagInfo tagInfo : tags) {
if (tagInfo.tag.equalsIgnoreCase("1.7.10")) { if (tagInfo.tag.equalsIgnoreCase(NMSVersion)) {
sender.sendMessage("§6版本: §b从Tag标签中获取最新版本..."); sender.sendMessage("§6版本: §b从Tag标签中获取 §e" + NMSVersion + " §b的最新版本...");
ver = tagInfo.version; ver = tagInfo.version;
break; break;
} }
@ -50,13 +53,13 @@ public class PluginInfo {
sender.sendMessage("§6版本: §b尝试从在线POM文件获取最新版本..."); sender.sendMessage("§6版本: §b尝试从在线POM文件获取最新版本...");
ver = IOUtil.getXMLTag(pom, "version", plugin.version); ver = IOUtil.getXMLTag(pom, "version", plugin.version);
if (ver != null) { if (ver != null) {
sender.sendMessage("§6版本: §a成功获取到最新版本 " + ver + " ..."); sender.sendMessage("§6版本: §a成功获取到最新版本 §e" + ver + " §a...");
} }
} }
} }
if (ver == null) { if (ver == null) {
ver = plugin.version; ver = plugin.version;
sender.sendMessage("§6版本: §a使用缓存的版本 " + ver + " ..."); sender.sendMessage("§6版本: §a使用缓存的版本 §e" + ver + " §a...");
} }
return String.format(url + (url.endsWith("/") ? "" : "/") + "%1$s/%2$s/%3$s/%2$s-%3$s.jar", return String.format(url + (url.endsWith("/") ? "" : "/") + "%1$s/%2$s/%3$s/%2$s-%3$s.jar",
plugin.groupId.replace(".", "/"), plugin.groupId.replace(".", "/"),

View File

@ -557,9 +557,8 @@ public class PluginsManager {
if (!pluginVersion.isEmpty()) { if (!pluginVersion.isEmpty()) {
sender.sendMessage("§6卸载: §a插件 §b" + name + " §a版本 §d" + pluginVersion + " §a已成功卸载!"); sender.sendMessage("§6卸载: §a插件 §b" + name + " §a版本 §d" + pluginVersion + " §a已成功卸载!");
return true; return true;
} else {
return false;
} }
return false;
} }
/** /**