From fb7a3ec99d103a2acbd3859d0672e98db18bd322 Mon Sep 17 00:00:00 2001 From: Sxtanna Date: Sat, 25 Jul 2020 12:55:07 -0400 Subject: [PATCH] added tab completion to the update command --- .../commands/impl/cloud/CommandECloudUpdate.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java index 7f056ee..9d9399c 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java @@ -1,5 +1,6 @@ package me.clip.placeholderapi.commands.impl.cloud; +import com.google.common.collect.Lists; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.commands.PlaceholderCommand; import me.clip.placeholderapi.expansion.PlaceholderExpansion; @@ -96,7 +97,20 @@ public final class CommandECloudUpdate extends PlaceholderCommand @Override public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List params, @NotNull final List suggestions) { + if (params.size() > 1) + { + return; + } + final List installed = Lists.newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values()); + installed.removeIf(expansion -> !expansion.shouldUpdate()); + + if (!installed.isEmpty() && (params.isEmpty() || "all".startsWith(params.get(0).toLowerCase()))) + { + suggestions.add("all"); + } + + suggestByParameter(installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")), suggestions, params.isEmpty() ? null : params.get(0)); }