Solved help with PacketPlayOutChat

Discussion in 'Spigot Plugin Development' started by toto7735, Jun 20, 2021.

  1. Hello guys!
    I am using PacketPlayOutChat to make a translation system to listen the PacketPlayOutChat, get the message, translate it, and send it again. my code is

    Code (Text):
                public void write(ChannelHandlerContext channelHandlerContext, Object packet, ChannelPromise channelPromise) throws Exception {
                    if (packet instanceof PacketPlayOutChat) {
                        for (IChatBaseComponent component : CraftChatMessage.fromString("message")) {
                            PacketPlayOutChat packetPlayOutChat = new PacketPlayOutChat(component, ChatMessageType.CHAT);
                            super.write(channelHandlerContext, packetPlayOutChat, channelPromise);
                    super.write(channelHandlerContext, packet, channelPromise);
    But the question is, how do you get that message in packet? I can send the message I want, but I don't know how to get the message from the packet. I tried everything I could, but the server was either kicking me or it's null.

    Thank you in advance for your help. Thanks you~!
    #1 toto7735, Jun 20, 2021
    Last edited: Jun 23, 2021
  2. get the 'a' variable [ IChatBaseComponent ] from the packet ( with reflection ).
  3. Also consider using ProtocolLib, it means that your plugin won't need updating with every version, doesn't require you to use reflection, and is generally quite a bit easier.