-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings_migrator.js
62 lines (52 loc) · 1.32 KB
/
settings_migrator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* eslint-disable no-param-reassign */
"use strict";
const DefaultSettings = {
"enabled": true,
"alert": false,
// Plants
"harmony_grass": true,
"wild_cobseed": true,
"wild_veridia": true,
"orange_mushroom": true,
"moongourd": true,
"apple_tree": true,
// Mining
"plain_stone": true,
"cobala_ore": true,
"shadmetal_ore": true,
"xermetal_ore": true,
"normetal_ore": true,
"galborne_ore": true,
"pure_duranium_ore": true,
// Energy
"achromic_essence": true,
"crimson_essence": true,
"earth_essence": true,
"azure_essence": true,
"opal_essence": true,
"obsidian_essence": true,
"pure_duranium_crystal": true
};
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if (from_ver === undefined) return { ...DefaultSettings, ...settings };
else if (from_ver === null) return DefaultSettings;
else {
from_ver = Number(from_ver);
to_ver = Number(to_ver);
if (from_ver + 1 < to_ver) {
settings = MigrateSettings(from_ver, from_ver + 1, settings);
return MigrateSettings(from_ver + 1, to_ver, settings);
}
const oldsettings = settings;
switch (to_ver) {
default:
settings = Object.assign(DefaultSettings, {});
for (const option in oldsettings) {
if (settings[option] !== undefined) {
settings[option] = oldsettings[option];
}
}
}
return settings;
}
};