import net.minecraft.text.LiteralText;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Formatting;
//send a client message in chat, only client can see
MinecraftClient.getInstance().player.
sendMessage(new LiteralText("message").
formatted(Formatting.WHITE),false);
//this one shows message above hotbar
MinecraftClient.getInstance().player.
sendMessage(new LiteralText("another message").
formatted(Formatting.WHITE),true);