run repo command async...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-10-02 21:26:47 +08:00
parent 0f3aa5f0de
commit f1b5551cf2
2 changed files with 37 additions and 28 deletions

View File

@ -64,8 +64,8 @@
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>citycraft-repo</id> <id>sumcraft-repo</id>
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url> <url>http://ci.sumcraft.net:8080/plugin/repository/everything/</url>
</repository> </repository>
<repository> <repository>
<id>Plugin Metrics</id> <id>Plugin Metrics</id>
@ -77,7 +77,7 @@
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<type>jar</type> <type>jar</type>
<version>1.8.3-R0.1-SNAPSHOT</version> <version>1.8.8-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.citycraft</groupId> <groupId>cn.citycraft</groupId>

View File

@ -37,38 +37,47 @@ public class CommandRepo extends BaseCommand {
@Override @Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException { public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final String cmd = args[0]; main.getServer().getScheduler().runTaskAsynchronously(main, new Runnable() {
switch (cmd) { @Override
case "add": public void run() {
if (args.length == 2) { final String cmd = args[0];
if (YumManager.repo.addRepositories(sender, args[1])) { switch (cmd) {
sender.sendMessage("§6仓库: §a插件信息已缓存!"); case "add":
} else { if (args.length == 2) {
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或无法访问!"); if (YumManager.repo.addRepositories(sender, args[1])) {
sender.sendMessage("§6仓库: §a插件信息已缓存!");
} else {
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或无法访问!");
}
} else {
sender.sendMessage("§6仓库: §c请输入源地址!");
}
break;
case "list":
sender.sendMessage("§6仓库: §b缓存的插件信息如下 ");
StringUtil.sendStringArray(sender, YumManager.repo.getAllPluginsInfo());
break;
case "clean":
YumManager.repo.clean();
sender.sendMessage("§6仓库: §a缓存的插件信息已清理!");
break;
case "update":
YumManager.repo.updateRepositories(sender);
sender.sendMessage("§6仓库: §a仓库缓存数据已更新!");
break;
} }
} else {
sender.sendMessage("§6仓库: §c请输入源地址!");
} }
break; });
case "list":
sender.sendMessage("§6仓库: §b缓存的插件信息如下 ");
StringUtil.sendStringArray(sender, YumManager.repo.getAllPluginsInfo());
break;
case "clean":
YumManager.repo.clean();
sender.sendMessage("§6仓库: §a缓存的插件信息已清理!");
break;
case "update":
YumManager.repo.updateRepositories(sender);
sender.sendMessage("§6仓库: §a仓库缓存数据已更新!");
break;
}
} }
@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>()); return StringUtil.copyPartialMatches(args[1], Arrays.asList(new String[] { "add",
"list",
"clean",
"update" }),
new ArrayList<String>());
} }
return null; return null;
} }