fix tab completion

This commit is contained in:
2024-01-20 14:47:23 -06:00
parent 86358e49b8
commit d2b524c259
16 changed files with 171 additions and 24 deletions
@@ -6,10 +6,12 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
@@ -70,4 +72,26 @@ public class EnchantCommand extends PlexCommand
{
return getEnchantments(item).stream().map(enchantment -> enchantment.key().value()).toArray(String[]::new);
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
if (silentCheckPermission(sender, this.getPermission()))
{
if (args.length == 1)
{
return Arrays.asList("add", "reset", "list", "addall", "remove");
}
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))
{
Player player = Bukkit.getPlayer(sender.getName());
if (player != null)
{
return List.of(getEnchantmentNames(player.getActiveItem()));
}
}
return Collections.emptyList();
}
return Collections.emptyList();
}
}