Use API method to create offset command completions

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2018-12-28 10:34:51 +11:00
parent cf4055b264
commit adabfc807a

View file

@ -48,9 +48,8 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandListenerWrapper> context, SuggestionsBuilder builder) throws CommandSyntaxException { public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandListenerWrapper> context, SuggestionsBuilder builder) throws CommandSyntaxException {
List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getWorld(), context.getSource().getPosition(), true); List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getWorld(), context.getSource().getPosition(), true);
// These are normally only set based on sub nodes, but we have just one giant args node // Defaults to sub nodes, but we have just one giant args node, so offset accordingly
builder.start = builder.getInput().lastIndexOf(' ') + 1; builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1);
builder.remaining = builder.getInput().substring(builder.start);
for (String s : results) { for (String s : results) {
builder.suggest(s); builder.suggest(s);