mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix BasicCommand suggestion arg count (#11241)
This commit is contained in:
parent
dada30ee8a
commit
23550ec960
1 changed files with 7 additions and 1 deletions
|
@ -711,6 +711,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import java.util.Locale;
|
+import java.util.Locale;
|
||||||
+import java.util.Set;
|
+import java.util.Set;
|
||||||
+import net.minecraft.commands.CommandBuildContext;
|
+import net.minecraft.commands.CommandBuildContext;
|
||||||
|
+import org.apache.commons.lang3.ArrayUtils;
|
||||||
+import org.apache.commons.lang3.StringUtils;
|
+import org.apache.commons.lang3.StringUtils;
|
||||||
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
@ -868,7 +869,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ .then(
|
+ .then(
|
||||||
+ Commands.argument("args", StringArgumentType.greedyString())
|
+ Commands.argument("args", StringArgumentType.greedyString())
|
||||||
+ .suggests((context, suggestionsBuilder) -> {
|
+ .suggests((context, suggestionsBuilder) -> {
|
||||||
+ final String[] args = StringUtils.split(suggestionsBuilder.getRemaining());
|
+ String[] args = StringUtils.split(suggestionsBuilder.getRemaining());
|
||||||
|
+ if (suggestionsBuilder.getRemaining().endsWith(" ")) {
|
||||||
|
+ // if there is trailing whitespace, we should add an empty argument to signify
|
||||||
|
+ // that there may be more, but no characters have been typed yet
|
||||||
|
+ args = ArrayUtils.add(args, "");
|
||||||
|
+ }
|
||||||
+ final SuggestionsBuilder offsetSuggestionsBuilder = suggestionsBuilder.createOffset(suggestionsBuilder.getInput().lastIndexOf(' ') + 1);
|
+ final SuggestionsBuilder offsetSuggestionsBuilder = suggestionsBuilder.createOffset(suggestionsBuilder.getInput().lastIndexOf(' ') + 1);
|
||||||
+
|
+
|
||||||
+ final Collection<String> suggestions = basicCommand.suggest(context.getSource(), args);
|
+ final Collection<String> suggestions = basicCommand.suggest(context.getSource(), args);
|
||||||
|
|
Loading…
Reference in a new issue