Skip to content

Commit

Permalink
Update Tabcompletion for the repalace command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasenzahn1 committed Mar 30, 2024
1 parent 635ff54 commit a528f72
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -110,17 +107,19 @@ public void run() {
}

@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
public @Nullable List<String> 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());
}
if (strings.length == 2) {
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());
}
Expand Down

0 comments on commit a528f72

Please sign in to comment.