Skip to content

Commit

Permalink
Fix tab complete /is invite
Browse files Browse the repository at this point in the history
Euphillya committed Jan 5, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3d69568 commit d0b29b9
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -22,9 +22,11 @@
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class InviteSubCommand implements SubCommandInterface {

@@ -76,11 +78,13 @@ public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender,
@Override
public @NotNull List<String> onTabComplete(@NotNull Plugin plugin, @NotNull CommandSender sender, @NotNull String[] args) {
if (args.length == 1) {
List<String> possible = List.of("accept", "decline", "delete");
String partial = args[0].trim().toLowerCase();
return possible.stream()
.filter(cmd -> cmd.toLowerCase().startsWith(partial))
.collect(Collectors.toList());
return Stream.concat(
Stream.of("accept", "decline", "delete"),
Bukkit.getOnlinePlayers()
.stream()
.map(Player::getName)
).filter(cmd -> cmd.toLowerCase().startsWith(partial)).collect(Collectors.toList());
} else if (args.length == 2) {
String partial = args[1].trim().toLowerCase();

0 comments on commit d0b29b9

Please sign in to comment.