Seren лет назад: 8
Родитель
Сommit
0852fd35e2
1 измененных файлов с 9 добавлено и 3 удалено
  1. 9 3
      index.js

+ 9 - 3
index.js

@@ -69,7 +69,8 @@ const Command = require('command'),
 
 
 
 
 module.exports = function FpsUtils(dispatch) {
 module.exports = function FpsUtils(dispatch) {
-     
+    let update = false
+	
 	try {db = require('./db.json')} 
 	try {db = require('./db.json')} 
 	catch (e) {
 	catch (e) {
 		console.log('(FPS Utils) - No DB file detected, creating...')
 		console.log('(FPS Utils) - No DB file detected, creating...')
@@ -99,12 +100,14 @@ module.exports = function FpsUtils(dispatch) {
             "hiddeneffect":[10153040,10155130,31100],
             "hiddeneffect":[10153040,10155130,31100],
             "hiddenheal":[10154031,700409,701606,701607]
             "hiddenheal":[10154031,700409,701606,701607]
         }
         }
+		update=true
 		saveDb()
 		saveDb()
     }
     }
     if (db.version !== 1){ 		//Remember to change version number for updates
     if (db.version !== 1){ 		//Remember to change version number for updates
 		console.log('[FPS Utils] Outdated DB file detected, updating...')
 		console.log('[FPS Utils] Outdated DB file detected, updating...')
         Object.assign(db,{})	//Replace {} with updating object.Eg {"version":1.1,"newKey":1,"newKey2":[1,2]}
         Object.assign(db,{})	//Replace {} with updating object.Eg {"version":1.1,"newKey":1,"newKey2":[1,2]}
 		db.hiddenskill.push()	//To Prevent replacing user customized array, Use pushes for array based Object values. This is just an example.
 		db.hiddenskill.push()	//To Prevent replacing user customized array, Use pushes for array based Object values. This is just an example.
+		update=true
         saveDb()
         saveDb()
     }
     }
     //config
     //config
@@ -147,11 +150,13 @@ module.exports = function FpsUtils(dispatch) {
 			"blockEffect": true,
 			"blockEffect": true,
 			"hiddenPeople": []
 			"hiddenPeople": []
 		}
 		}
+		update=true
         saveConfig()
         saveConfig()
     }
     }
     if (flags.version !== 1){		//Remember to change version number for updates (if new version is 1.1, change to 1.1!)
     if (flags.version !== 1){		//Remember to change version number for updates (if new version is 1.1, change to 1.1!)
         console.log('[FPS Utils] Outdated config file detected, updating...');
         console.log('[FPS Utils] Outdated config file detected, updating...');
         Object.assign(flags,{})		//Replace {} with updating object.Eg {"version":1.1,"newKey":true,"newKey2":false,"tcp":false}
         Object.assign(flags,{})		//Replace {} with updating object.Eg {"version":1.1,"newKey":true,"newKey2":false,"tcp":false}
+		update=true
         saveConfig()
         saveConfig()
     }
     }
     
     
@@ -645,9 +650,10 @@ module.exports = function FpsUtils(dispatch) {
 	function getClass(m) {return (m % 100)}
 	function getClass(m) {return (m % 100)}
 	
 	
     function saveConfig() {
     function saveConfig() {
-		if(this.state !== undefined) flags.state = state
+		if(!update) flags.state = state
+		else update = false
 		
 		
-		fs.writeFile(path.join(__dirname,'config.json'), JSON.stringify(flags, null, "\t"), err => {
+		fs.writeFile(path.join(__dirname,'config.json'), JSON.stringify(flags,null,"\t"), err => {
 			if (err) console.log('(FPS Utils) Config file failed to overwrite. Use "fps save" command to save again.')
 			if (err) console.log('(FPS Utils) Config file failed to overwrite. Use "fps save" command to save again.')
 			else
 			else
 				console.log('(FPS Utils) Config file saved!') // I am too lazy to unfuck this at the present moment
 				console.log('(FPS Utils) Config file saved!') // I am too lazy to unfuck this at the present moment