feat: add minimessage tag resolvers overload to CommandSender#sendMessage (#9505)

This commit is contained in:
powercas_gamer 2023-07-23 07:46:40 +02:00 committed by GitHub
parent 42830546f3
commit aa93dcfdce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -1837,7 +1837,7 @@ index 80209bb88a0294d4eedc78509533a6257315d856..75759131bd94b672bec4cd8e271ebff1
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
source.sendMessage(message);
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index 284be63a125624a8ae43d2c164aede810ce6bfe5..4e440880bd82f3cd8b267f00b2fcd725b49ce981 100644
index 284be63a125624a8ae43d2c164aede810ce6bfe5..70fec73328227725f519af845ecbdce8be2fa4e2 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -6,20 +6,28 @@ import org.bukkit.permissions.Permissible;
@ -1932,7 +1932,7 @@ index 284be63a125624a8ae43d2c164aede810ce6bfe5..4e440880bd82f3cd8b267f00b2fcd725
public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -99,4 +121,39 @@ public interface CommandSender extends Permissible {
@@ -99,4 +121,52 @@ public interface CommandSender extends Permissible {
@NotNull
Spigot spigot();
// Spigot end
@ -1963,6 +1963,19 @@ index 284be63a125624a8ae43d2c164aede810ce6bfe5..4e440880bd82f3cd8b267f00b2fcd725
+ }
+
+ /**
+ * Sends a message with the MiniMessage format to the command sender.
+ * <p>
+ * See <a href="https://docs.advntr.dev/minimessage/">MiniMessage docs</a> and <a href="https://docs.advntr.dev/minimessage/dynamic-replacements">MiniMessage Placeholders docs</a>
+ * for more information on the format.
+ *
+ * @param message MiniMessage content
+ * @param resolvers resolvers to use
+ */
+ default void sendRichMessage(final @NotNull String message, final net.kyori.adventure.text.minimessage.tag.resolver.@NotNull TagResolver... resolvers) {
+ this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message, resolvers));
+ }
+
+ /**
+ * Sends a plain message to the command sender.
+ *
+ * @param message plain message

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add BaseComponent sendMessage methods to CommandSender
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index 4e440880bd82f3cd8b267f00b2fcd725b49ce981..c97970a6a44d61462c9d8d69f6aa12d9a8bb4e05 100644
index 0f2b85e4979c478fbcc20bd67446e6ac8c8696d7..5c8ae3e0a927f2f2924d719b03499d936cf4d951 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -1,6 +1,9 @@
@ -18,7 +18,7 @@ index 4e440880bd82f3cd8b267f00b2fcd725b49ce981..c97970a6a44d61462c9d8d69f6aa12d9
import org.bukkit.Server;
import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull;
@@ -155,5 +158,33 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
@@ -168,5 +171,33 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
default void sendPlainMessage(final @NotNull String message) {
this.sendMessage(net.kyori.adventure.text.Component.text(message));
}