Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!