A248 / LibertyBans

The be-all, end-all of discipline.
https://ci.hahota.net:8443/job/LibertyBans/
GNU Affero General Public License v3.0
168 stars 42 forks source link

[Feature Request]: Allow colors in punishment-expired-display #228

Open fabianmakila opened 1 year ago

fabianmakila commented 1 year ago

I have confirmed that ...

Description

Some servers might want to color code the Expired and Not expired texts seen in the /history command to make it easier to differentiate between the two by a quick glance.

My first intuition was to do this which doesn't work currently.

  punishment-expired-display:
     # How do you describe an expired punishment?
    expired: '&cExpired'
     # How do you describe a punishment which is not expired?
    not-expired: '&aNot expired'

I'm proposing the addition of color code support for the two fields above, which would allow the use of colors without adding any additional fields to the configuration.

KoxSosen commented 7 months ago

Hello! I have looked into implementing this feature, but was quickly stopped by an idea.

punishment-expired-display falls under the formatting category, and is responsible for the %HAS_EXPIRED% variable. But, variables are usually used in messages, which allow for color codes to be used. So, using the %HAS_EXPIRED% variable with colors can be accomplished by coloring it like any other message.

But, at the same time I understand that this is not an ideal solution, in terms of the work required to set up messages, since you need to use color codes every time you want to use the variable. Allowing variables under the formatting section to be colored allows for easier messages setup, but it does bring some challenges.

Most sections under the formatting section in the configuration are implemented as Strings as opposed to Components, or TextComponents. They get their values set in Formatter.java#181, and well formatted in messages with punishments down the line. Making them colorable, to my understanding would require a small refactor in the formatting code.