How to have two separate colors in the same text component?

Slav ebb

New member
May 26, 2024
6
1
3
Hi, i'd like to have two separate colors in the same text component, i tried to do it in the code below, but it doesn't seem to work.
StrTex =Component.text("ОСТЕРЕГАЙТЕСЬ МОЛНИЙ!") .color(TextColor.fromHexString("FFFFFF")); nameTex=Component.text("⚡ ГРОЗА!") .color(TextColor.fromHexString("#ffd700")); Bukkit.getServer().sendMessage(nameTex.append(StrTex));
 

electronicboy

Administrator
Staff member
Dec 11, 2021
297
18
59
28
a text component has an color, and an contents; if you want a component with 2 different colors and 2 bits of text; then you want 2 different components, and a parent to hold them together;
i.e. Component.text().append(Component.text("a", NTC.RED)).append(Component.text("b",NTC.BLUE))