aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason Penilla <[email protected]>2024-07-28 12:14:46 -0700
committerJason Penilla <[email protected]>2024-07-28 12:14:57 -0700
commit68d2313bb05ce5d4abb0bc0080737f735d3e6bf0 (patch)
treeb81f012df73def0b08a9828e54887dcd2256e2a4
parentf82bea6940086218a280eba23a4c2ce373921c2f (diff)
downloadPaper-68d2313bb05ce5d4abb0bc0080737f735d3e6bf0.tar.gz
Paper-68d2313bb05ce5d4abb0bc0080737f735d3e6bf0.zip
Preserve command node when re-registering modern commands through old API
-rw-r--r--patches/server/0972-Brigadier-based-command-API.patch12
1 files changed, 9 insertions, 3 deletions
diff --git a/patches/server/0972-Brigadier-based-command-API.patch b/patches/server/0972-Brigadier-based-command-API.patch
index d98a2a98c3..c50682758a 100644
--- a/patches/server/0972-Brigadier-based-command-API.patch
+++ b/patches/server/0972-Brigadier-based-command-API.patch
@@ -1504,10 +1504,10 @@ index 0000000000000000000000000000000000000000..c59bbd90fdf04db837366218b312e7fb
+}
diff --git a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitBrigForwardingMap.java b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitBrigForwardingMap.java
new file mode 100644
-index 0000000000000000000000000000000000000000..f0cc27640bb3db275295a298d608c9d9f88df617
+index 0000000000000000000000000000000000000000..46213c0d7ea777f829d6da6ea4ebe2620d5dce8c
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitBrigForwardingMap.java
-@@ -0,0 +1,332 @@
+@@ -0,0 +1,338 @@
+package io.papermc.paper.command.brigadier.bukkit;
+
+import com.google.common.collect.Iterators;
@@ -1530,6 +1530,7 @@ index 0000000000000000000000000000000000000000..f0cc27640bb3db275295a298d608c9d9
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+import org.bukkit.command.Command;
++import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@@ -1600,12 +1601,17 @@ index 0000000000000000000000000000000000000000..f0cc27640bb3db275295a298d608c9d9
+ return PaperBrigadier.wrapNode(node);
+ }
+
++ @SuppressWarnings({"unchecked", "rawtypes"})
+ @Nullable
+ @Override
+ public Command put(String key, Command value) {
+ Command old = this.get(key);
+ this.getDispatcher().getRoot().removeCommand(key); // Override previous command
-+ this.getDispatcher().getRoot().addChild(BukkitCommandNode.of(key, value));
++ if (value instanceof VanillaCommandWrapper wrapper) {
++ this.getDispatcher().getRoot().addChild((CommandNode) wrapper.vanillaCommand);
++ } else {
++ this.getDispatcher().getRoot().addChild(BukkitCommandNode.of(key, value));
++ }
+ return old;
+ }
+