Closed Elikill58 closed 2 years ago
Why you would want to use Bungee components is beyond me, but the issue lies in your serialization. You need to set the builder to allow hex codes and Spigot's stupid hex format like this:
TextComponent name = new TextComponent(BukkitComponentSerializer.legacy().toBuilder().hexColors()
.useUnusualXRepeatedCharacterHexFormat().build().serialize(Nicks.api().getStoredNick(p).join()));
I'll leave this issue open for now in case you have further questions, but the problem does not lie within HexNicks.
Thanks ! I want to use Bungee chat to don't require to include Kyori's repo, and also because it's included from Spigot 1.8 but I understand it's not so well.
Also, I just tried your code, and it's the same as before. Can it come from ViaVersion or something like that ? (I'm with 1.18 client on 1.17 server)
I tested the code I gave you and it seemed to work for me, though I have admittedly very little experience with Bungee components. It is possible via version could have something to do with it? I'm not really the person to be asking given my limited knowledge in this area to be honest.
I just tested with this plugin with /test command :
My setup:
The code of /test
command :
Player p = (Player) sender;
p.sendMessage("HexNicks name:");
TextComponent name = new TextComponent(BukkitComponentSerializer.legacy().toBuilder().hexColors()
.useUnusualXRepeatedCharacterHexFormat().build().serialize(Nicks.api().getStoredNick(p).join()));
p.spigot().sendMessage(name);
Result: (the chat message is to show what it should show)
So, can you tell me more about when you successed with this code ?
I never tested it on a server. I just looked at the output of the text component in console when the builder was applied vs. when it wasn't. When it wasn't I saw the output down-sampling to the closest named text color (which is what it's still doing in your picture). When the code I sent you was applied I saw it serialize the hex colors into the &x&f&f&f... format.
You may get some shit for using Bungee api but these people can probably help you better than I can: https://discord.gg/MMfhJ8F
Describe the bug
First line: Default HexNicks's message Second line: Own message, which use
new TextComponent(BukkitComponentSerializer.legacy().serialize(Nicks.api().getStoredNick(p).join()))
to get the player name (included in fullTextComponent
object, of course).I also tried with
new TextComponent(BungeeComponentSerializer.get().serialize(Nicks.api().getStoredNick(p).join()))
.To Reproduce This code will show the "ugly" message instead of beautiful gradient one
Expected behavior
I'm looking to translate a
Component
into aTextComponent
, to show it everywhere I need itSoftware (please complete the following information):