PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.89k stars 897 forks source link

SyntaxError: Unexpected token #873

Closed 505051 closed 4 years ago

505051 commented 4 years ago

Versions

Detailed description of a problem

I tried to connect to a server with the bot, but the bot don't work, I don't really know why.

Current code

var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({
  host: "play.hadaria.fr", // optional
  port: 25565,       // optional
  username: "MyEmail", // email and password are required only for
  password: "MyPassword",          // online-mode=true servers
  version: "1.12.2",               // false corresponds to auto version detection (that's the default), put for example "1.8.8" if you need a specific version
  keepAlive: true,
 });
bot.on('message', (message) => {
    console.log(message.toAnsi());
});
bot.on('error', err => console.log(err))

Expected behavior

I've tried to read the chat in the cmd

Additional context

I have this error when I try to join the server :


Auto logged in
Connexion » Connexion effectuée !

undefined:1
{"text":"","extra":[{"text":"\n","color":"yellow"},{"text":"✦ ","color":"yellow"},{"text":"HADARIA ","color":"gold","bold":"true"},{"text":"• ","color":"gray"},{"text":"PvP/Factions ","color":"gold","bold":"true"},{"text":"Farm2Win ","color":"green","bold":"true"},{"text":"N","color":"red","bold":"true"},{"text":"°","color":"red"},{"text":"1 FR ","color":"red","bold":"true"},{"text":"✦
                                                                                                                                                                                                                                                                                                                                                                                                    ^

SyntaxError: Unexpected token
 in JSON at position 388
    at JSON.parse (<anonymous>)
    at Client.bot._client.on (C:\Users\Admin\node_modules\mineflayer\lib\plugins\tablist.js:18:49)
    at emitTwo (events.js:126:13)
    at Client.emit (events.js:214:7)
    at FullPacketParser.deserializer.on (C:\Users\Admin\node_modules\minecraft-protocol\src\client.js:82:12)
    at emitOne (events.js:116:13)
    at FullPacketParser.emit (events.js:211:7)
    at addChunk (C:\Users\Admin\node_modules\readable-stream\lib\_stream_readable.js:297:12)
    at readableAddChunk (C:\Users\Admin\node_modules\readable-stream\lib\_stream_readable.js:279:11)
    at FullPacketParser.Readable.push (C:\Users\Admin\node_modules\readable-stream\lib\_stream_readable.js:240:10)```
wvffle commented 4 years ago

Can you show a screenshot of tablist on the server?

505051 commented 4 years ago

2019-10-28_09 33 46

RedNicStone commented 4 years ago

Same error here Server: 1.8 bukkit, with support for 1.9-1.13 protocolls IP (If someone wants to join and check): spreed.mooo.com:25565

patyhank commented 4 years ago

Same Error here Server: 1.15.2 IP: mcfallout.net image

rom1504 commented 4 years ago

That's a server bug, fix your server

wvffle commented 4 years ago

Same Error here Server: 1.15.2 IP: mcfallout.net image

Or create a new issue. You gave absolutely no context.