From 939d06cfb56c06bbe87712a5878726f7339796b9 Mon Sep 17 00:00:00 2001 From: Felix Cravic Date: Sat, 15 Aug 2020 13:38:57 +0200 Subject: [PATCH] Added Player#sendPluginMessage --- .../net/minestom/server/entity/Player.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index e948c69f3..e5c0c127b 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -604,6 +604,29 @@ public class Player extends LivingEntity implements CommandSender { } } + /** + * Send a plugin message to the player + * + * @param channel the message channel + * @param data the message data + */ + public void sendPluginMessage(String channel, byte[] data) { + PluginMessagePacket pluginMessagePacket = new PluginMessagePacket(); + pluginMessagePacket.channel = channel; + pluginMessagePacket.data = data; + playerConnection.sendPacket(pluginMessagePacket); + } + + /** + * Send a plugin message to the player + * + * @param channel the message channel + * @param message the message + */ + public void sendPluginMessage(String channel, String message) { + sendPluginMessage(channel, message.getBytes()); + } + /** * Send a {@link BlockBreakAnimationPacket} packet to the player and his viewers * Setting {@code destroyStage} to -1 resets the break animation