Store the data version for data migrations at some later point
This commit is contained in:
@@ -11,6 +11,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ui": {
|
"ui": {
|
||||||
|
"messages": {
|
||||||
|
"unknownVersion": "Smart Doors migration failed with the error: Unkown Version. Please report this to the Smart Doors issue tracker. To prevent possible data loss don't use this plugin until this error is fixed."
|
||||||
|
},
|
||||||
"synchronizedDoors": {
|
"synchronizedDoors": {
|
||||||
"description": "State changes of doors in the same synchronization group will be synchronized across scenes. Leave blank to disable synchronization for this door.",
|
"description": "State changes of doors in the same synchronization group will be synchronized across scenes. Leave blank to disable synchronization for this door.",
|
||||||
"groupName": "Synchronization Group"
|
"groupName": "Synchronization Group"
|
||||||
|
|||||||
21
main.js
21
main.js
@@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const settingsKey = "smart-doors";
|
const settingsKey = "smart-doors";
|
||||||
|
const currentDataVersion = "1.0.0"
|
||||||
|
|
||||||
Hooks.once("init", () => {
|
Hooks.once("init", () => {
|
||||||
registerSettings()
|
registerSettings()
|
||||||
@@ -8,6 +9,10 @@ Hooks.once("init", () => {
|
|||||||
hookWallConfigUpdate()
|
hookWallConfigUpdate()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Hooks.once("ready", () => {
|
||||||
|
performMigrations()
|
||||||
|
})
|
||||||
|
|
||||||
// Tint the source door red when a locked alert is hovered
|
// Tint the source door red when a locked alert is hovered
|
||||||
Hooks.on("renderChatMessage", (message, html, data) => {
|
Hooks.on("renderChatMessage", (message, html, data) => {
|
||||||
// Tint the door that generated this message
|
// Tint the door that generated this message
|
||||||
@@ -236,8 +241,24 @@ function synchronizedDoorsRightClick() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function performMigrations() {
|
||||||
|
const dataVersion = game.settings.get(settingsKey, "dataVersion")
|
||||||
|
if (dataVersion === "fresh install")
|
||||||
|
{
|
||||||
|
game.settings.set(settingsKey, "dataVersion", currentDataVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dataVersion != currentDataVersion)
|
||||||
|
ui.notifications.error(game.i18n.localize("smart-doors.ui.messages.unknownVersion"), {permanent: true})
|
||||||
|
}
|
||||||
|
|
||||||
function registerSettings() {
|
function registerSettings() {
|
||||||
|
game.settings.register(settingsKey, "dataVersion", {
|
||||||
|
scope: "world",
|
||||||
|
config: false,
|
||||||
|
type: String,
|
||||||
|
default: "fresh install"
|
||||||
|
})
|
||||||
game.settings.register(settingsKey, "lockedDoorAlert", {
|
game.settings.register(settingsKey, "lockedDoorAlert", {
|
||||||
name: "smart-doors.settings.lockedDoorAlert.name",
|
name: "smart-doors.settings.lockedDoorAlert.name",
|
||||||
hint: "smart-doors.settings.lockedDoorAlert.hint",
|
hint: "smart-doors.settings.lockedDoorAlert.hint",
|
||||||
|
|||||||
Reference in New Issue
Block a user