Plugin updater refactor, made async
This commit is contained in:
parent
3e0a49659d
commit
4b55c76fd5
1 changed files with 14 additions and 15 deletions
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
|
import buttondevteam.lib.PluginUpdater;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
|
||||||
public class UpdatePlugin extends AdminCommandBase {
|
public class UpdatePlugin extends AdminCommandBase {
|
||||||
|
@ -20,23 +21,21 @@ public class UpdatePlugin extends AdminCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage("Downloading plugin names...");
|
sender.sendMessage("Downloading plugin names...");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (String plugin : TBMCCoreAPI.GetPluginNames()) {
|
for (String plugin : PluginUpdater.GetPluginNames()) {
|
||||||
if (first) {
|
if (first) {
|
||||||
sender.sendMessage("§6---- Plugin names ----");
|
sender.sendMessage("§6---- Plugin names ----");
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
sender.sendMessage("- " + plugin);
|
sender.sendMessage("- " + plugin);
|
||||||
}
|
}
|
||||||
return true;
|
} else
|
||||||
} else {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
|
|
||||||
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue