mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
add repo del...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
bf735307e8
commit
201dc9bc24
@ -45,12 +45,23 @@ public class CommandRepo extends BaseCommand {
|
|||||||
case "add":
|
case "add":
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (YumManager.repo.addRepositories(sender, args[1])) {
|
if (YumManager.repo.addRepositories(sender, args[1])) {
|
||||||
sender.sendMessage("§6仓库: §a插件信息已缓存!");
|
sender.sendMessage("§6仓库: §a§a源地址 " + args[1] + " 的插件信息已缓存!");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或无法访问!");
|
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或当前地址已缓存!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§6仓库: §c请输入源地址!");
|
sender.sendMessage("§6仓库: §c请输入需要添加的源地址!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "del":
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (YumManager.repo.delRepositories(sender, args[1])) {
|
||||||
|
sender.sendMessage("§6仓库: §a源地址 " + args[1] + " 已删除 请使用 yum repo update 更新缓存!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§6仓库: §c源地址未找到!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§6仓库: §c请输入需要删除的源地址!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "list":
|
case "list":
|
||||||
@ -73,7 +84,12 @@ public class CommandRepo extends BaseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
if (args[0].equalsIgnoreCase("repo")) {
|
if (args[0].equalsIgnoreCase("repo")) {
|
||||||
return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add", "list", "clean", "update" }), new ArrayList<String>());
|
if (args.length == 2) {
|
||||||
|
return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add", "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(), new ArrayList<String>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@ public class RepositoryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean addRepositories(final CommandSender sender, final String urlstring) {
|
public boolean addRepositories(final CommandSender sender, final String urlstring) {
|
||||||
if (urlstring.isEmpty()) {
|
final int urllength = urlstring.length();
|
||||||
|
if (urllength == 0 || repos.contains(urlstring.substring(0, urlstring.endsWith("/") ? urllength - 1 : urllength))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
repos.add(urlstring);
|
repos.add(urlstring);
|
||||||
@ -74,6 +75,14 @@ public class RepositoryManager {
|
|||||||
plugins.clear();
|
plugins.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean delRepositories(final CommandSender sender, final String urlstring) {
|
||||||
|
if (urlstring.isEmpty() || !repos.contains(urlstring)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
repos.remove(urlstring);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public List<PluginInfo> getAllPlugin() {
|
public List<PluginInfo> getAllPlugin() {
|
||||||
final List<PluginInfo> li = new ArrayList<PluginInfo>();
|
final List<PluginInfo> li = new ArrayList<PluginInfo>();
|
||||||
for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
|
for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
|
||||||
@ -137,6 +146,14 @@ public class RepositoryManager {
|
|||||||
return plugins.get(groupId + "." + artifactId);
|
return plugins.get(groupId + "." + artifactId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<String, PluginInfo> getPlugins() {
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getRepos() {
|
||||||
|
return repos;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean jsonToCache(final FileConfiguration config) {
|
public boolean jsonToCache(final FileConfiguration config) {
|
||||||
final String repocache = config.getString("repocache");
|
final String repocache = config.getString("repocache");
|
||||||
final String plugincache = config.getString("plugincache");
|
final String plugincache = config.getString("plugincache");
|
||||||
|
Loading…
Reference in New Issue
Block a user