diff --git a/index.js b/index.js index e04d17e..2f3d1f8 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const SettingsUI = require('tera-mod-ui').Settings; module.exports = function InstantEverything(mod) { - const PURPOSES = ['enchant', 'upgrade', 'soulbind', 'merge', 'dismantle']; + const PURPOSES = ['enchant', 'upgrade', 'soulbind', 'merge', 'dismantle', 'repair']; let hooks = {}; function hook(purpose, ...args) { @@ -13,6 +13,8 @@ module.exports = function InstantEverything(mod) { let enchanting = null; let upgrading = null; + let repairing = null; + function enable(purpose) { switch (purpose) { case 'enchant': { @@ -49,6 +51,22 @@ module.exports = function InstantEverything(mod) { break; } + case 'repair': { + if(mod.majorPatchVersion >= 79) { + hook('repair', 'C_REGISTER_REPAIR_ITEM', 1, event => { repairing = event }); + + hook('repair', 'C_START_REPAIR_ITEM', 1, event => { + if (repairing && event.contract === repairing.contract) { + mod.send('C_REQUEST_REPAIR_ITEM', 1, repairing); + return false; + } + }); + + hook('repair', 'C_REQUEST_REPAIR_ITEM', 'event', () => false); + } + break; + } + case 'soulbind': { hook('soulbind', 'C_BIND_ITEM_BEGIN_PROGRESS', 1, event => { mod.send('C_BIND_ITEM_EXECUTE', 1, { diff --git a/manifest.json b/manifest.json index 50145d6..5b631bb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "files": { - "index.js": "7dd1ebd434d6557995aa3a2cbfe970012dd934320065dd3f4af2efba59b0c1b4", + "index.js": "d8747e0dda8c6a02e6ac0522b8810e84c01b23739a87b59aecc7e73c73d248fc", "settings_migrator.js": "823fc1c204003a4a782e23b1a0781b9ee48d2865004a8acb73359777c0c067bc", "settings_structure.js": "76520793fad024750498529f19c830819b5d9e3b0ab6aa408caaf32c0c7b2000", "module.json": "874965336c161ab99edd2196c34fd3b5a03f63724a390a9f34712e0df487fbcb" @@ -13,6 +13,10 @@ "C_REGISTER_EVOLUTION_ITEM": 1, "C_REQUEST_EVOLUTION": ["raw", 1], "C_START_EVOLUTION": 1, + + "C_REGISTER_REPAIR_ITEM": 1, + "C_REQUEST_REPAIR_ITEM": ["raw", 1], + "C_START_REPAIR_ITEM": 1, "C_BIND_ITEM_BEGIN_PROGRESS": 1, "C_BIND_ITEM_EXECUTE": ["raw", 1], diff --git a/module.json b/module.json index 6fdb8bc..b4907ca 100644 --- a/module.json +++ b/module.json @@ -6,9 +6,9 @@ "servers": ["https://raw.githubusercontent.com/tera-toolbox-mods/instant-everything/master/"], "options": { "niceName": "InstantEverything", - "settingsVersion": 1, + "settingsVersion": 2, "settingsFile": "config.json", "settingsMigrator": "settings_migrator.js" }, "conflicts": ["instant-enchant", "instant-upgrade", "instant-soulbind", "instant-dismantle", "instant-merge"] -} \ No newline at end of file +} diff --git a/settings_migrator.js b/settings_migrator.js index caad634..4cae770 100644 --- a/settings_migrator.js +++ b/settings_migrator.js @@ -4,6 +4,7 @@ const DefaultSettings = { "soulbind": true, "merge": true, "dismantle": true, + "repair": true, } module.exports = function MigrateSettings(from_ver, to_ver, settings) { @@ -15,6 +16,6 @@ module.exports = function MigrateSettings(from_ver, to_ver, settings) { return DefaultSettings; } else { // Migrate from older version (using the new system) to latest one - throw new Error('So far there is only one settings version and this should never be reached!'); + return Object.assign(Object.assign({}, DefaultSettings), settings); } } diff --git a/settings_structure.js b/settings_structure.js index 43ca4fa..069c0df 100644 --- a/settings_structure.js +++ b/settings_structure.js @@ -23,5 +23,10 @@ module.exports = [ "key": "dismantle", "name": "Instant Dismantling", "type": "bool" + }, + { + "key": "repair", + "name": "Instant Repairing", + "type": "bool" } ];