Custom Chat Mode Plugin

When I was using Bukkit I had a roleplaying world. There was a Bukkit plugin called Roleplay Chat, which allowed for the creation of custom chat mode commands. You could add custom chat commands like /ooc and /shout which worked like the /say command, but you could customize the text formatting (color, bold, italic, caps, etc) all through the config file. It was amazing.

Is there any possibility of someone creating a similar plugin for Sponge? The original Bukkit mod can be found here!

This would make for an interesting first project. I will try to make this.

Awesome! I’ll test it out if you do!

Finished the plugin! CustomChatCommands.jar
I have changed the configuration. Rather than a single playername-message pair, you can have as many arguments as you like, and reference them in the format with <​arg1> <​arg2​> <​arg3> etc. The final argument is the rest of the command arguments combined, for the long message that is typical of these commands. You can also of course use for the playername.
Since this is Sponge and not Bukkit, instead of just & color codes, the message is in full JSON format.
Lastly, the radius can still be set to -1 to make it global, but now it can also be set to 0 to go to whoever a normal chat message would go to.

Works on my test server! Took me a while to figure out exactly how to format my own command in, the JSON format is super complex and NOT straightforward.

Like, the Bukkit plugin’s config is super easy to work with. If I want /me to just display the message in yellow with the username, the config is:
default: false
permission: false
radius: 30
format: '%username% &e%message%'
- 'me'
And if I want a /shout command that displays Username Shouts: in yellow, then the actual message bold and in white it is:
default: false
permission: false
radius: 100
format: '%username% &eshouts: &f&l%message%'
- 'shout'
The text string formatting doesn’t have any extraneous slashes, commas, or quotation marks. I’m not a programmer at all, so I have no idea how hard it would be to simplify the user-end text formatting, but I feel like the current level of complexity is going to scare off (or be unusable) to a massive group of casual server admins. The formatting with the commas, slashes and quote marks are a pain.

Anyhow, I am struggling with one thing. How do I format my /shout command so it displays Username Shouts: in yellow, but the actual message test white and bold? Currently I have:
shout {
message="{\"text\":\"<player> Shouts: <arg1>\",\"bold\":\"true\",\"color\":\"yellow\"}"
Which displays the whole thing in bold yellow. As I said, the JSON formatting is super confusing to me.

message="{“text”:" Shouts: “,“color”:“yellow”,“extra”:[{“text”:”",“color”:“white”,“bold”:“true”}]}"
This does kind of assume that you know the Minecraft JSON format. Although there are in fact generators online.
However, you are right. This could scare off noobs. I have thus updated the plugin. The download link is the same as before. Version 1.1 has a new tag, ‘format’. This can be either ‘json’, ‘ampersand’, or ‘xml’, to use JSON format, & format, or Sponge’s TextXML format respectively. It defaults to JSON if unspecified or invalid.
And lastly, I’m sorry about the ", but that’s HOCON for you, commas are par for the course (it’s JSON after all), and in Minecraft 1.9 they removed the ability to have quoteless identifiers.

Alright, awesome! thanks for stepping up and doing all this! I’ll try the update out tomorrow (the 12th) after I get some sleep. :stuck_out_tongue:

Oh man this is amazing, fantastic update! Got it working with the ampersand format.
If you’re going to publish i,t I would for sure include an example for all three formats instead of just JSON, took me a couple tries to get it to do what I wanted. Once I did the though, your implementation of the ampersand format was really easy to use!

Version 1.2 brings new examples, as well as the ‘example’ tag, which means that it is an example command and therefore should not be loaded. Also added support for zero-arg commands.

Sweet! This is becoming a solid and very powerful plugin.
Would it be possible to have a “Default” tag to set a certain format as the default chat format? I’m personally not fond of the displayed chat format being:
<Username> Message.

I much prefer:
Username: Message.

The default tag would mean that’s what chat looks like when you type in text with no commands. Might be a bit of a stretch for this plugin, but it would be super handy.

First: Yay, you found the plugin page.
Second: I looked into how one modifies the format of a MessageChannelEvent.Chat, and holy shit is it complicated. It also is completely missing from the documentation, and I can’t figure it out from the javadocs.
I will do this as soon as I have the slightest idea how.

Why can’t you just use setMessage() to change to message? I use it in my plugins.

I did indeed! Ahahaha, alright, take your time, I’m looking forward to it :smiley:

Thanks so much for building this, I think it may end up being pretty popular!

And, wow I’m dumb.

<​Pentephraxis> <​Pentephraxis> hi
what am i doing wrong

What does your code look like?

EDIT: I believe the issue is you are using getOriginalMessage() instead of using getRawMessage().

1 Like

Yeah, that was it. Thanks.

I have updated the plugin with the requested feature. It now has a /customchatcommands (/ccc) reload as well.

Check and validate JSON here: json formatter

Please don’t post on ancient posts which are no longer relevant @kirk8