From 23d50f8134c8919903c1051f4567acc2d461bb84 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 1 Feb 2022 15:51:44 -0700 Subject: [PATCH] API for creating command sender which forwards feedback --- paper-api/src/main/java/org/bukkit/Bukkit.java | 14 ++++++++++++++ paper-api/src/main/java/org/bukkit/Server.java | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 46b678da74..a9d1a9a522 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -1595,6 +1595,20 @@ public final class Bukkit { return server.getConsoleSender(); } + // Paper start + /** + * Creates a special {@link CommandSender} which redirects command feedback (in the form of chat messages) to the + * specified listener. The returned sender will have the same effective permissions as {@link #getConsoleSender()}. + * + * @param feedback feedback listener + * @return a command sender + */ + @NotNull + public static CommandSender createCommandSender(final @NotNull java.util.function.Consumer feedback) { + return server.createCommandSender(feedback); + } + // Paper end + /** * Gets the folder that contains all of the various {@link World}s. * diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 5ca4543587..06cc09298a 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -1349,6 +1349,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @NotNull public ConsoleCommandSender getConsoleSender(); + // Paper start + /** + * Creates a special {@link CommandSender} which redirects command feedback (in the form of chat messages) to the + * specified listener. The returned sender will have the same effective permissions as {@link #getConsoleSender()}. + * + * @param feedback feedback listener + * @return a command sender + */ + @NotNull + public CommandSender createCommandSender(final @NotNull java.util.function.Consumer feedback); + // Paper end + /** * Gets the folder that contains all of the various {@link World}s. *