aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason Penilla <[email protected]>2024-07-28 13:19:38 -0700
committerJason Penilla <[email protected]>2024-07-28 13:19:38 -0700
commita3929f76d622b8a2718cf0ae00a60638fe7f321e (patch)
treeb1b390d1f63756833e9997dff844069be4cfbb38
parentf82bea6940086218a280eba23a4c2ce373921c2f (diff)
downloadPaper-fix/vanilla-command-overriding.tar.gz
Paper-fix/vanilla-command-overriding.zip
Allow plugin aliases to override vanilla commandsfix/vanilla-command-overriding
fixes #11035
-rw-r--r--patches/server/0972-Brigadier-based-command-API.patch14
1 files changed, 9 insertions, 5 deletions
diff --git a/patches/server/0972-Brigadier-based-command-API.patch b/patches/server/0972-Brigadier-based-command-API.patch
index d98a2a98c3..4edd28ec6c 100644
--- a/patches/server/0972-Brigadier-based-command-API.patch
+++ b/patches/server/0972-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..a3e128bde0fa4ab0ecab4172f02288a29b9fddc7
+index 0000000000000000000000000000000000000000..da50ca4c6524e4f99ea4de2157d7ef900178d0f1
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
-@@ -0,0 +1,194 @@
+@@ -0,0 +1,198 @@
+package io.papermc.paper.command.brigadier;
+
+import com.google.common.base.Preconditions;
@@ -699,6 +699,7 @@ index 0000000000000000000000000000000000000000..a3e128bde0fa4ab0ecab4172f02288a2
+import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import com.mojang.brigadier.tree.CommandNode;
+import com.mojang.brigadier.tree.LiteralCommandNode;
++import io.papermc.paper.command.brigadier.bukkit.BukkitCommandNode;
+import io.papermc.paper.plugin.configuration.PluginMeta;
+import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner;
+import io.papermc.paper.plugin.lifecycle.event.registrar.PaperRegistrar;
@@ -839,9 +840,12 @@ index 0000000000000000000000000000000000000000..a3e128bde0fa4ab0ecab4172f02288a2
+ return this.registerIntoDispatcher(new PluginCommandNode(aliasLiteral, plugin, redirect, description), override);
+ }
+
-+ private boolean registerIntoDispatcher(final PluginCommandNode node, final boolean override) {
-+ final boolean hasChild = this.getDispatcher().getRoot().getChild(node.getLiteral()) != null;
-+ if (!hasChild || override) { // Avoid merging behavior. Maybe something to look into in the future
++ private boolean registerIntoDispatcher(final PluginCommandNode node, boolean override) {
++ final @Nullable CommandNode<CommandSourceStack> existingChild = this.getDispatcher().getRoot().getChild(node.getLiteral());
++ if (existingChild != null && !(existingChild instanceof PluginCommandNode) && !(existingChild instanceof BukkitCommandNode)) {
++ override = true; // override vanilla commands
++ }
++ if (existingChild == null || override) { // Avoid merging behavior. Maybe something to look into in the future
+ if (override) {
+ this.getDispatcher().getRoot().removeCommand(node.getLiteral());
+ }