node-minecraft-protocol/test/common/clientHelpers.js
Frej Alexander Nielsen cf1f67117d
Update to 1.19.3 (#1069)
* Add 1.19.3 player_info parsing

* player_remove packet parsing

* 1.19.3 chat parsing

* Outgoing chat for 1.19.3

* Fix lint

* Server chat validation

* add 1.19.2 and 1.19.3 in version.js

* Add 1.19.2 and 1.19.3 in ci.yml

* Deprecated client.verifyMessage for server clients

* Update docs

* Deprecate client.verifyMessage for server clients

* Fix tests

* Fix lint

* Fix packetTest

* Fix test

* Remove unneeded log statement

* Update types/docs

* Remove unnecessary feature check

* Remove _session from docs

Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
2023-01-21 20:31:17 +01:00

24 lines
666 B
JavaScript

module.exports = client => {
client.nextMessage = (containing) => {
return new Promise((resolve) => {
function onChat (packet) {
const m = packet.formattedMessage || packet.unsignedChatContent || JSON.stringify({ text: packet.plainMessage })
if (containing) {
if (m.includes(containing)) return finish(m)
else return
}
return finish(m)
}
client.on('playerChat', onChat)
client.on('systemChat', onChat) // For 1.7.10
function finish (m) {
client.off('playerChat', onChat)
client.off('systemChat', onChat)
resolve(m)
}
})
}
return client
}