From f5d4f691a3e81f7c94f5f1ae283af367ad97dd0c Mon Sep 17 00:00:00 2001 From: gerads Date: Thu, 26 May 2022 00:33:09 -0500 Subject: [PATCH] Check that game.keybindings exists before using This does not exist in 8.9 and was added in v9, breaking anybody still on 8.9. --- party-overview.js | 58 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/party-overview.js b/party-overview.js index 368fd4e..b1ade01 100644 --- a/party-overview.js +++ b/party-overview.js @@ -10,34 +10,36 @@ Hooks.once("init", () => { registerApiSettings(); partyOverview = new PartyOverviewApp(); - game.keybindings.register("party-overview", "openPartyOverview", { - name: game.i18n.localize("party-overview.keybinds.open.name"), - hint: game.i18n.localize("party-overview.keybinds.open.hint"), - onDown: () => { - partyOverview.render(true); - }, - onUp: () => {}, - precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, - }); - game.keybindings.register("party-overview", "closePartyOverview", { - name: game.i18n.localize("party-overview.keybinds.close.name"), - hint: game.i18n.localize("party-overview.keybinds.close.hint"), - onDown: () => { - partyOverview.close(); - }, - onUp: () => {}, - precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, - }); - game.keybindings.register("party-overview", "togglePartyOverview", { - name: game.i18n.localize("party-overview.keybinds.toggle.name"), - hint: game.i18n.localize("party-overview.keybinds.toggle.hint"), - onDown: () => { - if (!partyOverview.rendering) partyOverview.render(true); - else partyOverview.close(); - }, - onUp: () => {}, - precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, - }); + if (game.keybindings) { + game.keybindings.register("party-overview", "openPartyOverview", { + name: game.i18n.localize("party-overview.keybinds.open.name"), + hint: game.i18n.localize("party-overview.keybinds.open.hint"), + onDown: () => { + partyOverview.render(true); + }, + onUp: () => {}, + precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, + }); + game.keybindings.register("party-overview", "closePartyOverview", { + name: game.i18n.localize("party-overview.keybinds.close.name"), + hint: game.i18n.localize("party-overview.keybinds.close.hint"), + onDown: () => { + partyOverview.close(); + }, + onUp: () => {}, + precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, + }); + game.keybindings.register("party-overview", "togglePartyOverview", { + name: game.i18n.localize("party-overview.keybinds.toggle.name"), + hint: game.i18n.localize("party-overview.keybinds.toggle.hint"), + onDown: () => { + if (!partyOverview.rendering) partyOverview.render(true); + else partyOverview.close(); + }, + onUp: () => {}, + precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL, + }); + } return loadTemplates([ "modules/party-overview/templates/parts/Tabs.html", "modules/party-overview/templates/parts/FilterButton.html",