mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2026-06-05 15:56:54 +00:00
fix tab completion
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user