--- 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 implements Comparable> { private final Map> children = new LinkedHashMap<>(); @@ -32,6 +34,13 @@ private final RedirectModifier modifier; private final boolean forks; private Command 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 command, final Predicate requirement, final CommandNode redirect, final RedirectModifier 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); }