Upon joining the server the bot instantly crashes with the message:
D:\Computing\BinCommander\build\js\node_modules\mineflayer\lib\plugins\blocks.js:50
if (!('text' in json)) return ''
^
TypeError: Cannot use 'in' operator to search for 'text' in null
at prepareJson (D:\Computing\BinCommander\build\js\node_modules\mineflayer\lib\plugins\blocks.js:50:22)
at addBlockEntity (D:\Computing\BinCommander\build\js\node_modules\mineflayer\lib\plugins\blocks.js:57:43)
at Client.<anonymous> (D:\Computing\BinCommander\build\js\node_modules\mineflayer\lib\plugins\blocks.js:351:5)
at Client.emit (events.js:210:5)
at FullPacketParser.<anonymous> (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\src\client.js:87:12)
at FullPacketParser.emit (events.js:210:5)
at addChunk (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:298:12)
at readableAddChunk (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:280:11)
at FullPacketParser.Readable.push (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:241:10)
at FullPacketParser.Transform.push (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:139:32)
at FullPacketParser._transform (D:\Computing\BinCommander\build\js\node_modules\protodef\src\serializer.js:81:10)
at FullPacketParser.Transform._read (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:177:10)
at FullPacketParser.Transform._write (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:164:83)
at doWrite (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_writable.js:409:139)
at writeOrBuffer (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_writable.js:398:5)
at FullPacketParser.Writable.write (D:\Computing\BinCommander\build\js\node_modules\protodef\node_modules\readable-stream\lib\_stream_writable.js:307:11)
at Decompressor.ondata (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_readable.js:681:20)
at Decompressor.emit (events.js:210:5)
at addChunk (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_readable.js:298:12)
at readableAddChunk (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_readable.js:280:11)
at Decompressor.Readable.push (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_readable.js:241:10)
at Decompressor.Transform.push (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_transform.js:139:32)
at Decompressor._transform (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\src\transforms\compression.js:52:12)
at Decompressor.Transform._read (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_transform.js:177:10)
at Decompressor.Transform._write (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_transform.js:164:83)
at doWrite (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_writable.js:409:139)
at clearBuffer (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_writable.js:526:7)
at onwrite (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_writable.js:455:7)
at WritableState.onwrite (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_writable.js:160:5)
at Decompressor.afterTransform (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\node_modules\readable-stream\lib\_stream_transform.js:89:3)
at Unzip.cb (D:\Computing\BinCommander\build\js\node_modules\minecraft-protocol\src\transforms\compression.js:70:16)
at Unzip.zlibBufferOnEnd (zlib.js:139:10)
at Unzip.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1184:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Current code
// Handle signs
if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign') {
const prepareJson = (i) => {
const data = blockEntity[`Text${i}`]
if (data === '') return ''
const json = JSON.parse(data)
if (!('text' in json)) return ''
json.text = json.text.replace(/^"|"$/g, '')
return json
}
Expected behavior
Sign packets with invalid json should not cause a crash and be handled properly
Versions
Detailed description of a problem
Upon joining the server the bot instantly crashes with the message:
Current code
Expected behavior
Sign packets with invalid json should not cause a crash and be handled properly
Additional context
The server is
2b2tpvp.net
if you want to test.