Skip to content

Commit c6f99db

Browse files
added a tabcomplete for the PLAYER argument type
1 parent f8d878e commit c6f99db

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/com/datasiqn/commandcore/argument/type/PlayerArgumentType.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.datasiqn.commandcore.argument.type;
22

3+
import com.datasiqn.commandcore.command.CommandContext;
34
import com.datasiqn.resultapi.None;
45
import com.datasiqn.resultapi.Result;
56
import org.bukkit.Bukkit;
67
import org.bukkit.entity.Player;
78
import org.jetbrains.annotations.NotNull;
89

10+
import java.util.List;
11+
import java.util.stream.Collectors;
12+
913
class PlayerArgumentType implements SimpleArgumentType<Player> {
1014
@Override
1115
public @NotNull String getTypeName() {
@@ -16,4 +20,9 @@ class PlayerArgumentType implements SimpleArgumentType<Player> {
1620
public @NotNull Result<Player, None> parseWord(String word) {
1721
return Result.ofNullable(Bukkit.getPlayerExact(word), None.NONE);
1822
}
23+
24+
@Override
25+
public @NotNull List<String> getTabComplete(@NotNull CommandContext context) {
26+
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
27+
}
1928
}

0 commit comments

Comments
 (0)