Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Discord->Minecraft Chat Formatting. #3

Draft
wants to merge 3 commits into
base: dev/1.18.x
Choose a base branch
from

Conversation

TheCurle
Copy link
Contributor

@TheCurle TheCurle commented Feb 24, 2022

It's pretty fun to have your messages formatted in-game.

This allows people to send messages in discord with either Legacy style, or Concord style chat formatting sequences, and it will show in-game appropriately.

The custom Concord system i implemented works as follows:

  • Every key begins with a $ character
  • English-language words can be written after the $ (ie. $red) followed by a space, to apply that formatting in-game
  • Hex color codes can be written after the $ (ie. $#FF0000) followed by a space, to apply that formatting in-game

Because it leverages the TextColor parsing system, it does not work with formatting codes, such as bold or italic.

Legacy formatting consists of the old Minecraft section codes, but with an ampersand (&) instead.

A full list of Legacy sequences and the valid english-language color names, for future reference:

&0: color black
&1: color dark_blue
&2: color dark_green
&3: color dark_aqua
&4: color dark_red
&5: color dark_purple
&6: color gold
&7: color gray
&8: color dark_gray
&9: color blue
&a: color green
&b: color aqua
&c: color red
&d: color light_purple
&e: color yellow
&f: color white

&k: effect obfuscated (makes the letters scrambled and unreadable)
&l: effect bold
&m: effect strikethrough (a single thin line through the whole text)
&n: effect underline
&o: effect italic
&r: effect reset (undoes all of the effect formatting)

There are two known "issues" with this implementation:

  • Formatting cannot be chained; ie, you can't do &l&5 to get bold purple text.
  • It looks like ass

They can both be fixed with time, but i wanted to get this code on screen for you to look at.

@sciwhiz12 sciwhiz12 added the feature New feature or request label Feb 24, 2022
@TheCurle
Copy link
Contributor Author

Updated for RGB and English language colors.

@zml2008
Copy link

zml2008 commented Feb 24, 2022

Can I encourage you to align your formatting system with other rich text-focused projects? (entirely unbiased, I know) I have MiniMessage which is used in a fair few places across the community, and while I don't expect you to directly depend on the library or anything, but I do think it would be neat if this format was somewhat aligned with what we do.

@TheCurle
Copy link
Contributor Author

I'm all for standardising formatting!

I just implemented this because it was the path of least resistance (and I've implemented something incredibly similar for a personal project).

Marked this PR as draft until I align it closer to MiniMessage.

@TheCurle TheCurle marked this pull request as draft February 24, 2022 03:37
@sciwhiz12
Copy link
Owner

As a side-note because MiniMessage was mentioned here, I do have some future plans to use KyoriPowered's adventure library alongside the MCDiscordReserializer library by Vankka for proper Minecraft-to-Discord rendering of formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants