Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joining serverr: ERROR is not valid JSON #3363

Open
1 task done
SinanAkkoyun opened this issue Apr 29, 2024 · 2 comments
Open
1 task done

Joining serverr: ERROR is not valid JSON #3363

SinanAkkoyun opened this issue Apr 29, 2024 · 2 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@SinanAkkoyun
Copy link

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.20.1
  • server: vanilla/spigot/paper 1.20.4 spigot
  • node: 21.7.3

Detailed description of a problem

When joining a server like GommeHD.net, following error sometimes occurs:

SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at Client.<anonymous> (/home/ai/.mc/ts-bot/node_modules/minecraft-protocol/src/client/versionChecking.js:6:21)
    at Client.emit (node:events:531:35)
    at Client.emit (node:domain:488:12)
    at emitPacket (/home/ai/.mc/ts-bot/node_modules/minecraft-protocol/src/client.js:83:12)
    at FullPacketParser.<anonymous> (/home/ai/.mc/ts-bot/node_modules/minecraft-protocol/src/client.js:112:9)
    at FullPacketParser.emit (node:events:519:28)
    at FullPacketParser.emit (node:domain:488:12)
    at addChunk (/home/ai/.mc/ts-bot/node_modules/protodef/node_modules/readable-stream/lib/_stream_readable.js:279:12)
    at readableAddChunk (/home/ai/.mc/ts-bot/node_modules/protodef/node_modules/readable-stream/lib/_stream_readable.js:262:11)

The server has a multi-version protocol which lets players from 1.8 to 1.20.4 play together.

What did you try yet?

Your current code

const bot = mineflayer.createBot({
  username,
  auth: 'microsoft',
  version: '1.20.4'
})

It's code independent

Expected behavior

Code should, if invalid JSON, catch that error and instead output string.

Additional context

/

@SinanAkkoyun SinanAkkoyun added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Apr 29, 2024
@overtimepog
Copy link

overtimepog commented May 7, 2024

try

const bot = mineflayer.createBot({
  host: 'server_ip',
  auth: 'microsoft',
  version: '1.20.2',
});

dont worry about the username, if you signed in correctly through microsoft itll know the username

nvm, I tried to move my bot to 1.20.3 and got the same error you did

@SinanAkkoyun
Copy link
Author

I appriceate you trying it out too, it has nothing to do with the username.
Chat messages, names etc inside that server must somehow be wrongly formatted because it's a multi version server (not a mineflayer error per-se I think)
The solution would be: If JSON parsing fails (needs to be done for chat messages, entity names etc), try catch that and return a string instead of JSON

That's just a guess, before I PR anything I'd like to hear an opinion from someone who really knows whats going on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

2 participants