public static void Initialize() { if (!Directory.Exists(SavePath)) Directory.CreateDirectory(SavePath); switch (TShock.Config.StorageType.ToLower()) { case "mysql": string[] host = TShock.Config.MySqlHost.Split(':'); Database = new MySqlConnection() { ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", host[0], host.Length == 1 ? "3306" : host[1], TShock.Config.MySqlDbName, TShock.Config.MySqlUsername, TShock.Config.MySqlPassword) }; break; case "sqlite": string sql = Path.Combine(SavePath, "Clans.sqlite"); Database = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); break; } SqlTableCreator SQLcreator = new SqlTableCreator(Database, Database.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator()); SqlTable[] tables = new SqlTable[] { new SqlTable("Clans", new SqlColumn("Name", MySqlDbType.VarChar) { Primary=true, Unique=true }, new SqlColumn("Owner", MySqlDbType.VarChar), new SqlColumn("InviteMode", MySqlDbType.Int32), new SqlColumn("TileX", MySqlDbType.Int32), new SqlColumn("TileY", MySqlDbType.Int32), new SqlColumn("ChatColor", MySqlDbType.VarChar), new SqlColumn("Bans", MySqlDbType.VarChar) ), new SqlTable("ClanMembers", new SqlColumn("Username",MySqlDbType.VarChar) { Primary=true, Unique=true }, new SqlColumn("ClanName", MySqlDbType.VarChar) ), new SqlTable("ClanWarps", new SqlColumn("WarpName",MySqlDbType.VarChar) { Primary=true, Unique=true } ) }; for (int i = 0; i < tables.Length; i++) SQLcreator.EnsureTableStructure(tables[i]); Config = Config.Read(); LoadClans(); }
public static void ReloadConfig(TSPlayer ts) { Config = Config.Read(ts); }
public static void ReloadConfig(TSPlayer ts) { Config = Config.Read(); Config.write(); }