diff --git a/paper-server/patches/unapplied/com/mojang/brigadier/CommandDispatcher.java.patch b/paper-server/patches/sources/com/mojang/brigadier/CommandDispatcher.java.patch similarity index 88% rename from paper-server/patches/unapplied/com/mojang/brigadier/CommandDispatcher.java.patch rename to paper-server/patches/sources/com/mojang/brigadier/CommandDispatcher.java.patch index ba95e196e5..d5b323d68e 100644 --- a/paper-server/patches/unapplied/com/mojang/brigadier/CommandDispatcher.java.patch +++ b/paper-server/patches/sources/com/mojang/brigadier/CommandDispatcher.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/brigadier/CommandDispatcher.java +++ b/com/mojang/brigadier/CommandDispatcher.java -@@ -3,6 +3,7 @@ +@@ -3,6 +_,7 @@ package com.mojang.brigadier; @@ -8,7 +8,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContextBuilder; -@@ -297,15 +298,21 @@ +@@ -297,15 +_,21 @@ List> potentials = null; final int cursor = originalReader.getCursor(); @@ -31,7 +31,7 @@ } catch (final RuntimeException ex) { throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherParseException().createWithContext(reader, ex.getMessage()); } -@@ -320,6 +327,7 @@ +@@ -320,6 +_,7 @@ } errors.put(child, ex); reader.setCursor(cursor); @@ -39,7 +39,7 @@ continue; } -@@ -451,7 +459,7 @@ +@@ -451,7 +_,7 @@ } private String getSmartUsage(final CommandNode node, final S source, final boolean optional, final boolean deep) { @@ -48,16 +48,16 @@ return null; } -@@ -465,7 +473,7 @@ - final String redirect = node.getRedirect() == this.root ? "..." : "-> " + node.getRedirect().getUsageText(); - return self + CommandDispatcher.ARGUMENT_SEPARATOR + redirect; +@@ -465,7 +_,7 @@ + final String redirect = node.getRedirect() == root ? "..." : "-> " + node.getRedirect().getUsageText(); + return self + ARGUMENT_SEPARATOR + redirect; } else { - final Collection> children = node.getChildren().stream().filter(c -> c.canUse(source)).collect(Collectors.toList()); + final Collection> children = node.getChildren().stream().filter(c -> source == null || c.canUse(source)).collect(Collectors.toList()); // Paper if (children.size() == 1) { - final String usage = this.getSmartUsage(children.iterator().next(), source, childOptional, childOptional); + final String usage = getSmartUsage(children.iterator().next(), source, childOptional, childOptional); if (usage != null) { -@@ -537,10 +545,14 @@ +@@ -537,10 +_,14 @@ int i = 0; for (final CommandNode node : parent.getChildren()) { CompletableFuture future = Suggestions.empty(); diff --git a/paper-server/patches/unapplied/com/mojang/brigadier/builder/ArgumentBuilder.java.patch b/paper-server/patches/sources/com/mojang/brigadier/builder/ArgumentBuilder.java.patch similarity index 98% rename from paper-server/patches/unapplied/com/mojang/brigadier/builder/ArgumentBuilder.java.patch rename to paper-server/patches/sources/com/mojang/brigadier/builder/ArgumentBuilder.java.patch index 16daaa3a3c..e778d183d1 100644 --- a/paper-server/patches/unapplied/com/mojang/brigadier/builder/ArgumentBuilder.java.patch +++ b/paper-server/patches/sources/com/mojang/brigadier/builder/ArgumentBuilder.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/brigadier/builder/ArgumentBuilder.java +++ b/com/mojang/brigadier/builder/ArgumentBuilder.java -@@ -14,9 +14,17 @@ +@@ -14,9 +_,17 @@ import java.util.function.Predicate; public abstract class ArgumentBuilder> { diff --git a/paper-server/patches/unapplied/com/mojang/brigadier/tree/CommandNode.java.patch b/paper-server/patches/sources/com/mojang/brigadier/tree/CommandNode.java.patch similarity index 88% rename from paper-server/patches/unapplied/com/mojang/brigadier/tree/CommandNode.java.patch rename to paper-server/patches/sources/com/mojang/brigadier/tree/CommandNode.java.patch index 179686de6f..39c18089dd 100644 --- a/paper-server/patches/unapplied/com/mojang/brigadier/tree/CommandNode.java.patch +++ b/paper-server/patches/sources/com/mojang/brigadier/tree/CommandNode.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/brigadier/tree/CommandNode.java +++ b/com/mojang/brigadier/tree/CommandNode.java -@@ -3,6 +3,7 @@ +@@ -3,6 +_,7 @@ package com.mojang.brigadier.tree; @@ -8,7 +8,7 @@ import com.mojang.brigadier.AmbiguityConsumer; import com.mojang.brigadier.Command; import com.mojang.brigadier.RedirectModifier; -@@ -22,6 +23,7 @@ +@@ -22,6 +_,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; @@ -16,7 +16,7 @@ public abstract class CommandNode implements Comparable> { private final Map> children = new LinkedHashMap<>(); -@@ -32,6 +34,16 @@ +@@ -32,6 +_,16 @@ private final RedirectModifier modifier; private final boolean forks; private Command command; @@ -33,12 +33,12 @@ protected CommandNode(final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final boolean forks) { this.command = command; -@@ -61,7 +73,17 @@ - return this.modifier; +@@ -61,7 +_,17 @@ + return modifier; } - public boolean canUse(final S source) { -+ // CraftBukkit start ++ // Paper start + public synchronized boolean canUse(final S source) { + if (source instanceof CommandSourceStack) { + try { @@ -48,28 +48,28 @@ + ((CommandSourceStack) source).currentCommand.remove(Thread.currentThread()); // Paper - Thread Safe Vanilla Command permission checking + } + } -+ // CraftBukkit end - return this.requirement.test(source); ++ // Paper end + return requirement.test(source); } -@@ -151,6 +173,12 @@ +@@ -151,6 +_,12 @@ protected abstract String getSortedKey(); public Collection> getRelevantNodes(final StringReader input) { -+ // Paper start - prioritize mc commands in function parsing ++ // Paper start - prioritize mc commands in function parsing + return this.getRelevantNodes(input, null); + } + @org.jetbrains.annotations.ApiStatus.Internal + public Collection> getRelevantNodes(final StringReader input, final Object source) { -+ // Paper end - prioritize mc commands in function parsing - if (this.literals.size() > 0) { ++ // Paper end - prioritize mc commands in function parsing + if (literals.size() > 0) { final int cursor = input.getCursor(); while (input.canRead() && input.peek() != ' ') { -@@ -158,7 +186,21 @@ +@@ -158,7 +_,21 @@ } final String text = input.getString().substring(cursor, input.getCursor()); input.setCursor(cursor); -- final LiteralCommandNode literal = this.literals.get(text); +- final LiteralCommandNode literal = literals.get(text); + // Paper start - prioritize mc commands in function parsing + LiteralCommandNode literal = null; + if (source instanceof CommandSourceStack css && css.source == net.minecraft.commands.CommandSource.NULL) { @@ -88,7 +88,7 @@ if (literal != null) { return Collections.singleton(literal); } else { -@@ -183,4 +225,11 @@ +@@ -183,4 +_,11 @@ } public abstract Collection getExamples(); diff --git a/paper-server/patches/unapplied/com/mojang/brigadier/tree/LiteralCommandNode.java.patch b/paper-server/patches/sources/com/mojang/brigadier/tree/LiteralCommandNode.java.patch similarity index 97% rename from paper-server/patches/unapplied/com/mojang/brigadier/tree/LiteralCommandNode.java.patch rename to paper-server/patches/sources/com/mojang/brigadier/tree/LiteralCommandNode.java.patch index 15d0b7b976..f08f887a30 100644 --- a/paper-server/patches/unapplied/com/mojang/brigadier/tree/LiteralCommandNode.java.patch +++ b/paper-server/patches/sources/com/mojang/brigadier/tree/LiteralCommandNode.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/brigadier/tree/LiteralCommandNode.java +++ b/com/mojang/brigadier/tree/LiteralCommandNode.java -@@ -23,11 +23,19 @@ +@@ -23,11 +_,19 @@ public class LiteralCommandNode extends CommandNode { private final String literal; private final String literalLowerCase; @@ -20,7 +20,7 @@ } public String getLiteral() { -@@ -42,7 +50,12 @@ +@@ -42,7 +_,12 @@ @Override public void parse(final StringReader reader, final CommandContextBuilder contextBuilder) throws CommandSyntaxException { final int start = reader.getCursor(); @@ -34,7 +34,7 @@ if (end > -1) { contextBuilder.withNode(this, StringRange.between(start, end)); return; -@@ -51,7 +64,10 @@ +@@ -51,7 +_,10 @@ throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.literalIncorrect().createWithContext(reader, literal); } @@ -46,7 +46,7 @@ final int start = reader.getCursor(); if (reader.canRead(literal.length())) { final int end = start + literal.length(); -@@ -78,7 +94,7 @@ +@@ -78,7 +_,7 @@ @Override public boolean isValidInput(final String input) {