How to use hex color in TextComponent

ILikeBananas

New member
Aug 8, 2024
2
0
1
Hello i'm currently coding a plugin that shod be as much customizable as possible so i'm make a command that returns a message that has some text and on part of it you can click to run a command now the problem is i have a config in that config you can change the message that you receive, and you can use hex colors like this &x&f&f&0&0&f&f you can also change what the color character is default is & now i have a function that replaces the color character for example & width § in the message and then returns it but when i then make Component.text(myColorFormatter(message)) then the message is not in color it just takes the last §f for example and then sets the color to that can anyone help me how to fix that?
 

stefvanschie

Moderator
Staff member
Dec 17, 2021
121
7
21
18
Components don't work with legacy color codes. If you want to turn text with legacy color codes into a Component, you should use the LegacyComponentSerializer.