3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/api/0352-API-for-creating-command-sender-which-forwards-feedb.patch

55 Zeilen
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
2022-12-07 17:46:46 +01:00
index 85dc2bf97175207bcc169d5d7e0d86dae39aecf2..1934a4521a43ad14beacf0c56e5914e35da8bc59 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2022-12-07 17:46:46 +01:00
@@ -1415,6 +1415,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
2022-12-07 17:46:46 +01:00
index c07eef17aac9140e1f461aa20e3a90fcb3f4ae74..23063ebcf36dd4f02ad4670839295064c95e3aec 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2022-12-07 17:46:46 +01:00
@@ -1181,6 +1181,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.
*