Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
Sending a String concatenated with variable raises an error in Minecraft

Okay, so, I'm having trouble sending players strings combined with variables. For example, this line of code:

client.write("chat", { message: ("Username:"+data.data[0]["name"].toString())})

This data variable is a JSON object. Printing out

"Username:"+data.data[0]["name"].toString()

Works without an error, but when I try send it to the client, the client disconnects with this error message:

Internal Exception: io.netty.handler.codec.DecoderException: 
com.google.gson.JsonSyntaxException: 
com.google.gson.stream.MalformedJsonException: Use 
JsonReader.setLenient(true) to accept malformed JSON at line 1 column 10

BTW, I'm using npm minecraft-protocol javascript

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I just checked the documentation and the sent message doesn't correspond to the format that should be used.

The json should NOT be in json direclty, but should be stringified. So, such as the usage said, you should use something like that:

var msg = {
  translate: 'chat.type.announcement',
  "with": [
      'Username',
      data.data[0]["name"]
  ]
};
client.write("chat", { message: JSON.stringify(msg), position: 0, sender: '0' });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda