Easy-to-use tellraw?

Bukkit’s ability to use the raw message formatting, in my opinion, fell short of what if could have done. I’m suggesting that the API contains methods to send the raw messages easily and possibly even craft them without a plugin developer having to deal with JSON Strings.


RawMessage raw = new RawMessage();
raw.addPlaintext("Hello, world! ");
raw.addCommand("[Click for /help]", new HelpCommand());


I like that idea. I loved being able to use the tooltip, click, hover, etc actions for text, but had to use Fanciful or internal classes, so if it can be well handled by Sponge better, I’d love to implement those features into some of my plugins.

1 Like

I wrote a Lib that allows you to do that. :) I’ll see if I can post it on GitHub for you. :)

Sponge use another API …

That is a great idea. Would make advanced chat formatting so much easier.

That’s awesome man! Maybe it can be included with the Sponge API if you choose :slight_smile:

Those aren’t real classes, just a suggested example.

I have my own formatting library that I use in WorldEdit, but I’m open to suggestions.

The one I use predates JSON chat, so it needs some updating, but it’s tree-based.

  .append("The command is ")
  .append(with(BLUE, BOLD).append("/example"))

The period would still be yellow.

You can also subclass the fragment class:

class Code extends StyledFragment {
  public Code() { super(BOLD, BLUE); }

So you can reuse elements:

  .append("The command is ")
  .append(new Code().append("/example"))
1 Like

That’s a nice way of doing it. Is the class immutable or is it just a set of fluent methods appending to the original object?

Mutable. Those are just fluent methods.

It’s basically StringBuilder that also stores the current style / formatting (except it stores a list of fragments rather than a sequence of characters).

Sexy. I hope you aren’t opposed to something like this implemented into the API.

1 Like