Store the data version for data migrations at some later point
This commit is contained in:
21
main.js
21
main.js
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const settingsKey = "smart-doors";
|
||||
const currentDataVersion = "1.0.0"
|
||||
|
||||
Hooks.once("init", () => {
|
||||
registerSettings()
|
||||
@@ -8,6 +9,10 @@ Hooks.once("init", () => {
|
||||
hookWallConfigUpdate()
|
||||
})
|
||||
|
||||
Hooks.once("ready", () => {
|
||||
performMigrations()
|
||||
})
|
||||
|
||||
// Tint the source door red when a locked alert is hovered
|
||||
Hooks.on("renderChatMessage", (message, html, data) => {
|
||||
// Tint the door that generated this message
|
||||
@@ -236,8 +241,24 @@ function synchronizedDoorsRightClick() {
|
||||
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() {
|
||||
game.settings.register(settingsKey, "dataVersion", {
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: String,
|
||||
default: "fresh install"
|
||||
})
|
||||
game.settings.register(settingsKey, "lockedDoorAlert", {
|
||||
name: "smart-doors.settings.lockedDoorAlert.name",
|
||||
hint: "smart-doors.settings.lockedDoorAlert.hint",
|
||||
|
||||
Reference in New Issue
Block a user