1.17.1 Use JSON Text Within player.sendTitle

Discussion in 'Spigot Plugin Development' started by FlopsiBunny, Nov 26, 2021.

  1. So the title of the thread is pretty self explanatory, I would love to use the json formatted text within the `player.sendTitle` command but as it only supports strings I am somewhat stumped. I would prefer not to use NMS or reflection and just use the base spigot command.

    That being said I looked into other options such as using the TextComponent which has the options for setFont, setColor, etc. which is what I am in need of, specifically setFont, so rather than creating the JSON directly is there a way to use the TextComponent within sendTitle?

    If that's not the case how would I go about properly using the ChatSerializer instead and be able to grab a proper format from there.
     
  2. There doesn't seem to be a counterpart to the method that accepts BaseComponents. Is there an issue with using legacy text though? You can color and set the font of text just fine without text components, just use the ChatColor enum.
     
  3. How does ChatColor support fonts?
     
  4. Sorry, seems I misunderstood you and this is a feature I'm not familiar with. I believed you were referring to bold, italic, underlined, etc., text.
     
  5. I didn’t understand the problem. You can`t get text from json and send via sendTitle? Or do you want colored text, but not sure how?
    You can use the symbol "§" in ur string value to color the text. For example "§cHello World" -> in minecraft "Hello World"
     
  6. Have you tried using your font within the sendTitle method provided? It works within methods such as sendMessage so I don’t see why there would be an exception here.

    Failing that, this method is provided. Not sure if that is any use but you can always convert to “legacy string” according to the docs.
     
  7. So I'm trying to use a custom font within a resource pack over the title, the font I'm using remaps a clone of the custom vanilla font in smaller size and with support for negative spacing to work on implementing a plugin with custom tooltips. The issue I just need to know is how to send the text, declaring the custom font in the title message. I know it is possible and will provide an example of such:
     

    Attached Files:

  8. I've tried creating and sending the format with both but the issue is sendTitle displays the direct string of JSON not the processed version.
     
  9. Hmm I see. I’m certain that you might have to use packets unfortunately as I can’t think of a different way :confused:.