aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-08-12 00:40:39 -0700
committerGitHub <[email protected]>2024-08-12 09:40:39 +0200
commit1798e949e5727f376ccaee51873f21dcdedc9a5f (patch)
treee7e920956f49302975057c6e2bd580d7dec15825
parent4a97ba3ea8cb449fe76ed1aef0b572e7cc01d542 (diff)
downloadPaper-1798e949e5727f376ccaee51873f21dcdedc9a5f.tar.gz
Paper-1798e949e5727f376ccaee51873f21dcdedc9a5f.zip
Fix BasicCommand suggestion arg count (#11241)
-rw-r--r--patches/server/0971-Brigadier-based-command-API.patch12
1 files changed, 9 insertions, 3 deletions
diff --git a/patches/server/0971-Brigadier-based-command-API.patch b/patches/server/0971-Brigadier-based-command-API.patch
index 2494cfc3be..ad3eff5ecd 100644
--- a/patches/server/0971-Brigadier-based-command-API.patch
+++ b/patches/server/0971-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..da50ca4c6524e4f99ea4de2157d7ef900178d0f1
+index 0000000000000000000000000000000000000000..95d3b42cbe2184b0a04d941f27f7a6e643ef59be
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
-@@ -0,0 +1,198 @@
+@@ -0,0 +1,204 @@
+package io.papermc.paper.command.brigadier;
+
+import com.google.common.base.Preconditions;
@@ -711,6 +711,7 @@ index 0000000000000000000000000000000000000000..da50ca4c6524e4f99ea4de2157d7ef90
+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;
@@ -868,7 +869,12 @@ index 0000000000000000000000000000000000000000..da50ca4c6524e4f99ea4de2157d7ef90
+ .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);