From 0000000000000000000000000000000000000000 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 diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 6f9ffbb907b7f14ae2cfc3cae45ea277c00d461c..9a7a2ad3d245b5215b914ef1a00fb65a83639871 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1392,6 +1392,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/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 64e4667efbf60204076ef32d64aa3a76c399df05..5aa14f6c2f5be4d72689d764ad4d0ce5a3d704a8 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1162,6 +1162,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. *