aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPieter Svenson <[email protected]>2024-09-16 12:02:12 -0700
committerGitHub <[email protected]>2024-09-16 21:02:12 +0200
commite61b73f740bfd4ac2f284d586b8d5e4f1862f6df (patch)
treeedb270b115205f13005eb30f76dde5aa8e47e48c
parent6e71f415369e35558450f015cfcc2d2db1c0e064 (diff)
downloadPaper-e61b73f740bfd4ac2f284d586b8d5e4f1862f6df.tar.gz
Paper-e61b73f740bfd4ac2f284d586b8d5e4f1862f6df.zip
Fix BasicCommand suggestion arg count
Resolves: #11211 Backport-of: #11241
-rw-r--r--patches/server/1042-Brigadier-based-command-API.patch12
1 files changed, 9 insertions, 3 deletions
diff --git a/patches/server/1042-Brigadier-based-command-API.patch b/patches/server/1042-Brigadier-based-command-API.patch
index f94956ca8f..bfcbe9db15 100644
--- a/patches/server/1042-Brigadier-based-command-API.patch
+++ b/patches/server/1042-Brigadier-based-command-API.patch
@@ -686,10 +686,10 @@ index 0000000000000000000000000000000000000000..1b1642f306771f029e6214a2e2ebebb6
+}
diff --git a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
new file mode 100644
-index 0000000000000000000000000000000000000000..27509813a90980be1dfc7bde27d0eba60adfc820
+index 0000000000000000000000000000000000000000..c0d2268c6f79bad107a490f8fa1c746a6a96b573
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
-@@ -0,0 +1,193 @@
+@@ -0,0 +1,199 @@
+package io.papermc.paper.command.brigadier;
+
+import com.google.common.base.Preconditions;
@@ -710,6 +710,7 @@ index 0000000000000000000000000000000000000000..27509813a90980be1dfc7bde27d0eba6
+import java.util.Locale;
+import java.util.Set;
+import net.minecraft.commands.CommandBuildContext;
++import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
+import org.checkerframework.checker.nullness.qual.NonNull;
@@ -863,7 +864,12 @@ index 0000000000000000000000000000000000000000..27509813a90980be1dfc7bde27d0eba6
+ .then(
+ Commands.argument("args", StringArgumentType.greedyString())
+ .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 Collection<String> suggestions = basicCommand.suggest(context.getSource(), args);