修复删除仓库时报错的问题...

Signed-off-by: 502647092 <jtb1@163.com>
dev
502647092 2015-11-25 20:44:29 +08:00
parent 6e766313d6
commit e25207247c
1 changed files with 10 additions and 4 deletions

View File

@ -15,6 +15,7 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.PluginHelper.utils.StringUtil;
import cn.citycraft.Yum.Yum;
import cn.citycraft.Yum.api.YumAPI;
import cn.citycraft.Yum.manager.RepoSerialization.Repositories;
/**
*
@ -56,9 +57,10 @@ public class CommandRepo extends BaseCommand {
break;
case "del":
if (args.length == 2) {
if (YumAPI.repo.delRepositories(sender, args[1])) {
final String reponame = YumAPI.repo.getRepoCache(args[1]).name;
sender.sendMessage("§6仓库: §a源仓库 §e" + reponame + " §c已删除 §a请使用 §b/yum repo update §a更新缓存!");
final Repositories delrepo = YumAPI.repo.getRepoCache(args[1]);
if (delrepo != null) {
YumAPI.repo.delRepositories(sender, args[1]);
sender.sendMessage("§6仓库: §a源仓库 §e" + delrepo.name + " §c已删除 §a请使用 §b/yum repo update §a更新缓存!");
} else {
sender.sendMessage("§6仓库: §c源地址未找到!");
}
@ -66,6 +68,10 @@ public class CommandRepo extends BaseCommand {
sender.sendMessage("§6仓库: §c请输入需要删除的源地址!");
}
break;
case "delall":
YumAPI.repo.getRepoCache().getRepos().clear();
sender.sendMessage("§6仓库: §a缓存的仓库信息已清理!");
break;
case "list":
sender.sendMessage("§6仓库: §b缓存的插件信息如下 ");
StringUtil.sendStringArray(sender, YumAPI.repo.getAllPluginsInfo());
@ -91,7 +97,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", "all", "list", "clean", "update", "del" }), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add", "all", "list", "delall", "clean", "update", "del" }), new ArrayList<String>());
}
if (args.length == 3 && (args[1] == "add" || args[1] == "del")) {
return StringUtil.copyPartialMatches(args[2], YumAPI.repo.getRepos().keySet(), new ArrayList<String>());