3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00

Add sendRichMessage and sendPlainMessage methods

Dieser Commit ist enthalten in:
Nassim Jahnke 2022-06-09 23:34:06 +02:00
Ursprung 5052a4515e
Commit 09c9215b85
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 27 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -1403,7 +1403,7 @@ index 80209bb88a0294d4eedc78509533a6257315d856..57ade3963faae3724d9a01eeeb6d0216
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..22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35 100644
index 284be63a125624a8ae43d2c164aede810ce6bfe5..ec97093a4410322ad44e111d894a3b1a5c5f7b88 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -6,12 +6,13 @@ import org.bukkit.permissions.Permissible;
@ -1485,7 +1485,7 @@ index 284be63a125624a8ae43d2c164aede810ce6bfe5..22b654efdcc49d6dc6d52c9d6afa1c9d
public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -99,4 +111,18 @@ public interface CommandSender extends Permissible {
@@ -99,4 +111,39 @@ public interface CommandSender extends Permissible {
@NotNull
Spigot spigot();
// Spigot end
@ -1502,6 +1502,27 @@ index 284be63a125624a8ae43d2c164aede810ce6bfe5..22b654efdcc49d6dc6d52c9d6afa1c9d
+ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
+ this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
+ }
+
+ /**
+ * Sends a message with the MiniMessage format to the command sender.
+ * <p>
+ * See <a href="https://docs.adventure.kyori.net/minimessage/">MiniMessage docs</a>
+ * for more information on the format.
+ *
+ * @param message MiniMessage content
+ */
+ default void sendRichMessage(final @NotNull String message) {
+ this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message));
+ }
+
+ /**
+ * Sends a plain message to the command sender.
+ *
+ * @param message plain message
+ */
+ default void sendPlainMessage(final @NotNull String message) {
+ this.sendMessage(net.kyori.adventure.text.Component.text(message));
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java

Datei anzeigen

@ -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 22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35..daab4d13556150d4a4875f0273795e2c4cb82d63 100644
index ec97093a4410322ad44e111d894a3b1a5c5f7b88..f3cf27e075ea01d9d825aead3782db66cd4f2c3b 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -1,6 +1,9 @@
@ -18,9 +18,9 @@ index 22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35..daab4d13556150d4a4875f0273795e2c
import org.bukkit.Server;
import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull;
@@ -124,5 +127,33 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
@@ -145,5 +148,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));
}
+
+ /**