From 325fb41de3f83292cb643328dca9fe1cf88a4285 Mon Sep 17 00:00:00 2001 From: kashike 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 index abf68a2c..fcb03b83 100644 --- a/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java @@ -58,4 +58,30 @@ public interface CommandSender extends Permissible { Spigot spigot(); // Spigot end + + // Paper start + /** + * Sends the component to the sender + * + *

If this sender does not support sending full components then + * the component will be sent as legacy text.

+ * + * @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 + * + *

If this sender does not support sending full components then + * the components will be sent as legacy text.

+ * + * @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 index 959add05..5109a0c3 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -421,6 +421,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param component the components to send */ + @Override public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent component) { spigot().sendMessage(component); } @@ -430,6 +431,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param components the components to send */ + @Override public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) { spigot().sendMessage(components); } -- 2.20.1