public static void OpenConfig() { try { string configPath = Patchables.fullevelPathValue + @"\config.txt"; ConfigV2 deserializedConfigV2 = new ConfigV2(); ConfigV3 deserializedConfigV3 = new ConfigV3(); if (File.Exists(configPath)) { string configContent = File.ReadAllText(configPath); if (Patchables.configVersion == 2) { deserializedConfigV2 = JsonConvert.DeserializeObject<ConfigV2>(configContent); Map.events = deserializedConfigV2.events; } else if (Patchables.configVersion == 3) { deserializedConfigV3 = JsonConvert.DeserializeObject<ConfigV3>(configContent); ConfigV3 deserializedConfig = JsonConvert.DeserializeObject<ConfigV3>(configContent); string encryptedEvents = deserializedConfig.e; string decryptedEvents = IntralismDecryption.Decrypt(encryptedEvents); DecryptedEvents deserializedDecryptedEvents = JsonConvert.DeserializeObject<DecryptedEvents>(decryptedEvents); Map.events = deserializedDecryptedEvents.events; } // I don't support multiple Key Layour yet -> Multiple hands if (Patchables.handCount == 1) { Thread relaxThread = new Thread(RelaxThread); relaxThread.Start(); } } } catch { // Do Nothing } }
/// <summary> Decrypts the Events of the V3 Config in the Example Folder. This automatically gets the e (events) text out of the config. And yes, I suggest using Json instead of <see cref="File.ReadAllLines(string)"/>, etc., Azuki taught me that. /// </summary> public static DecryptedEvents GetDecryptedEvents() { try { string localePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), // Btw: You can also give a path like so: @"\Example\v3\config.txt" // Same end result. Only benefit could be some time savings. encryptedConfigPath = localePath + "\\example\\v3\\config.txt", configContent = File.ReadAllText(encryptedConfigPath); ConfigV3 deserializedConfig = JsonConvert.DeserializeObject <ConfigV3>(configContent); string encryptedEvents = deserializedConfig.e; string decryptedEvents = IntralismDecryption.Decrypt(encryptedEvents); DecryptedEvents deserializedDecryptedEvents = JsonConvert.DeserializeObject <DecryptedEvents>(decryptedEvents); return(deserializedDecryptedEvents); } catch (Exception) { // Do Nothing. return(new DecryptedEvents()); } }