完善多版本更新机制...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-12-15 20:58:28 +08:00
parent 63dda660c8
commit 34596e3b1d
5 changed files with 24 additions and 12 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>1.8.8</version> <version>1.8.9</version>
<name>Yum</name> <name>Yum</name>
<description>Minecraft 服务器插件管理系统</description> <description>Minecraft 服务器插件管理系统</description>
<build> <build>
@ -55,7 +55,8 @@
</build> </build>
<properties> <properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url> <jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
<update.description>&amp;c临时兼容旧版本的全体更新...</update.description> <update.description>&amp;a通过检测NMS版本实现多端兼容处理...</update.description>
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<repositories> <repositories>

View File

@ -1,10 +1,9 @@
package cn.citycraft.Yum.manager; package cn.citycraft.Yum.manager;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.PluginHelperLogger;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.IOUtil;
import cn.citycraft.Yum.manager.RepoSerialization.Plugin; import cn.citycraft.Yum.manager.RepoSerialization.Plugin;
import cn.citycraft.Yum.manager.RepoSerialization.TagInfo; import cn.citycraft.Yum.manager.RepoSerialization.TagInfo;
@ -19,7 +18,6 @@ public class PluginInfo {
public String pom; public String pom;
public URLType type; public URLType type;
public String repo; public String repo;
public List<TagInfo> tags;
public String url; public String url;
/** /**
@ -87,11 +85,15 @@ public class PluginInfo {
public String getUrl(final CommandSender sender, final String version) { public String getUrl(final CommandSender sender, final String version) {
String ver = version; String ver = version;
if (ver == null) { if (ver == null) {
if (tags != null) { if (plugin.tags != null) {
for (final TagInfo tagInfo : tags) { PluginHelperLogger.getLogger().debug("发现存在TAG标签 开始检索: " + NMSVersion);
for (final TagInfo tagInfo : plugin.tags) {
if (tagInfo.tag.equalsIgnoreCase(NMSVersion)) { if (tagInfo.tag.equalsIgnoreCase(NMSVersion)) {
sender.sendMessage("§6版本: §b从Tag标签中获取 §e" + NMSVersion + " §b的最新版本..."); sender.sendMessage("§6版本: §b从Tag标签中获取 §e" + NMSVersion + " §b的最新版本...");
ver = tagInfo.version; ver = tagInfo.version;
if (tagInfo.type == URLType.DirectUrl) {
return tagInfo.url;
}
break; break;
} }
} }

View File

@ -32,7 +32,6 @@ public class RepoCache {
} }
repos.put(repo, reposes); repos.put(repo, reposes);
return reposes; return reposes;
} }
public List<String> getAllRepoInfo() { public List<String> getAllRepoInfo() {

View File

@ -18,7 +18,7 @@ public class RepoSerialization {
public List<Plugin> plugins = new ArrayList<>(); public List<Plugin> plugins = new ArrayList<>();
public String pom; public String pom;
public String url; public String url;
public String type; public URLType type;
} }
public class Plugin { public class Plugin {
@ -31,7 +31,7 @@ public class RepoSerialization {
public String pom; public String pom;
public List<TagInfo> tags; public List<TagInfo> tags;
public String version; public String version;
public String type; public URLType type;
} }
public class Repositories { public class Repositories {
@ -41,13 +41,14 @@ public class RepoSerialization {
public class Repository { public class Repository {
public String id; public String id;
public String type; public URLType type;
public String url; public String url;
} }
public class TagInfo { public class TagInfo {
public String tag; public String tag;
public String version; public String version;
public URLType type;
public String url; public String url;
} }

View File

@ -23,6 +23,7 @@ import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo;
import cn.citycraft.Yum.manager.RepoSerialization.Plugin; import cn.citycraft.Yum.manager.RepoSerialization.Plugin;
import cn.citycraft.Yum.manager.RepoSerialization.Repositories; import cn.citycraft.Yum.manager.RepoSerialization.Repositories;
import cn.citycraft.Yum.manager.RepoSerialization.Repository; import cn.citycraft.Yum.manager.RepoSerialization.Repository;
import cn.citycraft.Yum.manager.RepoSerialization.TagInfo;
import cn.citycraft.Yum.manager.RepoSerialization.URLType; import cn.citycraft.Yum.manager.RepoSerialization.URLType;
/** /**
@ -92,9 +93,16 @@ public class RepositoryManager {
public List<String> getAllPluginsInfo() { public List<String> getAllPluginsInfo() {
final List<String> li = new ArrayList<String>(); final List<String> li = new ArrayList<String>();
li.add("§d仓库名称 §a插件名称 §e插件描述");
for (final Entry<String, PluginInfo> pi : repocache.getPlugins().entrySet()) { for (final Entry<String, PluginInfo> pi : repocache.getPlugins().entrySet()) {
final Plugin plugin = pi.getValue().plugin; final Plugin plugin = pi.getValue().plugin;
li.add(String.format("§d%s §a%s §6- §e%s", pi.getValue().repo, pi.getValue().name, plugin.description)); li.add(String.format("§d%s §a%s §6- §e%s", pi.getValue().repo, pi.getValue().name, plugin.description));
if (plugin.tags != null) {
li.add("§dTag标签 §a版本 §e类型 §c地址");
for (final TagInfo tag : plugin.tags) {
li.add(String.format(" §d%s §a%s §e%s §6- §c%s", tag.tag, tag.version, tag.type != null ? tag.type : URLType.Maven, tag.url != null ? tag.url : "未定义"));
}
}
} }
return li; return li;
} }
@ -180,7 +188,8 @@ public class RepositoryManager {
pi.branch = StringUtil.getNotNull(plugin.branch, "master"); pi.branch = StringUtil.getNotNull(plugin.branch, "master");
pi.pom = StringUtil.getNotNull(plugin.pom, pkg.pom); pi.pom = StringUtil.getNotNull(plugin.pom, pkg.pom);
pi.url = StringUtil.getNotNull(plugin.url, pkg.url); pi.url = StringUtil.getNotNull(plugin.url, pkg.url);
pi.type = URLType.valueOf(StringUtil.getNotNull(StringUtil.getNotNull(plugin.type, pkg.type), URLType.Maven.name())); pi.type = plugin.type != null ? plugin.type : pkg.type;
pi.type = pi.type != null ? pi.type : URLType.Maven;
pi.plugin = plugin; pi.plugin = plugin;
pi.repo = pkg.name; pi.repo = pkg.name;
repocache.getPlugins().put(plugin.groupId + "." + plugin.artifactId, pi); repocache.getPlugins().put(plugin.groupId + "." + plugin.artifactId, pi);