Add async command suggestions
This commit is contained in:
@@ -2,6 +2,7 @@ package com.velocitypowered.api.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,18 @@ public interface Command {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides tab complete suggestions for a command for a specified {@link CommandSource}.
|
||||
*
|
||||
* @param source the source to run the command for
|
||||
* @param currentArgs the current, partial arguments for this command
|
||||
* @return tab complete suggestions
|
||||
*/
|
||||
default CompletableFuture<List<String>> suggestAsync(CommandSource source,
|
||||
String @NonNull [] currentArgs) {
|
||||
return CompletableFuture.completedFuture(suggest(source, currentArgs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to check if the {@code source} has permission to use this command with the provided
|
||||
* {@code args}.
|
||||
|
@@ -2,6 +2,7 @@ package com.velocitypowered.api.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
@@ -29,13 +30,19 @@ public interface RawCommand extends Command {
|
||||
* @param currentLine the current, partial command line for this command
|
||||
* @return tab complete suggestions
|
||||
*/
|
||||
default List<String> suggest(CommandSource source, String currentLine) {
|
||||
return ImmutableList.of();
|
||||
default CompletableFuture<List<String>> suggest(CommandSource source, String currentLine) {
|
||||
return CompletableFuture.completedFuture(ImmutableList.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
default CompletableFuture<List<String>> suggestAsync(CommandSource source,
|
||||
String @NonNull [] currentArgs) {
|
||||
return suggest(source, String.join(" ", currentArgs));
|
||||
}
|
||||
|
||||
@Override
|
||||
default List<String> suggest(CommandSource source, String @NonNull [] currentArgs) {
|
||||
return suggest(source, String.join(" ", currentArgs));
|
||||
return suggestAsync(source, currentArgs).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user