testserver/Spigot-API-Patches/0018-Add-BaseComponent-send...

65 lines
2.3 KiB
Diff
Raw Normal View History

2018-07-29 16:42:07 +00:00
From bb93ce5965c54e88bc4fe08927346a6e75ebff17 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Tue, 8 Mar 2016 13:05:59 -0800
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
2018-07-29 16:42:07 +00:00
index abf68a2c7..fcb03b830 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
2017-05-15 16:25:20 +00:00
@@ -58,4 +58,30 @@ public interface CommandSender extends Permissible {
Spigot spigot();
// Spigot end
+
+ // Paper start
+ /**
+ * Sends the component to the sender
+ *
+ * <p>If this sender does not support sending full components then
+ * the component will be sent as legacy text.</p>
+ *
+ * @param component the component to send
+ */
+ default void sendMessage(net.md_5.bungee.api.chat.BaseComponent component) {
+ this.sendMessage(component.toLegacyText());
+ }
+
+ /**
+ * Sends an array of components as a single message to the sender
+ *
+ * <p>If this sender does not support sending full components then
+ * the components will be sent as legacy text.</p>
+ *
+ * @param components the components to send
+ */
+ default void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) {
+ this.sendMessage(new net.md_5.bungee.api.chat.TextComponent(components).toLegacyText());
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
2018-07-29 16:42:07 +00:00
index e042098df..94b316a20 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
2018-07-29 16:42:07 +00:00
@@ -446,6 +446,7 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
*
* @param component the components to send
*/
+ @Override
2016-12-20 22:34:27 +00:00
public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent component) {
spigot().sendMessage(component);
}
2018-07-29 16:42:07 +00:00
@@ -455,6 +456,7 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
*
* @param components the components to send
*/
+ @Override
2016-12-20 22:34:27 +00:00
public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) {
spigot().sendMessage(components);
}
--
2.18.0