Skip to content

Commit

Permalink
async migration
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryBeaver committed Sep 8, 2024
1 parent 2660f5d commit 3ab3d1a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
## 4.0.5
- migration is now an asynchronous Task that will not break the module.
## 4.0.4
- translated to Brazilian Portuguese by [Andersants](https://github.com/Andersants)
## 4.0.3
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Beaver's Crafting Module",
"description": "A Module for crafting, brewing, harvesting, mining, fabricating, gathering, character advancement, tech tree, skill tree, ability tree, downtime activities, factions / organisation reputation, quest logs, skill training",
"id": "beavers-crafting",
"version": "4.0.4",
"version": "4.0.5",
"authors": [
{
"name": "angryBeaver",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "4.0.4",
"version": "4.0.5",
"description": "Crafting",
"devDir": "c:\\vtts\\v12.331\\Data\\modules",
"#devDir": "c:\\vtts\\v11.315\\Data\\modules",
Expand Down
33 changes: 18 additions & 15 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ Hooks.on("ready", async function(){
}
})

Hooks.once("beavers-system-interface.ready", async function(){
Settings.init();
if(!game[Settings.NAMESPACE])game[Settings.NAMESPACE]={};
game[Settings.NAMESPACE].Crafting = Crafting;
game[Settings.NAMESPACE].RecipeCompendium = RecipeCompendium;
game[Settings.NAMESPACE].Recipe = Recipe;
game[Settings.NAMESPACE].Settings = Settings;
game[Settings.NAMESPACE].migrateRecipeAddItemType = itemTypeMigration;
game[Settings.NAMESPACE].migrateRecipeSkillToTests= migrateRecipeSkillToTests;
game[Settings.NAMESPACE].migrateDeprecateTools= migrateDeprecateTools;
game[Settings.NAMESPACE].migrateRecipeToOrConditions= migrateRecipeToOrConditions;
game[Settings.NAMESPACE].migrateRecipeTestsToBeaversTests= migrateRecipeTestsToBeaversTests;

hookChatLog();
async function migrate(){
const version = Settings.get(Settings.MAJOR_VERSION);
if(version == 2){
await migrateDeprecateTools();
Expand All @@ -51,11 +38,27 @@ Hooks.once("beavers-system-interface.ready", async function(){
await migrateRecipeToOrConditions();
}
if(version < 400){
await new Promise(resolve => setTimeout(resolve, 1000));
await new Promise(resolve => setTimeout(resolve, 10000));
await migrateRecipeTestsToBeaversTests();
}
Settings.set(Settings.MAJOR_VERSION,400);
}

Hooks.once("beavers-system-interface.ready", async function(){
Settings.init();
if(!game[Settings.NAMESPACE])game[Settings.NAMESPACE]={};
game[Settings.NAMESPACE].Crafting = Crafting;
game[Settings.NAMESPACE].RecipeCompendium = RecipeCompendium;
game[Settings.NAMESPACE].Recipe = Recipe;
game[Settings.NAMESPACE].Settings = Settings;
game[Settings.NAMESPACE].migrateRecipeAddItemType = itemTypeMigration;
game[Settings.NAMESPACE].migrateRecipeSkillToTests= migrateRecipeSkillToTests;
game[Settings.NAMESPACE].migrateDeprecateTools= migrateDeprecateTools;
game[Settings.NAMESPACE].migrateRecipeToOrConditions= migrateRecipeToOrConditions;
game[Settings.NAMESPACE].migrateRecipeTestsToBeaversTests= migrateRecipeTestsToBeaversTests;

hookChatLog();
migrate();
beaversSystemInterface.addExtension(Settings.NAMESPACE,{componentAddFlags:["crafted","isCrafted"]})

if(Settings.get(Settings.SEPARATE_CRAFTED_ITEMS) === "full"){
Expand Down

0 comments on commit 3ab3d1a

Please sign in to comment.