mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 06:18:46 +00:00
使用国内源数据 添加仓库查看命令...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
84295a46de
commit
281e09b496
4
pom.xml
4
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>1.8.2</version>
|
||||
<version>1.8.3</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
@ -55,7 +55,7 @@
|
||||
</build>
|
||||
<properties>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
<update.description>&c修复自动获取版本错误...</update.description>
|
||||
<update.description>&b默认使用国内源数据 添加仓库查看命令...</update.description>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
|
@ -32,7 +32,7 @@ public class CommandRepo extends BaseCommand {
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("插件源命令");
|
||||
setPossibleArguments("<add|del|clean|list> <仓库名称>");
|
||||
setPossibleArguments("<add|del|all|clean|list> <仓库名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,7 +45,8 @@ public class CommandRepo extends BaseCommand {
|
||||
case "add":
|
||||
if (args.length == 2) {
|
||||
if (YumManager.repo.addRepositories(sender, args[1])) {
|
||||
sender.sendMessage("§6仓库: §a§a源地址 " + args[1] + " 的插件信息已缓存!");
|
||||
final String reponame = YumManager.repo.getRepoCache(args[1]).name;
|
||||
sender.sendMessage("§6仓库: §a源仓库 §e" + reponame + " §a的插件信息已缓存!");
|
||||
} else {
|
||||
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或当前地址已缓存!");
|
||||
}
|
||||
@ -56,7 +57,8 @@ public class CommandRepo extends BaseCommand {
|
||||
case "del":
|
||||
if (args.length == 2) {
|
||||
if (YumManager.repo.delRepositories(sender, args[1])) {
|
||||
sender.sendMessage("§6仓库: §a源地址 " + args[1] + " 已删除 请使用 yum repo update 更新缓存!");
|
||||
final String reponame = YumManager.repo.getRepoCache(args[1]).name;
|
||||
sender.sendMessage("§6仓库: §a源仓库 §e" + reponame + " §c已删除 §a请使用 §b/yum repo update §a更新缓存!");
|
||||
} else {
|
||||
sender.sendMessage("§6仓库: §c源地址未找到!");
|
||||
}
|
||||
@ -68,6 +70,10 @@ public class CommandRepo extends BaseCommand {
|
||||
sender.sendMessage("§6仓库: §b缓存的插件信息如下 ");
|
||||
StringUtil.sendStringArray(sender, YumManager.repo.getAllPluginsInfo());
|
||||
break;
|
||||
case "all":
|
||||
sender.sendMessage("§6仓库: §b缓存的仓库信息如下 ");
|
||||
StringUtil.sendStringArray(sender, YumManager.repo.getRepoCache().getAllRepoInfo());
|
||||
break;
|
||||
case "clean":
|
||||
YumManager.repo.clean();
|
||||
sender.sendMessage("§6仓库: §a缓存的插件信息已清理!");
|
||||
@ -85,7 +91,7 @@ public class CommandRepo extends BaseCommand {
|
||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
if (args[0].equalsIgnoreCase("repo")) {
|
||||
if (args.length == 2) {
|
||||
return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add", "list", "clean", "update", "del" }), new ArrayList<String>());
|
||||
return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add", "all", "list", "clean", "update", "del" }), new ArrayList<String>());
|
||||
}
|
||||
if (args.length == 3 && (args[1] == "add" || args[1] == "del")) {
|
||||
return StringUtil.copyPartialMatches(args[2], YumManager.repo.getRepos().keySet(), new ArrayList<String>());
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.citycraft.Yum.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import cn.citycraft.PluginHelper.jsonresult.JsonResult;
|
||||
import cn.citycraft.PluginHelper.utils.IOUtil;
|
||||
@ -33,6 +36,14 @@ public class RepoCache {
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAllRepoInfo() {
|
||||
final List<String> repoinfo = new ArrayList<String>();
|
||||
for (final Entry<String, Repositories> repo : repos.entrySet()) {
|
||||
repoinfo.add(String.format("§d仓库: §e%s §6- §3%s", repo.getValue().name, repo.getKey()));
|
||||
}
|
||||
return repoinfo;
|
||||
}
|
||||
|
||||
public Map<String, PluginInfo> getPlugins() {
|
||||
return plugins;
|
||||
}
|
||||
|
@ -52,15 +52,8 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public boolean addRepositories(final CommandSender sender, final String urlstring) {
|
||||
final int urllength = urlstring.length();
|
||||
String url = urlstring.substring(0, urlstring.endsWith("/") ? urllength - 1 : urllength);
|
||||
if (!url.startsWith("http://")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
if (!url.endsWith("repo.info")) {
|
||||
url = url + "/repo.info";
|
||||
}
|
||||
final Repositories repo = repocache.addRepo(urlstring);
|
||||
final String url = handerRepoUrl(urlstring);
|
||||
final Repositories repo = repocache.addRepo(url);
|
||||
if (repo == null) {
|
||||
return false;
|
||||
}
|
||||
@ -76,7 +69,7 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public boolean delRepositories(final CommandSender sender, final String urlstring) {
|
||||
return repocache.removeRepo(urlstring);
|
||||
return repocache.removeRepo(handerRepoUrl(urlstring));
|
||||
}
|
||||
|
||||
public List<PluginInfo> getAllPlugin() {
|
||||
@ -131,10 +124,29 @@ public class RepositoryManager {
|
||||
return repocache.getPlugins();
|
||||
}
|
||||
|
||||
public RepoCache getRepoCache() {
|
||||
return repocache;
|
||||
}
|
||||
|
||||
public Repositories getRepoCache(final String urlstring) {
|
||||
return repocache.repos.get(handerRepoUrl(urlstring));
|
||||
}
|
||||
|
||||
public Map<String, Repositories> getRepos() {
|
||||
return repocache.getRepos();
|
||||
}
|
||||
|
||||
public boolean getRepositories(final CommandSender sender, final String urlstring) {
|
||||
final int urllength = urlstring.length();
|
||||
final String url = urlstring.substring(0, urlstring.endsWith("/") ? urllength - 1 : urllength);
|
||||
handerRepoUrl(url);
|
||||
final Repositories repo = repocache.addRepo(urlstring);
|
||||
if (repo == null) {
|
||||
return false;
|
||||
}
|
||||
return updateRepositories(sender, repo);
|
||||
}
|
||||
|
||||
public boolean jsonToCache(final FileConfiguration config) {
|
||||
try {
|
||||
final String reposcache = config.getString("reposcache");
|
||||
@ -176,7 +188,7 @@ public class RepositoryManager {
|
||||
public boolean updateRepositories(final CommandSender sender) {
|
||||
repocache.getPlugins().clear();
|
||||
if (repocache.getRepos().isEmpty()) {
|
||||
repocache.addRepo("http://citycraft.cn/yumcenter/repo.info");
|
||||
repocache.addRepo("https://coding.net/u/502647092/p/YumData/git/raw/master/yumcenter/repo.info");
|
||||
}
|
||||
final Iterator<Entry<String, Repositories>> keys = repocache.getRepos().entrySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
@ -204,4 +216,17 @@ public class RepositoryManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String handerRepoUrl(String url) {
|
||||
final int urllength = url.length();
|
||||
url = url.substring(0, url.endsWith("/") ? urllength - 1 : urllength);
|
||||
if (!url.startsWith("http://")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
if (!url.endsWith("repo.info")) {
|
||||
url = url + "/repo.info";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user