mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-19 03:52:34 -05:00
26 lines
715 B
JavaScript
26 lines
715 B
JavaScript
|
module.exports = client => {
|
||
|
const mcData = require('minecraft-data')(client.version)
|
||
|
const hasSignedChat = mcData.supportFeature('signedChat')
|
||
|
|
||
|
client.nextMessage = (containing) => {
|
||
|
return new Promise((resolve) => {
|
||
|
function onChat (packet) {
|
||
|
const m = packet.message || packet.unsignedChatContent || packet.signedChatContent
|
||
|
if (containing) {
|
||
|
if (m.includes(containing)) return finish(m)
|
||
|
else return
|
||
|
}
|
||
|
return finish(m)
|
||
|
}
|
||
|
client.on(hasSignedChat ? 'player_chat' : 'chat', onChat)
|
||
|
|
||
|
function finish (m) {
|
||
|
client.off(hasSignedChat ? 'player_chat' : 'chat', onChat)
|
||
|
resolve(m)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return client
|
||
|
}
|