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

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

Slav ebb

New member
May 26, 2024
7
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
321
18
68
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))