Skip to content

Commit

Permalink
Handle unknown scoreboard objectives (PrismarineJS#3191)
Browse files Browse the repository at this point in the history
* Handle unknown scoreboard objectives

* Fix lint

* Throw as error instead of string

* Use Object.hasOwn instead of in operator

---------

Co-authored-by: Frej Alexander Nielsen <frej@valoks.com>
Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
  • Loading branch information
3 people authored Sep 10, 2023
1 parent e571e54 commit 2e02cee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/plugins/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function inject (bot) {
}

if (packet.action === 2) {
if (!Object.hasOwn(scoreboards, packet.name)) {
bot.emit('error', new Error(`Received update for unknown objective ${packet.name}`))
return
}
scoreboards[packet.name].setTitle(packet.displayText)
bot.emit('scoreboardTitleChanged', scoreboards[packet.name])
}
Expand Down

0 comments on commit 2e02cee

Please sign in to comment.