From a528f72e97dfd88fd9d7c71f2b06905709956f50 Mon Sep 17 00:00:00 2001 From: Hasenzahn1 Date: Sat, 30 Mar 2024 23:52:07 +0100 Subject: [PATCH] Update Tabcompletion for the repalace command. --- .../commands/ReplaceCustomBlocksCommand.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/canstein_berlin/customblocksapi/commands/ReplaceCustomBlocksCommand.java b/src/main/java/de/canstein_berlin/customblocksapi/commands/ReplaceCustomBlocksCommand.java index b039e2e..9c57b53 100644 --- a/src/main/java/de/canstein_berlin/customblocksapi/commands/ReplaceCustomBlocksCommand.java +++ b/src/main/java/de/canstein_berlin/customblocksapi/commands/ReplaceCustomBlocksCommand.java @@ -25,10 +25,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; public class ReplaceCustomBlocksCommand implements CommandExecutor, TabExecutor { @@ -110,10 +107,11 @@ public void run() { } @Override - public @Nullable List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { + public @Nullable List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, @NotNull String[] strings) { if (strings.length == 1) { return Arrays.stream(Material.values()) .map(Material::name) + .filter(s -> s.toLowerCase(Locale.ROOT).startsWith(strings[0].toLowerCase())) .sorted() .collect(Collectors.toList()); } @@ -121,6 +119,7 @@ public void run() { return CustomBlocksApi.getInstance().getAllCustomBlocks().stream() .map(CustomBlock::getKey) .map(NamespacedKey::asString) + .filter(s -> s.toLowerCase(Locale.ROOT).startsWith(strings[1].toLowerCase())) .sorted() .collect(Collectors.toList()); }