From 869fedd1287fac616f61ef25f67002f0b504f985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 27 Jan 2021 12:43:47 +0100 Subject: [PATCH] Always check first if a feature is enabled before doing anything else to increase compatibility with other modules --- CHANGELOG.md | 5 +++++ src/features/locked_door_alert.js | 6 +++--- src/features/synchronized_doors.js | 2 +- src/features/toggle_secret_door.js | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e83949..ec85b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## In development +### Bugfix +- Disabled features are now less likely to interfere with other modules, increasing compatibility. + - This module can now be used together with the `Arms Reach` module if the `Toggle Secret Doors` feature is disabled in the settings. + ## v1.2.1 ### Other - Verified compatibility with 0.7.9 diff --git a/src/features/locked_door_alert.js b/src/features/locked_door_alert.js index b14fccf..c060fa5 100644 --- a/src/features/locked_door_alert.js +++ b/src/features/locked_door_alert.js @@ -26,13 +26,13 @@ export function onRenderChatMessage(message, html, data) { // Creates a chat message stating that a player tried to open a locked door export function onDoorLeftClick() { - const state = this.wall.data.ds - const states = CONST.WALL_DOOR_STATES - // Check if this feature is enabled if (!game.settings.get(settingsKey, "lockedDoorAlert")) return false + const state = this.wall.data.ds + const states = CONST.WALL_DOOR_STATES + // Only create messages when the door is locked. if (state != states.LOCKED) return false diff --git a/src/features/synchronized_doors.js b/src/features/synchronized_doors.js index 0322c2b..fd63b31 100644 --- a/src/features/synchronized_doors.js +++ b/src/features/synchronized_doors.js @@ -3,7 +3,7 @@ import * as Util from "../util.js" // Inject settings for synchronized doors export function onRederWallConfig(wallConfig, html, data) { - if (data.isDoor && game.settings.get(settingsKey, "synchronizedDoors")) { + if (game.settings.get(settingsKey, "synchronizedDoors") && data.isDoor) { // Inject settings const synchronizedSettings = `

${game.i18n.localize("smart-doors.ui.synchronizedDoors.description")}

diff --git a/src/features/toggle_secret_door.js b/src/features/toggle_secret_door.js index 4b32684..b2c73c1 100644 --- a/src/features/toggle_secret_door.js +++ b/src/features/toggle_secret_door.js @@ -2,7 +2,7 @@ import {settingsKey} from "../settings.js" // Toggles between normal and secret doors export function onDoorLeftClick(event) { - if (event.data.originalEvent.ctrlKey && game.user.isGM && game.settings.get(settingsKey, "toggleSecretDoors")) { + if (game.settings.get(settingsKey, "toggleSecretDoors") && event.data.originalEvent.ctrlKey && game.user.isGM) { const types = CONST.WALL_DOOR_TYPES const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR this.wall.update({door: newtype})