mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
complete repo manager...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
de111b8f80
commit
7ebc9167b9
@ -59,7 +59,14 @@ public class RepositoryManager {
|
|||||||
|
|
||||||
public boolean addRepositories(final CommandSender sender, final String urlstring) {
|
public boolean addRepositories(final CommandSender sender, final String urlstring) {
|
||||||
final int urllength = urlstring.length();
|
final int urllength = urlstring.length();
|
||||||
if (urllength == 0 || repos.contains(urlstring.substring(0, urlstring.endsWith("/") ? urllength - 1 : urllength))) {
|
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";
|
||||||
|
}
|
||||||
|
if (urllength == 0 || repos.contains(url)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
repos.add(urlstring);
|
repos.add(urlstring);
|
||||||
@ -202,6 +209,9 @@ public class RepositoryManager {
|
|||||||
|
|
||||||
public boolean updateRepositories(final CommandSender sender) {
|
public boolean updateRepositories(final CommandSender sender) {
|
||||||
plugins.clear();
|
plugins.clear();
|
||||||
|
if (repos.isEmpty()) {
|
||||||
|
repos.add("http://citycraft.cn/repo/repo.info");
|
||||||
|
}
|
||||||
for (final String string : repos) {
|
for (final String string : repos) {
|
||||||
if (updateRepositories(sender, string)) {
|
if (updateRepositories(sender, string)) {
|
||||||
sender.sendMessage("§6源: §e" + string + " §a更新成功!");
|
sender.sendMessage("§6源: §e" + string + " §a更新成功!");
|
||||||
@ -212,15 +222,14 @@ public class RepositoryManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateRepositories(CommandSender sender, String urlstring) {
|
public boolean updateRepositories(CommandSender sender, final String urlstring) {
|
||||||
if (sender == null) {
|
if (sender == null) {
|
||||||
sender = Bukkit.getConsoleSender();
|
sender = Bukkit.getConsoleSender();
|
||||||
}
|
}
|
||||||
if (!urlstring.endsWith("repo.info")) {
|
|
||||||
urlstring = urlstring + "/repo.info";
|
|
||||||
}
|
|
||||||
final String json = getHtml(urlstring);
|
final String json = getHtml(urlstring);
|
||||||
if (json == null || json.isEmpty()) {
|
if (json == null || json.isEmpty()) {
|
||||||
|
sender.sendMessage("§6源: §e" + urlstring + " §c未找到任何仓库信息 已删除!");
|
||||||
|
repos.remove(urlstring);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final List<Repository> lrepo = jsonToRepositories(json);
|
final List<Repository> lrepo = jsonToRepositories(json);
|
||||||
|
Loading…
Reference in New Issue
Block a user