forked from foundryvtt/pf2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { MigrationRunner } from '../../module/migration-runner'; | ||
import { Migrations } from '../../module/migrations'; | ||
|
||
export function listen(): void { | ||
// Save the current world schema version if hasn't before. | ||
Hooks.once('renderSettings', () => { | ||
Hooks.once('renderSettings', async () => { | ||
const storedSettings = game.settings.storage.get('world'); | ||
const storedSchemaVersion = storedSettings.getItem('pf2e.worldSchemaVersion'); | ||
if (game.user.isGM && !storedSchemaVersion) { | ||
const currentVersion = game.settings.get('pf2e', 'worldSchemaVersion'); | ||
game.settings.set('pf2e', 'worldSchemaVersion', currentVersion); | ||
const storedSchemaVersion = storedSettings.get('pf2e.worldSchemaVersion'); | ||
if (game.user.isGM && storedSchemaVersion === undefined) { | ||
// If there is no stored schema version, the world is either new or wasn't receiving migrations since | ||
// schema version 0.595 | ||
if ([game.actors.entities, game.items.entities].some((entities) => entities.length > 0)) { | ||
await game.settings.set('pf2e', 'worldSchemaVersion', 0.595); | ||
const migrationRunner = new MigrationRunner(Migrations.constructAll()); | ||
await migrationRunner.runMigration(); | ||
} else { | ||
const currentVersion = game.settings.get('pf2e', 'worldSchemaVersion'); | ||
game.settings.set('pf2e', 'worldSchemaVersion', currentVersion); | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters