SpongePowered/SpongeAPI — pull request #146 by 1stGlitch (2014-09-14 00:51:02+00:00)
Title: Added chat formatting classes (highly/easily expandable)

This system is easily expandable and
features such as hover can be added easily, along with any other chat
features that gets added to the game in the future, I feel that this
system of chat formatting will more organized to use and easier to do
repetitive formatted chat messages such as:
"You do not have permission to ..."

Below shows how to use this system, these examples assume that
"player.sendmessage()" accepts the following arguments: string, string and my “format” type,
my “formatted message” type. Once player.sendmessage and any other
chat broadcasters like it are put in, I will submit a commit to
implement that if not already done (this is if this commit is merged)

Now, Code examples:

String message = "Hi";

//Plain text saying "Hi"
player.sendmessage(message)

//Dark Red Underlined Text saying "Hi" (showing 3 ways)
// #1
player.sendmessage(message, new ChatFormat(MinecraftColor.DARK_RED, ChatFormat.Formatting.Underlined));

// #2
ChatFormat myformat = new ChatFormat(MinecraftColor.DARK_RED, ChatFormat.Formatting.Underlined);
player.sendmessage(message, myformat);

// #3
FormattedMessage messageformatted = new FormattedMessage(message, myformat);
player.sendmessage(messageformatted);

//Dark Red Underlined and Bold Text saying "Hi" (showing 1 way)
// #1
ChatFormat.Formatting[] myformats = new ChatFormat.Formatting[]{ChatFormat.Formatting.Underlined, ChatFormat.Formatting.Bold}
player.sendmessage(message, new ChatFormat(MinecraftColor.DARK_RED, myformats));