mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 10:11:29 +01:00
30e4583dbe
By: Initial Source <noreply+automated@papermc.io>
51 lines
1.8 KiB
Diff
51 lines
1.8 KiB
Diff
--- a/com/mojang/brigadier/tree/CommandNode.java
|
|
+++ b/com/mojang/brigadier/tree/CommandNode.java
|
|
@@ -3,6 +3,7 @@
|
|
|
|
package com.mojang.brigadier.tree;
|
|
|
|
+// CHECKSTYLE:OFF
|
|
import com.mojang.brigadier.AmbiguityConsumer;
|
|
import com.mojang.brigadier.Command;
|
|
import com.mojang.brigadier.RedirectModifier;
|
|
@@ -22,6 +23,7 @@
|
|
import java.util.Set;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.function.Predicate;
|
|
+import net.minecraft.commands.CommandSourceStack;
|
|
|
|
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
|
private final Map<String, CommandNode<S>> children = new LinkedHashMap<>();
|
|
@@ -32,6 +34,13 @@
|
|
private final RedirectModifier<S> modifier;
|
|
private final boolean forks;
|
|
private Command<S> command;
|
|
+ // CraftBukkit start
|
|
+ public void removeCommand(String name) {
|
|
+ this.children.remove(name);
|
|
+ this.literals.remove(name);
|
|
+ this.arguments.remove(name);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
|
this.command = command;
|
|
@@ -61,7 +70,17 @@
|
|
return this.modifier;
|
|
}
|
|
|
|
- public boolean canUse(final S source) {
|
|
+ // CraftBukkit start
|
|
+ public synchronized boolean canUse(final S source) {
|
|
+ if (source instanceof CommandSourceStack) {
|
|
+ try {
|
|
+ ((CommandSourceStack) source).currentCommand = this;
|
|
+ return this.requirement.test(source);
|
|
+ } finally {
|
|
+ ((CommandSourceStack) source).currentCommand = null;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
return this.requirement.test(source);
|
|
}
|
|
|