/// <summary> /// Sets up the configuration file for all variables, and creates any missing files. /// </summary> public static void SetupConfig() { if (!Directory.Exists(TShock.SavePath)) { Directory.CreateDirectory(TShock.SavePath); } CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!"); CreateIfNot(MotdPath, "This server is running TShock. Type /help for a list of commands.\n%255,000,000%Current map: %map%\nCurrent players: %players%"); CreateIfNot(WhitelistPath); try { if (File.Exists(ConfigPath)) { TShock.Config = ConfigFile.Read(ConfigPath); // Add all the missing config properties in the json file } TShock.Config.Write(ConfigPath); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error in config file"); Console.ForegroundColor = ConsoleColor.Gray; Log.Error("Config Exception"); Log.Error(ex.ToString()); } }
/// <summary> /// Sets up the configuration file for all variables, and creates any missing files. /// </summary> public static void SetupConfig() { if (!Directory.Exists(TShock.SavePath)) { Directory.CreateDirectory(TShock.SavePath); } CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!"); CreateIfNot(MotdPath, "This server is running TShock for Terraria.\n Type /help for a list of commands.\n%255,000,000%Current map: %map%\nCurrent players: %players%"); CreateIfNot(WhitelistPath); if (File.Exists(ConfigPath)) { TShock.Config = ConfigFile.Read(ConfigPath); // Add all the missing config properties in the json file } TShock.Config.Write(ConfigPath); if (File.Exists(ServerSideCharacterConfigPath)) { TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath); // Add all the missing config properties in the json file } TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath); }
/// <summary> /// Sets up the configuration file for all variables, and creates any missing files. /// </summary> public static void SetupConfig() { if (!Directory.Exists(TShock.SavePath)) { Directory.CreateDirectory(TShock.SavePath); } CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!"); CreateIfNot(MotdPath, MotdFormat); CreateIfNot(WhitelistPath); if (File.Exists(ConfigPath)) { TShock.Config = ConfigFile.Read(ConfigPath); // Add all the missing config properties in the json file } TShock.Config.Write(ConfigPath); if (File.Exists(ServerSideCharacterConfigPath)) { TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath); // Add all the missing config properties in the json file } else { TShock.ServerSideCharacterConfig = new ServerSideConfig { StartingInventory = new List <NetItem>() { new NetItem() { netID = -15, stack = 1, prefix = 0 }, new NetItem() { netID = -13, stack = 1, prefix = 0 }, new NetItem() { netID = -16, stack = 1, prefix = 0 } } }; } TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath); }
/// <summary> /// Sets up the configuration file for all variables, and creates any missing files. /// </summary> public static void SetupConfig() { if (!Directory.Exists(TShock.SavePath)) { Directory.CreateDirectory(TShock.SavePath); } CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!"); CreateIfNot(MotdPath, MotdFormat); CreateIfNot(WhitelistPath); bool writeConfig = true; // Default to true if the file doesn't exist if (File.Exists(ConfigPath)) { TShock.Config = ConfigFile.Read(ConfigPath, out writeConfig); } if (writeConfig) { // Add all the missing config properties in the json file TShock.Config.Write(ConfigPath); } bool writeSSCConfig = true; // Default to true if the file doesn't exist if (File.Exists(ServerSideCharacterConfigPath)) { TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath, out writeSSCConfig); } if (writeSSCConfig) { // Add all the missing config properties in the json file TShock.ServerSideCharacterConfig = new ServerSideConfig { StartingInventory = new List <NetItem> { new NetItem(-15, 1, 0), new NetItem(-13, 1, 0), new NetItem(-16, 1, 0) } }; TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath); } }
/// <summary> /// Sets up the configuration file for all variables, and creates any missing files. /// </summary> public static void SetupConfig() { if (!Directory.Exists(TShock.SavePath)) { Directory.CreateDirectory(TShock.SavePath); } CreateIfNot(RulesPath, "玩家和睦相处!\n禁止使用爆炸物."); CreateIfNot(MotdPath, MotdFormat); CreateIfNot(WhitelistPath); if (File.Exists(ConfigPath)) { TShock.Config = ConfigFile.Read(ConfigPath); // Add all the missing config properties in the json file } TShock.Config.Write(ConfigPath); if (File.Exists(ServerSideCharacterConfigPath)) { TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath); // Add all the missing config properties in the json file } else { TShock.ServerSideCharacterConfig = new ServerSideConfig { StartingInventory = new List <NetItem> { new NetItem(-15, 1, 0), new NetItem(-13, 1, 0), new NetItem(-16, 1, 0) } }; } TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath); }