public static VaultConfig ReadConfig(string Path) { VaultConfig config = null; try { string fileInput = System.IO.File.ReadAllText(Path); config = JsonConvert.DeserializeObject <VaultConfig>(fileInput); } catch (Exception ex) { if (ex is DirectoryNotFoundException || ex is FileNotFoundException) { TShockAPI.Log.ConsoleError("Vault config not found. Creating new one"); config = new VaultConfig(); config.CreateConfig(Path); } else if (ex is UnauthorizedAccessException || ex is System.Security.SecurityException) { TShockAPI.Log.ConsoleError("vault config: Access is denied to Vault config: " + Path); } else { TShockAPI.Log.ConsoleError("vault config: Error reading file: " + Path); throw; } } return(config); }
public override void Initialize() { PlayerList = new List <VaultPlayer>(); BossList = new List <BossNPC>(); Config = VaultConfig.ReadConfig("tshock" + System.IO.Path.DirectorySeparatorChar + "SEconomy" + System.IO.Path.DirectorySeparatorChar + "VaultEx.config.json"); Hooks.NetHooks.GetData += NetHooks_GetData; Hooks.NetHooks.SendData += NetHooks_SendData; Hooks.ServerHooks.Join += ServerHooks_Join; }
public static VaultConfig ReadConfig(string Path) { VaultConfig config = null; try { string fileInput = System.IO.File.ReadAllText(Path); config = JsonConvert.DeserializeObject<VaultConfig>(fileInput); } catch (Exception ex) { if (ex is DirectoryNotFoundException || ex is FileNotFoundException) { TShockAPI.Log.ConsoleError("Vault config not found. Creating new one"); config = new VaultConfig(); config.CreateConfig(Path); } else if (ex is UnauthorizedAccessException || ex is System.Security.SecurityException) { TShockAPI.Log.ConsoleError("vault config: Access is denied to Vault config: " + Path); } else { TShockAPI.Log.ConsoleError("vault config: Error reading file: " + Path); throw; } } return config; }