From c2f24e1567a3ac576c31c7e4fab0d56988e52a56 Mon Sep 17 00:00:00 2001 From: Strokkur24 <133226102+Strokkur424@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:29:16 +0100 Subject: [PATCH] Feat: Add 'with' methods to CommandSourceStack (#11868) --- .../command/brigadier/CommandSourceStack.java | 22 +++++++++++++ ...y-type-tags-suggestions-in-selectors.patch | 4 +-- .../commands/CommandSourceStack.java.patch | 31 +++++++++++++++++++ .../brigadier/PaperCommandSourceStack.java | 16 +++++++--- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/command/brigadier/CommandSourceStack.java b/paper-api/src/main/java/io/papermc/paper/command/brigadier/CommandSourceStack.java index ac6f5b754a..109c0a89e2 100644 --- a/paper-api/src/main/java/io/papermc/paper/command/brigadier/CommandSourceStack.java +++ b/paper-api/src/main/java/io/papermc/paper/command/brigadier/CommandSourceStack.java @@ -1,5 +1,7 @@ package io.papermc.paper.command.brigadier; +import com.mojang.brigadier.RedirectModifier; +import com.mojang.brigadier.tree.CommandNode; import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; @@ -48,4 +50,24 @@ public interface CommandSourceStack { * @return entity that executes this command */ @Nullable Entity getExecutor(); + + /** + * Creates a new CommandSourceStack object with a different location for redirecting commands to other nodes. + * + * @param location The location to create a new CommandSourceStack object with + * @return The newly created CommandSourceStack + * @see #getLocation() + * @see com.mojang.brigadier.builder.ArgumentBuilder#fork(CommandNode, RedirectModifier) + */ + CommandSourceStack withLocation(Location location); + + /** + * Creates a new CommandSourceStack object with a different executor for redirecting commands to other nodes. + * + * @param executor The executing entity to create a new CommandSourceStack object with + * @return The newly created CommandSourceStack + * @see #getExecutor() + * @see com.mojang.brigadier.builder.ArgumentBuilder#fork(CommandNode, RedirectModifier) + */ + CommandSourceStack withExecutor(Entity executor); } diff --git a/paper-server/patches/features/0009-Fix-entity-type-tags-suggestions-in-selectors.patch b/paper-server/patches/features/0009-Fix-entity-type-tags-suggestions-in-selectors.patch index cd578f9f57..b587b90edc 100644 --- a/paper-server/patches/features/0009-Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/paper-server/patches/features/0009-Fix-entity-type-tags-suggestions-in-selectors.patch @@ -10,10 +10,10 @@ when if this was fixed on the client, that wouldn't be needed. Mojira Issue: https://bugs.mojang.com/browse/MC-235045 diff --git a/net/minecraft/commands/CommandSourceStack.java b/net/minecraft/commands/CommandSourceStack.java -index 704a63890a06d793f8ac3452838917e7c7335232..75262c8c9eaecb4a88a94f4076d67119c67a97da 100644 +index cf923441da598637be74a5ffa4b4f948e01ff532..cbf32be9235921ebcaca88225120c2ca70a72771 100644 --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -652,4 +652,20 @@ public class CommandSourceStack implements ExecutionCommandSource