mineflayer
mineflayer copied to clipboard
message event processing issue.. crash down your bot
- [ ] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: 3.11.2
- server: paper 1.17.1
- node: 16.11.0
Detailed description of a problem
When I put 32*[] on the chatroom:
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
The bot stuck in the event processing,
because I can't see the message
or jsonMsg
in 'message'
or 'messagestr'
event via console.log()
.
What did you try yet?
- Whether
console.log(jsonMsg)
exists, bot crashes down. - When 32[] is sent, the bot stopped any process.
- Take 2 times long to finish processing to display on console as one more [] is sent. 31[] => took 60s to finish. 30[] => took 30s to finish. 29[] => took 15s to finish. 28[] => took 7s to finish. 27[] => took 3s to finish.
Your current code
const mineflayer = require('mineflayer')
const bot = mineflayer.createBot({~Options~})
bot.on('messagestr',(message, messagePosition, jsonMsg)=>{console.log(message)})
Expected behavior
<bot> [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
displayed on the console.
Additional context
Maybe it doesn't work on other servers, but it may works if it's 64[] in singleplayer 1.17.1
Thanks if you try to help out!
can you try adding a return
at the line before there https://github.com/PrismarineJS/mineflayer/blob/8bdce55dc3e0311ab979bc901b53f85becf7abce/lib/plugins/chat.js#L174 and try again?
can you try adding a
return
at the line before therehttps://github.com/PrismarineJS/mineflayer/blob/8bdce55dc3e0311ab979bc901b53f85becf7abce/lib/plugins/chat.js#L174
and try again?
Do you mean:
Thanks @rom1504! it works!
ok I guess that is one valid use case of #2247 then and also of fixing these regex to not be so easy to break
https://github.com/PrismarineJS/mineflayer/issues/2328#issuecomment-985246695 temporary workaround
What is a proper solution for this? A better chat regex?
What is a proper solution for this? A better chat regex?
A proper solution is to make chat regexes in prismarine-chat that support different server chat formats such as vanilla, essential and hypixel. Another thing that could be added to prismarine-chat or minecraft-data is a list of chat regexes for various servers.
The problem with this regex is that it tries to match too many things at once, and matching too many things at once can lead to mistakes or regex dos.