I have this code:
Where hex is a string from config (staff.1.color):
But the nickname has default color in the chat:

Java:
public Component prepareName(Player p, String hex) {
String hint = this.config.getString("name-hint");
return miniMessage.deserialize(p.getName())
.hoverEvent(HoverEvent.showText(miniMessage.deserialize(hint)))
.color(TextColor.fromHexString(hex))
.clickEvent(ClickEvent.runCommand("/playerinfo " + p.getName())
);
}
YAML:
staff:
1:
prefix: ''
color: '#8a8690'
Java:
Component message = plugin.miniMessage.deserialize(
Objects.requireNonNull(plugin.config.getString("chat.local.text")),
Placeholder.component("rank",
Component.text(rankPrefix).color(TextColor.fromHexString(color))
.hoverEvent(HoverEvent.showText(plugin.miniMessage.deserialize(rankHint)))
),
Placeholder.component("playername", plugin.prepareName(pl, color)),
Placeholder.component("message", e.originalMessage())
);

Last edited: