diff --git a/src/main/java/com/mojang/brigadier/builder/RequiredArgumentBuilder.java b/src/main/java/com/mojang/brigadier/builder/RequiredArgumentBuilder.java index 694f256e..6e619d8b 100644 --- a/src/main/java/com/mojang/brigadier/builder/RequiredArgumentBuilder.java +++ b/src/main/java/com/mojang/brigadier/builder/RequiredArgumentBuilder.java @@ -5,11 +5,6 @@ import com.mojang.brigadier.tree.ArgumentCommandNode; import com.mojang.brigadier.tree.CommandNode; -import java.util.Collection; -import java.util.Collections; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; - public class RequiredArgumentBuilder extends ArgumentBuilder> { private final String name; private final ArgumentType type; @@ -30,7 +25,7 @@ public RequiredArgumentBuilder suggests(final CommandSuggestions.Provider< } public CommandSuggestions.Provider getSuggestionsProvider() { - return suggestionsProvider == null ? type::listSuggestions : suggestionsProvider; + return suggestionsProvider; } @Override diff --git a/src/main/java/com/mojang/brigadier/tree/ArgumentCommandNode.java b/src/main/java/com/mojang/brigadier/tree/ArgumentCommandNode.java index 3fa97bc6..20f8a788 100644 --- a/src/main/java/com/mojang/brigadier/tree/ArgumentCommandNode.java +++ b/src/main/java/com/mojang/brigadier/tree/ArgumentCommandNode.java @@ -21,13 +21,13 @@ public class ArgumentCommandNode extends CommandNode { private final String name; private final ArgumentType type; - private final CommandSuggestions.Provider suggestionsProvider; + private final CommandSuggestions.Provider customSuggestions; - public ArgumentCommandNode(final String name, final ArgumentType type, final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final CommandSuggestions.Provider suggestionsProvider) { + public ArgumentCommandNode(final String name, final ArgumentType type, final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final CommandSuggestions.Provider customSuggestions) { super(command, requirement, redirect, modifier); this.name = name; this.type = type; - this.suggestionsProvider = suggestionsProvider; + this.customSuggestions = customSuggestions; } public ArgumentType getType() { @@ -44,6 +44,10 @@ public String getUsageText() { return USAGE_ARGUMENT_OPEN + name + USAGE_ARGUMENT_CLOSE; } + public CommandSuggestions.Provider getCustomSuggestions() { + return customSuggestions; + } + @Override public void parse(final StringReader reader, final CommandContextBuilder contextBuilder) throws CommandSyntaxException { final int start = reader.getCursor(); @@ -56,7 +60,11 @@ public void parse(final StringReader reader, final CommandContextBuilder cont @Override public CompletableFuture> listSuggestions(final CommandContext context, final String command) { - return suggestionsProvider.getSuggestions(context, command); + if (customSuggestions == null) { + return type.listSuggestions(context, command); + } else { + return customSuggestions.getSuggestions(context, command); + } } @Override @@ -64,7 +72,7 @@ public RequiredArgumentBuilder createBuilder() { final RequiredArgumentBuilder builder = RequiredArgumentBuilder.argument(name, type); builder.requires(getRequirement()); builder.redirect(getRedirect(), getRedirectModifier()); - builder.suggests(suggestionsProvider); + builder.suggests(customSuggestions); if (getCommand() != null) { builder.executes(getCommand()); }