'Using Components with .color changing the color sets it to the wrong color for whatever reason [Paper,Java,Plugin,Minecraft]
I am using Paper 1.16.5 minecraft and trying to make a system for people to have chat tags. It somehow makes the players name appear red instead of the supposed white
package de.zbinfinn.mining_game.chatstuff;
import de.zbinfinn.mining_game.Mining_Game;
import io.papermc.paper.chat.ChatRenderer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ChatRendererClass implements ChatRenderer {
@Override
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
Component finalMessage = Mining_Game.INSTANCE.prefixes.get(source.getName())
.append(Component.text(" " + source.getName() + ": ").color(TextColor.color(Mining_Game.INSTANCE.namecolors.get(source.getName())))
.append(message).color(TextColor.color(Mining_Game.INSTANCE.chatcolors.get(source.getName()))));
return finalMessage;
}
}
Solution 1:[1]
Someone just explained this to me so basically the Styles are taken from the parent common practice is to just do:
Component.empty()
.append(a)
.append(b)
.append(c)
Leaving this here for people that might need help in the future
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ouflak |
