Skip to content

Commit

Permalink
Added support for 0.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sneat authored May 19, 2021
2 parents 491092b + 862e0fd commit 3e8d28d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

**NOTE** This is an unofficial forked version of the module maintained by the League of Foundry Developers to provide module continuity while Forien is unavailable.

**[Compatibility]**: *FoundryVTT* 0.7.0+
**[Compatibility]**: *FoundryVTT* 0.6.0 - 0.8.0+

**[Systems]**: *any*

This module allows for fast copy/save environment data such as core version or list of installed modules and their versions. Supports copying as TXT or saving as JSON.
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### v2.0.3

* Added 0.8.4 compatibility

### v2.0.2

* Tested 0.8.1 compatibility
Expand Down
25 changes: 14 additions & 11 deletions module.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
"name": "forien-copy-environment",
"title": "Forien's Copy Environment",
"description": "Allows for copying TXT/JSON list of system/modules and versions, and gives ability to export/import game and player settings",
"version": "2.0.2",
"version": "2.0.3",
"library": "false",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.8.1",
"compatibleCoreVersion": "0.8.4",
"author": "Forien — Forien#2130",
"authors": [{
"authors": [
{
"name": "Forien",
"url": "https://www.patreon.com/forien"
},
{
"name": "The League of Extraordinary FVTT Developers",
"name": "The League of Extraordinary FoundryVTT Developers",
"url": "https://github.com/League-of-Foundry-Developers"
},
{
Expand All @@ -28,15 +29,17 @@
"styles": [
"/styles/module.css"
],
"languages": [{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
],
"url": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment",
"manifest": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment/releases/latest/download/module.json",
"download": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment/releases/download/2.0.2/module.zip",
"download": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment/releases/latest/download/module.zip",
"bugs": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment/issues",
"changelog": "https://github.com/League-of-Foundry-Developers/foundryvtt-forien-copy-environment/blob/master/changelog.md",
"allowBugReporter": true
}
}
54 changes: 49 additions & 5 deletions scripts/core.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default class Core extends FormApplication {
Core.processSettings(changes).then(() => {
ui.notifications.info(
game.i18n.localize('forien-copy-environment.updatedReloading'),
{}
{},
);
window.setTimeout(window.location.reload.bind(window.location), 5000);
});
Expand Down Expand Up @@ -192,7 +192,7 @@ export default class Core extends FormApplication {
game.i18n.format('forien-copy-environment.import.updatedPlayer', {
name: targetUser.name,
}),
{}
{},
);
}

Expand Down Expand Up @@ -255,7 +255,7 @@ export default class Core extends FormApplication {

ui.notifications.info(
game.i18n.localize('forien-copy-environment.copiedToClipboard'),
{}
{},
);
}

Expand Down Expand Up @@ -299,7 +299,7 @@ export default class Core extends FormApplication {
role: u.data.role,
},
flags: u.data.flags,
}))
})),
);
this.download(data, 'foundry-settings-export.json');
}
Expand Down Expand Up @@ -329,6 +329,50 @@ export default class Core extends FormApplication {
}

static async processSettings(settings) {
if (isNewerVersion(game.data.version, '0.7.9')) {
const updates = [];
const creates = [];
settings.forEach(data => {
const config = game.settings.settings.get(data.key);
if (config?.scope === 'client') {
const storage = game.settings.storage.get(config.scope);
if (storage) {
storage.setItem(setting.key, setting.value);
}
} else if (game.user.isGM) {
const existing = game.data.settings.find((s) => s.key === data.key);
if (existing?._id) {
data._id = existing._id;
updates.push(data);
} else {
creates.push(data);
}
}
});
try {
if (updates.length) {
await SocketInterface.dispatch('modifyDocument', {
type: 'Setting',
action: 'update',
updates: updates,
});
}
if (creates.length) {
await SocketInterface.dispatch('modifyDocument', {
type: 'Setting',
action: 'create',
data: creates,
});
}
} catch (e) {
log(
false,
`Settings update could not be dispatched to server.`,
);
console.error(e);
}
return;
}
for (const setting of settings) {
const config = game.settings.settings.get(setting.key);
if (config?.scope === 'client') {
Expand All @@ -344,7 +388,7 @@ export default class Core extends FormApplication {
} catch (e) {
log(
false,
`Setting key ${setting.key} could not be dispatched to server.`
`Setting key ${setting.key} could not be dispatched to server.`,
);
console.error(e);
}
Expand Down
Empty file modified scripts/setting.js
100644 → 100755
Empty file.

0 comments on commit 3e8d28d

Please sign in to comment.