Paper/patches/api/0348-API-for-creating-command-sender-which-forwards-feedb.patch
Nassim Jahnke d8e07590e3
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
5dbedae1 PR-864: Fix Registry#match() failing namespaced inputs
49256865 PR-863: Fix boolean PersistentDataType
9f15450b SPIGOT-7195, SPIGOT-7197: Add DataPack API
ebef5b6a Disable InterfaceIsType Checkstyle check
01d577f5 Slight tweak to boolean PersistentDataType javadoc
d2b99e56 PR-857: Add boolean PersistentDataType

CraftBukkit Changes:
2270366cd PR-1196: Test Registry instances more thoroughly
863dacb7a PR-1191: Do not start on pre-release Java 17
1f2dd8e12 SPIGOT-7362: Properly handle null in CraftBlock#blockFaceToNotch()
dbc70bed5 SPIGOT-7195, SPIGOT-7197: Add DataPack API
2023-06-06 11:09:19 +02:00

55 lines
2.3 KiB
Diff

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 d4b522ee3d44ec755046cc406708086b5f5cf625..3c7cedf0f2654d68fc7fa9fb32a17d362bba459e 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1434,6 +1434,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<? super net.kyori.adventure.text.Component> 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 feb2c76bd20c1146d22ec1988943e5b94a982de9..57e117583ba6d562e2ffd308e058e5ea7de90b24 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1204,6 +1204,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<? super net.kyori.adventure.text.Component> feedback);
+ // Paper end
+
/**
* Gets the folder that contains all of the various {@link World}s.
*