This commit is contained in:
kento2 2026-06-02 23:48:07 +02:00
parent c2aec2842a
commit 5cec83b992
34 changed files with 269 additions and 58 deletions

View file

@ -9,7 +9,7 @@ import java.util.Map;
public class BukkitCommandContext extends CommandContextImpl<CommandSender, BukkitCommandContext> {
public BukkitCommandContext(
BukkitCommandContext(
CommandSender sender,
Map<String, ParsedArgument<CommandSender, BukkitCommandContext, ?>> parsedArguments
) {

View file

@ -1,7 +1,7 @@
package de.kentoj.kencommandapi;
import de.kentoj.kencommandapi.api.KenCommandApi;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

View file

@ -2,7 +2,7 @@ package de.kentoj.kencommandapi;
import de.kentoj.kencommandapi.api.processing.CommandException;
import de.kentoj.kencommandapi.api.processing.ParsedArgument;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.impl.AbstractKenCommandApi;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;

View file

@ -0,0 +1,21 @@
package de.kentoj.kencommandapi.suggestionprovider;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.argument.SuggestionProvider;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class PlayerSuggestionProvider implements SuggestionProvider<CommandSender, BukkitCommandContext> {
@Override
public CompletableFuture<Set<String>> suggest(BukkitCommandContext context) {
var list = Bukkit.getOnlinePlayers().stream()
.map(Player::getName)
.collect(Collectors.toSet());
return CompletableFuture.completedFuture(list);
}
}

View file

@ -2,9 +2,10 @@ package de.kentoj.kencommandapi.type;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.processing.CommandException;
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider;
import de.kentoj.kencommandapi.api.argument.ArgumentType;
import de.kentoj.kencommandapi.api.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.argument.suggestion.NoSuggestionProvider;
import de.kentoj.kencommandapi.suggestionprovider.PlayerSuggestionProvider;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -12,7 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import java.util.Set;
import java.util.UUID;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@ -38,6 +38,6 @@ public class OfflinePlayerArgumentType implements ArgumentType<CommandSender, Bu
@Override
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
return new NoSuggestionProvider<>();
return new PlayerSuggestionProvider();
}
}

View file

@ -2,9 +2,10 @@ package de.kentoj.kencommandapi.type;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.processing.CommandException;
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider;
import de.kentoj.kencommandapi.api.argument.ArgumentType;
import de.kentoj.kencommandapi.api.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.argument.suggestion.NoSuggestionProvider;
import de.kentoj.kencommandapi.suggestionprovider.PlayerSuggestionProvider;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -13,6 +14,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PlayerArgumentType implements ArgumentType<CommandSender, BukkitCommandContext, Player> {
@ -29,6 +31,6 @@ public class PlayerArgumentType implements ArgumentType<CommandSender, BukkitCom
@Override
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
return new NoSuggestionProvider<>();
return new PlayerSuggestionProvider();
}
}