How to set to the creative mod a player?

Hi, i search how to set a player to the creative mod, how can I ?
public void onJoin(ClientConnectionEvent.Join e) {
Player p = e.getTargetEntity();
e.setMessage(Text.of("§a§l" + p.getName() + “§a a rejoint le jeu.”));

Thank you,


So two things:

  1. IIRC, you should be using something like p.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
  2. Please for the love of everything, do NOT use the § symbol to denotate color. The chat API exists, use it. Use a Text.Builder to set things like color and style and text…

Thank you ! I will do this.

If the text is small enough that a full builder call is overkill, you can pass sequential arguments to the Text.of method.

e.setMessage(Text.of(TextColors.GREEN, TextStyles.BOLD, p.getName(), " a rejoint le jeu."));