TeraProxy лет назад: 7
Родитель
Сommit
9c8fc1a8d7
4 измененных файлов с 58 добавлено и 74 удалено
  1. 11 22
      index.js
  2. 19 19
      manifest.json
  3. 3 3
      module.json
  4. 25 30
      settings_migrator.js

+ 11 - 22
index.js

@@ -7,17 +7,6 @@ const ITEMS_NOSTRUM = [152898, 184659, 201005, 201006, 201007, 201008, 201022, 8
 
 
 module.exports = function Essentials(mod) {
 module.exports = function Essentials(mod) {
 
 
-	if(mod.proxyAuthor !== 'caali') {
-		const options = require('./module').options
-		if(options) {
-			const settingsVersion = options.settingsVersion
-			if(settingsVersion) {
-				mod.settings = require('./' + (options.settingsMigrator || 'module_settings_migrator.js'))(mod.settings._version, settingsVersion, mod.settings)
-				mod.settings._version = settingsVersion
-			}
-		}
-	}
-
 	mod.game.initialize("contract")
 	mod.game.initialize("contract")
 
 
 	let slot = null,
 	let slot = null,
@@ -88,8 +77,8 @@ module.exports = function Essentials(mod) {
 	}
 	}
 
 
 	function useNostrum() {
 	function useNostrum() {
-		for(let buff of BUFF_NOSTRUM) // Use Nostrum only when less than 5 minutes remaining
-			if(abnormalityDuration(buff) > 300000 || !mod.settings.useNostrum) return
+		for(let buff of BUFF_NOSTRUM) // Use Nostrum only when less than nostrumTime
+			if(abnormalityDuration(buff) > mod.settings.nostrumTime * 60000 || !mod.settings.useNostrum) return
 
 
 		if(!mod.game.isIngame || mod.game.isInLoadingScreen || !mod.game.me.alive || mod.game.me.mounted || mod.game.me.inBattleground || mod.game.contract.active) return
 		if(!mod.game.isIngame || mod.game.isInLoadingScreen || !mod.game.me.alive || mod.game.me.mounted || mod.game.me.inBattleground || mod.game.contract.active) return
 		if(mod.game.me.zone < 9000 && mod.settings.dungeonOnly) return
 		if(mod.game.me.zone < 9000 && mod.settings.dungeonOnly) return
@@ -101,8 +90,8 @@ module.exports = function Essentials(mod) {
 	}
 	}
 
 
 	function useCCB() {
 	function useCCB() {
-		for(let buff of BUFF_CCB) // Use CCB only when less than 10 minutes remaining
-			if(abnormalityDuration(buff) > 600000 || !mod.settings.useCCB) return
+		for(let buff of BUFF_CCB) // Use CCB only when less than CCBTime
+			if(abnormalityDuration(buff) > mod.settings.CCBTime * 60000 || !mod.settings.useCCB) return
 
 
 		if(!mod.game.isIngame || mod.game.isInLoadingScreen || !mod.game.me.alive || mod.game.me.mounted || mod.game.me.inBattleground || mod.game.contract.active) return
 		if(!mod.game.isIngame || mod.game.isInLoadingScreen || !mod.game.me.alive || mod.game.me.mounted || mod.game.me.inBattleground || mod.game.contract.active) return
 		if(mod.game.me.zone < 9000 && mod.settings.dungeonOnly) return
 		if(mod.game.me.zone < 9000 && mod.settings.dungeonOnly) return
@@ -115,8 +104,8 @@ module.exports = function Essentials(mod) {
 		if(counter > 5) {
 		if(counter > 5) {
 			let missing = (item == mod.settings.nostrum) ? 'Nostrums' : 'Crystalbinds'
 			let missing = (item == mod.settings.nostrum) ? 'Nostrums' : 'Crystalbinds'
 			enabled = false
 			enabled = false
-			mod.command.message(niceName + 'You ran out of ' + missing + ' (ID: ' + item + '). Essentials has been disabled. Please restock and enable the module again by typing "essentials" in this chat.')
-			console.log('[Essentials] You ran out of ' + missing + ' (ID: ' + item + '). Essentials has been disabled. Please restock and enable the module again by typing "essentials" in proxy chat.')
+			mod.command.message(niceName + 'You ran out of ' + missing + ' (ID: ' + item + '). Essentials has been disabled. Please restock and enable the module again by typing "ess" in this chat.')
+			console.log('[Essentials] You ran out of ' + missing + ' (ID: ' + item + '). Essentials has been disabled. Please restock and enable the module again by typing "ess" in proxy chat.')
 			return
 			return
 		}
 		}
 		if(!resetcount) resetcount = setTimeout(() => { counter = 0; resetcount = null }, 15000)
 		if(!resetcount) resetcount = setTimeout(() => { counter = 0; resetcount = null }, 15000)
@@ -152,19 +141,19 @@ module.exports = function Essentials(mod) {
 	// ### Commands ### //
 	// ### Commands ### //
 	// ################ //
 	// ################ //
 
 
-	mod.command.add('essentials', (param) => {
-		if(param == null) {
+	mod.command.add(['essentials', 'ess'], (cmd) => {
+		if(cmd == null) {
 			enabled = !enabled
 			enabled = !enabled
 			mod.command.message(niceName + 'Essentials ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
 			mod.command.message(niceName + 'Essentials ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
 			console.log('Essentials ' + (enabled ? 'enabled' : 'disabled'))
 			console.log('Essentials ' + (enabled ? 'enabled' : 'disabled'))
 		}
 		}
-		else if(param == "dungeons" || param == "dungeons" || param == "dung") {
+		else if(cmd == "dungeon" || cmd == "dungeons" || cmd == "dung") {
 			mod.settings.dungeonOnly = !mod.settings.dungeonOnly
 			mod.settings.dungeonOnly = !mod.settings.dungeonOnly
 			mod.command.message(niceName + 'Items will be used ' + (mod.settings.dungeonOnly ? 'everywhere' : 'in dungeons only'))
 			mod.command.message(niceName + 'Items will be used ' + (mod.settings.dungeonOnly ? 'everywhere' : 'in dungeons only'))
 		}
 		}
 		else mod.command.message('Commands:\n'
 		else mod.command.message('Commands:\n'
-			+ ' "essentials" (enable/disable Essentials),\n'
-			+ ' "essentials dungeon" (switch between using items everywhere or only in dungeons)'
+			+ ' "ess" (enable/disable Essentials),\n'
+			+ ' "ess dungeon" (switch between using items everywhere or only in dungeons)'
 		)
 		)
 	})
 	})
 }
 }

+ 19 - 19
manifest.json

@@ -1,21 +1,21 @@
 {
 {
-	"files": {
-		"LICENSE": "589ed823e9a84c56feb95ac58e7cf384626b9cbf4fda2a907bc36e103de1bad2",
-		"README.md": "bba1c212104617248764052ed7e1b12c3250c6f28853ca888a984068de882085",
-		"config.json": {
-			"overwrite": false,
-			"hash": "529973b75ba5a07bfeb1b86b99f7fdb60bf78b435afd64b6e84382f077533ec7"
-		},
-		"index.js": "3c175a1765c3f8b99ab5f06fbf5cce4d6a85abd53baaa86e5e0cdd05f212389a",
-		"module.json": "e6824fd3173a9b51be05dea1d617817df03cabc041c5d302a45ec1fa121a0af9",
-		"settings_migrator.js": "b6cd4c0b82a975d56663951b7bb9a839201ab90fef123e41902871057831ee95"
-	},
-	"defs": {
-		"C_PCBANGINVENTORY_USE_SLOT": 1,
-		"C_USE_ITEM": 3,
-		"S_ABNORMALITY_BEGIN": 3,
-		"S_ABNORMALITY_END": 1,
-		"S_ABNORMALITY_REFRESH": 1,
-		"S_PCBANGINVENTORY_DATALIST": 1
-	}
+    "files": {
+        "LICENSE": "589ed823e9a84c56feb95ac58e7cf384626b9cbf4fda2a907bc36e103de1bad2",
+        "README.md": "bba1c212104617248764052ed7e1b12c3250c6f28853ca888a984068de882085",
+        "config.json": {
+            "overwrite": false,
+            "hash": "f37583b51ed6c475cc38f812a13ae52b784f5f319be8560f94cbf0c7f7a80db2"
+        },
+        "index.js": "48a1d269381dd8c3a7b693a0e436559bbd8298923e1e12d4869f28f2613c0a03",
+        "module.json": "ecb33b75fad9b78238a60173150597ed65f8a0d0ee0706c6d14cc2b744cd7f1c",
+        "settings_migrator.js": "0da6c1e6f7d14d980db286eb577e2e181cfcba44d9bc7dc0601db6c0020a2a03"
+    },
+    "defs": {
+        "C_PCBANGINVENTORY_USE_SLOT": 1,
+        "C_USE_ITEM": 3,
+        "S_ABNORMALITY_BEGIN": 3,
+        "S_ABNORMALITY_END": 1,
+        "S_ABNORMALITY_REFRESH": 1,
+        "S_PCBANGINVENTORY_DATALIST": 1
+    }
 }
 }

+ 3 - 3
module.json

@@ -1,14 +1,14 @@
 {
 {
-    "disableAutoUpdate": false,
+    "disableAutoUpdate": true,
     "name": "Essentials",
     "name": "Essentials",
     "author": "Pinkie Pie / Caali / TeraProxy",
     "author": "Pinkie Pie / Caali / TeraProxy",
     "description": "A tera-proxy module that automatically uses Nostrum/Battle Solution and Complete Crystalbind items whenever needed.",
     "description": "A tera-proxy module that automatically uses Nostrum/Battle Solution and Complete Crystalbind items whenever needed.",
-    "version": "2.1.1",
+    "version": "2.2.0",
     "donationUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=A3KBZUCSEQ5RJ",
     "donationUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=A3KBZUCSEQ5RJ",
     "options": {
     "options": {
         "niceName": "Essentials",
         "niceName": "Essentials",
         "guiName": "Essentials",
         "guiName": "Essentials",
-        "settingsVersion": 4,
+        "settingsVersion": 5,
         "settingsFile": "config.json",
         "settingsFile": "config.json",
         "settingsMigrator": "settings_migrator.js"
         "settingsMigrator": "settings_migrator.js"
     },
     },

+ 25 - 30
settings_migrator.js

@@ -3,6 +3,8 @@
 const DefaultSettings = {
 const DefaultSettings = {
 	"useNostrum": true,
 	"useNostrum": true,
 	"useCCB": true,
 	"useCCB": true,
+	"nostrumTime": 5,
+	"CCBTime": 10,
 	"dungeonOnly": false,
 	"dungeonOnly": false,
 	"log": false,
 	"log": false,
 	"nostrum": 200999,
 	"nostrum": 200999,
@@ -10,41 +12,34 @@ const DefaultSettings = {
 }
 }
 
 
 module.exports = function MigrateSettings(from_ver, to_ver, settings) {
 module.exports = function MigrateSettings(from_ver, to_ver, settings) {
-    if (from_ver === undefined) {
-        // Migrate legacy config file
-        return Object.assign(Object.assign({}, DefaultSettings), settings);
-    } else if (from_ver === null) {
-        // No config file exists, use default settings
-        return DefaultSettings;
-    } else {
-        // Migrate from older version (using the new system) to latest one
-        if (from_ver + 1 < to_ver) {
-            // Recursively upgrade in one-version steps
-            settings = MigrateSettings(from_ver, from_ver + 1, settings);
-            return MigrateSettings(from_ver + 1, to_ver, settings);
-        }
-
-        // If we reach this point it's guaranteed that from_ver === to_ver - 1, so we can implement
-        // a switch for each version step that upgrades to the next version. This enables us to
-        // upgrade from any version to the latest version without additional effort!
-        switch(to_ver)
-        {
-			// keep old settings, add new ones
-			default:
-				let oldsettings = settings
-				
+	if (from_ver === undefined) { // Migrate legacy config file
+		return Object.assign(Object.assign({}, DefaultSettings), settings);
+	}
+	else if (from_ver === null) { // No config file exists, use default settings
+		return DefaultSettings;
+	}
+	else { // Migrate from older version (using the new system) to latest one
+		if (from_ver + 1 < to_ver) { // Recursively upgrade in one-version steps
+			settings = MigrateSettings(from_ver, from_ver + 1, settings);
+			return MigrateSettings(from_ver + 1, to_ver, settings);
+		}
+		// If we reach this point it's guaranteed that from_ver === to_ver - 1, so we can implement
+		// a switch for each version step that upgrades to the next version. This enables us to
+		// upgrade from any version to the latest version without additional effort!
+		switch(to_ver) {
+			default: // keep old settings, add new ones
+				let oldsettings = settings;
 				settings = Object.assign(DefaultSettings, {});
 				settings = Object.assign(DefaultSettings, {});
-				
+
 				for(let option in oldsettings) {
 				for(let option in oldsettings) {
 					if(settings[option]) {
 					if(settings[option]) {
-						settings[option] = oldsettings[option]
+						settings[option] = oldsettings[option];
 					}
 					}
 				}
 				}
 
 
-				if(from_ver < to_ver) console.log('[Essentials] Your settings have been updated to version ' + to_ver + '. You can edit the new config file after the next relog.')
+				if(from_ver < to_ver) console.log('[Essentials] Your settings have been updated to version ' + to_ver + '. You can edit the new config file after the next relog.');
 				break;
 				break;
-        }
-
-        return settings;
-    }
+		}
+		return settings;
+	}
 }
 }