Color and Hover problem in TextTemplate

Hello,
I load String in a file, like this one :

§aHello §e{player}§a !

That I transform to a TextTemplate with this method :

private static TextTemplate messageToTextTemplate(String message) {
    String[] splitArg = message.split("(?=\\{)|(?<=})");
    Object[] template = new Object[splitArg.length];
    for(int i = 0; i < splitArg.length; i++) {
        String str = splitArg[i];
        if(str.startsWith("{") && str.endsWith("}"))
            template[i] = TextTemplate.arg(str.substring(1, str.length()-1)).build();
        else
            template[i] = str;
    }
    return TextTemplate.of(template);
}

I apply arguments and I get the Text.
If I send this Text to the player, the hover I added for some arguments (like player above) is present, but the color does not apply for the arguments :
text1
My mouse is on “CanardNocturne”

If I send the same Text but by doing toPlain(), the color is good but the hover disappears :
text2
My mouse is on “CanardNocturne”

How can I do it ?

The problem is that you use color codes. This is strongly discouraged because they cause a lot of issues. This is not sponge side but minecraft side. If you want to convert String <–> Text you should use TextSerializers.

I saw that I can use & instead of § by using TextSerializers.FORMATTING_CODE to get a Text, but I want String <-> TextTemplate, not String <-> Text, unless there is a way to convert
Text <-> TextTemplate ?

I try

@Listener
public void onPlayerConnect(ClientConnectionEvent.Join event) {
   String test = "&aHello &e{player}&a !";
   Text text = TextSerializers.FORMATTING_CODE.deserialize(test);
   TextTemplate template = TextTemplate.of(text);
   HashMap<String,Text> args = new HashMap<>(); 
  args.put("player",Text.builder(event.getTargetEntity().getName()).onHover(TextActions.showText(Text.of("Test"))).build());
   Text finalText = template.apply(args).build();
   event.getTargetEntity().sendMessage(finalText);
}

But it doesn’t work neither
Capture
My mouse is on the {player}