Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Expose suggestions API
Dieser Commit ist enthalten in:
Ursprung
00ed2284ec
Commit
9bb374a4fe
@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.command;
|
package com.velocitypowered.api.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -112,6 +114,25 @@ public interface CommandManager {
|
|||||||
*/
|
*/
|
||||||
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
|
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns suggestions to fill in the given command.
|
||||||
|
*
|
||||||
|
* @param source the source to execute the command for
|
||||||
|
* @param cmdLine the partially completed command
|
||||||
|
* @return a {@link CompletableFuture} eventually completed with a {@link List}, possibly empty
|
||||||
|
*/
|
||||||
|
CompletableFuture<List<String>> offerSuggestions(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns suggestions to fill in the given command.
|
||||||
|
*
|
||||||
|
* @param source the source to execute the command for
|
||||||
|
* @param cmdLine the partially completed command
|
||||||
|
* @return a {@link CompletableFuture} eventually completed with {@link Suggestions}, possibly
|
||||||
|
* empty
|
||||||
|
*/
|
||||||
|
CompletableFuture<Suggestions> offerBrigadierSuggestions(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an immutable collection of the case-insensitive aliases registered
|
* Returns an immutable collection of the case-insensitive aliases registered
|
||||||
* on this manager.
|
* on this manager.
|
||||||
|
@ -279,27 +279,14 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
() -> executeImmediately0(source, cmdLine), eventManager.getAsyncExecutor());
|
() -> executeImmediately0(source, cmdLine), eventManager.getAsyncExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns suggestions to fill in the given command.
|
|
||||||
*
|
|
||||||
* @param source the source to execute the command for
|
|
||||||
* @param cmdLine the partially completed command
|
|
||||||
* @return a {@link CompletableFuture} eventually completed with a {@link List}, possibly empty
|
|
||||||
*/
|
|
||||||
public CompletableFuture<List<String>> offerSuggestions(final CommandSource source,
|
public CompletableFuture<List<String>> offerSuggestions(final CommandSource source,
|
||||||
final String cmdLine) {
|
final String cmdLine) {
|
||||||
return offerBrigadierSuggestions(source, cmdLine)
|
return offerBrigadierSuggestions(source, cmdLine)
|
||||||
.thenApply(suggestions -> Lists.transform(suggestions.getList(), Suggestion::getText));
|
.thenApply(suggestions -> Lists.transform(suggestions.getList(), Suggestion::getText));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns suggestions to fill in the given command.
|
|
||||||
*
|
|
||||||
* @param source the source to execute the command for
|
|
||||||
* @param cmdLine the partially completed command
|
|
||||||
* @return a {@link CompletableFuture} eventually completed with {@link Suggestions}, possibly
|
|
||||||
* empty
|
|
||||||
*/
|
|
||||||
public CompletableFuture<Suggestions> offerBrigadierSuggestions(
|
public CompletableFuture<Suggestions> offerBrigadierSuggestions(
|
||||||
final CommandSource source, final String cmdLine) {
|
final CommandSource source, final String cmdLine) {
|
||||||
Preconditions.checkNotNull(source, "source");
|
Preconditions.checkNotNull(source, "source");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren