Solved TextComponent to IChatBaseComponent?

Discussion in 'Spigot Plugin Development' started by Creeprr, Feb 14, 2020.

  1. How do I turn a TextComponent into IChatBaseComponent?

    I'm basically trying to modify an IChatBaseComponent using text formatting (hoverable text etc.), I can turn the IChatBaseComponent into a String using
    Code (Java):
    CraftChatMessage.fromComponent(component)
    But after I've edited it using TextComponent I'm not sure on how to turn it back to IChatBaseComponent.

    I'm using TextComponent for hoverable text etc.
     
  2. Seems to be a xy-problem.
    Do you want to send a hoverable message to the user?
    Are you trying to modify a iChat component that is already in the pipeline of Netty to get send to the client?
     
    • Like Like x 1
  3. Yes sir, that is exactly what I'm trying. :)
     
  4. The first or the second?
     
  5. SteelPhoenix

    Moderator

    Which one of the two?

    Edit: snipd :(
     
  6. Oh my god lol, my bad, I read both in one I think I've dropped my IQ today.

    But yeah I am trying to modify an IChatComponent that's already in the netty pipeline to add hoverable text to it. :)
     
  7. Found the solution to this myself:

    The ComponentSerializer can parse a json string to BaseComponents, after that you can parse those back to json again using ComponentSerializer.

    Thank you for your time. :)