From 2e02cee82d6d154b3b7bfb30d213479e7c4fbc59 Mon Sep 17 00:00:00 2001 From: Frej Alexander Nielsen Date: Sun, 10 Sep 2023 20:55:06 +0200 Subject: [PATCH] Handle unknown scoreboard objectives (#3191) * 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 Co-authored-by: Romain Beaumont --- lib/plugins/scoreboard.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/plugins/scoreboard.js b/lib/plugins/scoreboard.js index fa071f09f..f29d669f2 100644 --- a/lib/plugins/scoreboard.js +++ b/lib/plugins/scoreboard.js @@ -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]) }