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 53c4e5ca208ee17c7c244e416c537c7b63edf194..3a8326735b62521f8fb95c51a0909d8b7bac83d1 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1297,6 +1297,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 e48af3822e9f118399c3a1c9358c56efae12e0da..73446141e8c50b71a17ff6f0c528a62d5c75751b 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1078,6 +1078,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. *