Move CraftBukkit per-file patches

By: Initial <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot 2024-12-11 22:26:36 +01:00
parent a4de181b77
commit a265d64138
583 changed files with 71 additions and 857 deletions

View file

@ -0,0 +1,19 @@
--- a/com/mojang/brigadier/CommandDispatcher.java
+++ b/com/mojang/brigadier/CommandDispatcher.java
@@ -3,6 +3,7 @@
package com.mojang.brigadier;
+// CHECKSTYLE:OFF
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.CommandContextBuilder;
@@ -538,7 +539,7 @@
for (final CommandNode<S> node : parent.getChildren()) {
CompletableFuture<Suggestions> future = Suggestions.empty();
try {
- future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start));
+ if (node.canUse(parse.getContext().getSource())) future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start)); // CraftBukkit
} catch (final CommandSyntaxException ignored) {
}
futures[i++] = future;

View file

@ -0,0 +1,52 @@
--- 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;
@@ -23,6 +24,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
+import net.minecraft.commands.CommandListenerWrapper; // CraftBukkit
+
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
private final Map<String, CommandNode<S>> children = new LinkedHashMap<>();
private final Map<String, LiteralCommandNode<S>> literals = new LinkedHashMap<>();
@@ -32,6 +35,13 @@
private final RedirectModifier<S> modifier;
private final boolean forks;
private Command<S> command;
+ // CraftBukkit start
+ public void removeCommand(String name) {
+ children.remove(name);
+ literals.remove(name);
+ 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 +71,17 @@
return modifier;
}
- public boolean canUse(final S source) {
+ // CraftBukkit start
+ public synchronized boolean canUse(final S source) {
+ if (source instanceof CommandListenerWrapper) {
+ try {
+ ((CommandListenerWrapper) source).currentCommand = this;
+ return requirement.test(source);
+ } finally {
+ ((CommandListenerWrapper) source).currentCommand = null;
+ }
+ }
+ // CraftBukkit end
return requirement.test(source);
}

Some files were not shown because too many files have changed in this diff Show more