mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-19 14:51:27 +01:00
Allow plugin aliases to override vanilla commands (#11186)
fixes #11035
This commit is contained in:
parent
5bb7bd0f66
commit
301caeb6d0
@ -699,6 +699,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+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..00000000000000000000000000000000
|
||||
+ 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());
|
||||
+ }
|
||||
|
Loading…
Reference in New Issue
Block a user