KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
716 stars 107 forks source link

An editable color registry, i.e. custom named colors #1101

Open Romindous opened 2 months ago

Romindous commented 2 months ago

So, as it stands, there is a set number of named colors that are recognized by adventure, and are used by minimessage. One can "add" more colors by using a TagResolver, which should substitute a hex code when reading the tag name (1st image) image

However, the problem shows when the new color isn't in a simple form, such as by using a gradient, where the name is simply not recognized (2nd image) image

Could we maybe get a way to straight up add NamedTextColors? Maybe some way to register them in minimessage?

WasabiThumb commented 2 months ago

NamedTextColor is global state (essentially an enum) and probably not a good idea to modify, custom colors should only exist within the lifetime of the MiniMessage instance they are attached to. If you just want to create your own TextColor enums, you can accomplish this with a class in your own namespace.

This could maybe look like builder().color("name", /* TextColor instance */) with perhaps helper methods for hex codes/RGB int literals

Watching this in case I have to implement it in minimessage-js ;)