Write chat

[FR]
Bonjour,
j’aimerais savoir si on peut faire en sorte que quand on clique sur un mot l’écrire dans le chat comme la commande /help.

J’ai cliqué sur ma commande /couleur et ça la écrit dans le chat:

[EN]
Hello,
I wonder if we can ensure that when you click on a word write chat as the command / help.

I clicked on my order /couleur and it writes the chat:

So you want that when the help text is clicked, it fills in “/help couleur” ?

J’ai trouvé:

Text.builder("/couleur")
.color(TextColors.AQUA)
.onShiftClick(TextActions.insertText("/couleur"))
.build(),

Moi je veux faire:

Text.builder("/couleur")
.color(TextColors.AQUA)
.onClick(TextActions.insertText("/couleur"))
.build(),

[FR]
Utilise suggestCommand à la place de insertText dans ton code
[EN]
Use suggestCommand instead of insertText in your code

[FR]
J’aime pas onShiftClick, mais au moins ça rajoute le texte contrairement à suggestCommand

[EN]
I do not like “onShiftClick”, but at least it adds the text unlike “suggestCommand”;

Exemple:

    public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
        Player player = (Player) sender;
        
        Builder pseudo = Text.builder();
        int i = 0;
        for(Player p : Sponge.getPlayers()) {
            String n = "";
            if(i != (Sponge.getPlayers().size() - 1)) {
                n += "\n";
            }
            pseudo.append(
                    Text.builder(p.getName() + n)
                    .color(TextColors.GRAY)
                    .onClick(TextActions.suggestCommand("/kick " + p.getName() + " "))
                    .build());
            i++;
        }
        
        PaginationService paginationService = Sponge.getGame().getServiceManager().provide(PaginationService.class).get();
        paginationService.builder()
        .title(
                Text.builder("Commande kick")
                .build()
        )
        .contents(
                Text.builder("Cliquer sur un pseudo.\n"
                + "Ensuite cliqué sur une raison de kick avec clic + la touche Shift.\n"
                + "Si aucune raison ne convient merci de la préciser manuellement.")
                .color(TextColors.GREEN)
                .build(),

                Text.builder("----------").build(),

                Text.builder("Les joueurs:")
                .onHover(TextActions.showText(
                    Text.builder("Reset texte")
                    .build()
                ))
                .onClick(TextActions.suggestCommand(""))
                .build(),
                
                pseudo.build(),

                Text.builder("----------").build(),
                
                Text.builder("Raison du kick:")
                .color(TextColors.AQUA)
                .build(),

                Text.builder("Raison n°1: j'ai envie de te faire chier")
                .color(TextColors.GRAY)
                .onShiftClick(TextActions.insertText("J'ai envie de te faire chier"))
                .build(),
                
                Text.builder("Raison n°2: Pas de flood dans le chat, merci.")
                .color(TextColors.GRAY)
                .onShiftClick(TextActions.insertText("Pas de flood dans le chat, merci."))
                .build()
                
        )
        .paddingString("*")
        .sendTo(player);

        return CommandResult.success();
    }