geforkt von Mirrors/Paper
977543c545
== AT == public net.minecraft.commands.arguments.blocks.BlockInput tag public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE public net.minecraft.server.ReloadableServerResources registryLookup public net.minecraft.server.ReloadableServerResources Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Marc Baloup <marc.baloup@laposte.net>
67 Zeilen
2.6 KiB
Diff
67 Zeilen
2.6 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,16 @@
|
|
private final RedirectModifier<S> modifier;
|
|
private final boolean forks;
|
|
private Command<S> command;
|
|
+ public CommandNode<CommandSourceStack> clientNode; // Paper - Brigadier API
|
|
+ public CommandNode<io.papermc.paper.command.brigadier.CommandSourceStack> unwrappedCached = null; // Paper - Brigadier Command API
|
|
+ public CommandNode<io.papermc.paper.command.brigadier.CommandSourceStack> wrappedCached = null; // Paper - Brigadier Command API
|
|
+ // 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 +73,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.put(Thread.currentThread(), this); // Paper - Thread Safe Vanilla Command permission checking
|
|
+ return this.requirement.test(source);
|
|
+ } finally {
|
|
+ ((CommandSourceStack) source).currentCommand.remove(Thread.currentThread()); // Paper - Thread Safe Vanilla Command permission checking
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
return this.requirement.test(source);
|
|
}
|
|
|
|
@@ -183,4 +205,11 @@
|
|
}
|
|
|
|
public abstract Collection<String> getExamples();
|
|
+ // Paper start - Brigadier Command API
|
|
+ public void clearAll() {
|
|
+ this.children.clear();
|
|
+ this.literals.clear();
|
|
+ this.arguments.clear();
|
|
+ }
|
|
+ // Paper end - Brigadier Command API
|
|
}
|