Always check first if a feature is enabled before doing anything else to increase compatibility with other modules

This commit is contained in:
2021-01-27 12:43:47 +01:00
parent 2a9d7e7acb
commit 869fedd128
4 changed files with 10 additions and 5 deletions

View File

@@ -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 ## v1.2.1
### Other ### Other
- Verified compatibility with 0.7.9 - Verified compatibility with 0.7.9

View File

@@ -26,13 +26,13 @@ export function onRenderChatMessage(message, html, data) {
// Creates a chat message stating that a player tried to open a locked door // Creates a chat message stating that a player tried to open a locked door
export function onDoorLeftClick() { export function onDoorLeftClick() {
const state = this.wall.data.ds
const states = CONST.WALL_DOOR_STATES
// Check if this feature is enabled // Check if this feature is enabled
if (!game.settings.get(settingsKey, "lockedDoorAlert")) if (!game.settings.get(settingsKey, "lockedDoorAlert"))
return false return false
const state = this.wall.data.ds
const states = CONST.WALL_DOOR_STATES
// Only create messages when the door is locked. // Only create messages when the door is locked.
if (state != states.LOCKED) if (state != states.LOCKED)
return false return false

View File

@@ -3,7 +3,7 @@ import * as Util from "../util.js"
// Inject settings for synchronized doors // Inject settings for synchronized doors
export function onRederWallConfig(wallConfig, html, data) { export function onRederWallConfig(wallConfig, html, data) {
if (data.isDoor && game.settings.get(settingsKey, "synchronizedDoors")) { if (game.settings.get(settingsKey, "synchronizedDoors") && data.isDoor) {
// Inject settings // Inject settings
const synchronizedSettings = ` const synchronizedSettings = `
<p class="notes">${game.i18n.localize("smart-doors.ui.synchronizedDoors.description")}</p> <p class="notes">${game.i18n.localize("smart-doors.ui.synchronizedDoors.description")}</p>

View File

@@ -2,7 +2,7 @@ import {settingsKey} from "../settings.js"
// Toggles between normal and secret doors // Toggles between normal and secret doors
export function onDoorLeftClick(event) { 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 types = CONST.WALL_DOOR_TYPES
const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR
this.wall.update({door: newtype}) this.wall.update({door: newtype})