aadnk / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
288 stars 92 forks source link

Null when sending message using net.kyori.adventure.text.Component #191

Closed markovav-official closed 3 years ago

markovav-official commented 3 years ago

Describe the bug I using this code: https://pastebin.com/EHKpRxYB When I send message to player using net.kyori.adventure.text.Component, I recieve null on packet.getChatComponents().getValues().get(0) How I can get this message anyway? I think it is incorrect behavior.

To Reproduce Steps to reproduce the behavior:

  1. Use this https://pastebin.com/EHKpRxYB
  2. Send message to player using net.kyori.adventure.text.Component
  3. Recieve packet
  4. Recieve null on packet.getChatComponents().getValues().get(0)

Expected behavior I want to recieve WrappedChatComponent but not null

Version Info https://pastebin.com/UV0i1Z1B

Error in console https://pastebin.com/Wcdv8w6Y

MiniDigger commented 3 years ago

getChatComponents uses vanilla components, not adventure components.

you want to create your own structure wrapper for accessing adventure components

markovav-official commented 3 years ago

How can I get the raw text (sent by plugin using adventure component) that is sent to the player?

MiniDigger commented 3 years ago

get the adventure component from the packet and use a PlainTextSerializer https://docs.adventure.kyori.net/serializer/plain.html

markovav-official commented 3 years ago

Thanks, I will try to do this