I’ve looked through the sources of the popular up to date chat formatting plugins.
nobody is doing chat formatting right, and the way it is currently, chat formatting plugins will absolutely step on each others feet, even if they do something minor like add a prefix or replace a word with a clickable text.
So I’m asking, does anyone here have some simple guidelines we can follow, so that we can not ruin each others days?
My suggestions would be to (and I welcome people refuting them)
Use TextTemplates where ever possible. TextTemplates allow other plugins to potentially merge / manipulate your template + arguments and reformat them.
Additionally it provides users with a standard way to input formatting into configs.
When possible, insert or append text. Don’t just remove the formatting of someone else, or use raw.
If you are providing variables to chat, give them to all the simple text appliers you can find, at event priority LATE this will allow plugins to have had time to apply their templates, and let you populate it with custom variables.
use a plugin prefix for variable names(PvPTagger.player), the scope is shared by all plugins, don’t be a dick by calling yours “player”
Hopefully if we follow these rules, it means we need less “primary formatters” that will format the entire message directly. If you do need to create a “primary formatter” consider using a MessageChannel transformer, if you do, wrap the previous MessageChannel / transformer.
So in short.
Add variables to others templates, if they exist.
insert templateAppliers but these may be overridden…
If you are a primary formatter(whisper, local chat corrupter, chat channels, admin channels), consider creating a custom MessageChannel.
Do these guidelines sound sane? Is it possible for the API to change to force people to work correctly rather then clobber the formatting? Does the API need to change to become simpler?
I’m keen to hear your thoughts.