From 4b55c76fd5c013a52569c04e01014bcf01bf1a55 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 23 Jun 2017 19:33:52 +0200 Subject: [PATCH] Plugin updater refactor, made async --- .../commands/ucmds/admin/UpdatePlugin.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java index 1cfde5a..b60690e 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java @@ -4,6 +4,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import buttondevteam.chat.PluginMain; +import buttondevteam.lib.PluginUpdater; import buttondevteam.lib.TBMCCoreAPI; public class UpdatePlugin extends AdminCommandBase { @@ -20,23 +21,21 @@ public class UpdatePlugin extends AdminCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { - if (args.length == 0) { - sender.sendMessage("Downloading plugin names..."); - boolean first = true; - for (String plugin : TBMCCoreAPI.GetPluginNames()) { - if (first) { - sender.sendMessage("§6---- Plugin names ----"); - first = false; + Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { + if (args.length == 0) { + sender.sendMessage("Downloading plugin names..."); + boolean first = true; + for (String plugin : PluginUpdater.GetPluginNames()) { + if (first) { + sender.sendMessage("§6---- Plugin names ----"); + first = false; + } + sender.sendMessage("- " + plugin); } - sender.sendMessage("- " + plugin); - } - return true; - } else { - Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { + } else TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]); - }); - return true; - } + }); + return true; } }