How to set to the creative mod a player?

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

Thank you,

maxou54200.

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… https://jd.spongepowered.org/7.0.0/org/spongepowered/api/text/Text.Builder.html
2 Likes

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."));