From 20c520f20c8567a2f70ab28d536d9f48cdeaa76e Mon Sep 17 00:00:00 2001 From: dev7355608 Date: Tue, 24 Sep 2024 14:01:11 +0200 Subject: [PATCH] Fix compatibility with dnd5e 3.x --- module.json | 6 +++--- scripts/main.mjs | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/module.json b/module.json index 127f82a..bba7fd9 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ "email": "dev7355608@gmail.com" } ], - "version": "2.5.0", + "version": "2.5.1", "compatibility": { "minimum": "12", "verified": "12" @@ -60,8 +60,8 @@ }, "url": "https://github.com/dev7355608/vision-5e", "manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json", - "download": "https://github.com/dev7355608/vision-5e/releases/download/v2.5.0/module.zip", - "changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.5.0", + "download": "https://github.com/dev7355608/vision-5e/releases/download/v2.5.1/module.zip", + "changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.5.1", "bugs": "https://github.com/dev7355608/vision-5e/issues", "readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md", "license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE" diff --git a/scripts/main.mjs b/scripts/main.mjs index 18fbd90..375372a 100644 --- a/scripts/main.mjs +++ b/scripts/main.mjs @@ -32,6 +32,8 @@ import VisionModeTruesight from "./vision-modes/truesight.mjs"; import testVisibility from "./test-visibility.mjs"; Hooks.once("init", () => { + const legacy = foundry.utils.isNewerVersion("4.0.0", game.system.version) || game.settings.get("dnd5e", "rulesVersion") === "legacy"; + // Extend Actor, TokenDocument, Token, and TokenHUD CONFIG.Actor.documentClass = ActorMixin(CONFIG.Actor.documentClass); CONFIG.Token.documentClass = TokenDocumentMixin(CONFIG.Token.documentClass); @@ -82,7 +84,7 @@ Hooks.once("init", () => { CONFIG.specialStatusEffects.UNCONSCIOUS = "unconscious"; // Shapechanger detection is not needed in PHB'24 at the momement, because Witch Sight has been changed - if (game.settings.get("dnd5e", "rulesVersion") === "legacy") { + if (legacy) { CONFIG.specialStatusEffects.SHAPECHANGER = "shapechanger"; } @@ -120,7 +122,7 @@ Hooks.once("init", () => { } // Register legacy detection modes - if (game.settings.get("dnd5e", "rulesVersion") === "legacy") { + if (legacy) { for (const detectionModeClass of [ DetectionModeBlindsense, DetectionModeWitchSight, @@ -160,7 +162,7 @@ Hooks.once("init", () => { delete CONFIG.Canvas.visionModes.tremorsense; // Legacy Devil's Sight - if (game.settings.get("dnd5e", "rulesVersion") === "legacy") { + if (legacy) { CONFIG.Canvas.visionModes.devilsSight.updateSource({ canvas: { shader: ColorAdjustmentsSamplerShader,