public static void ReloadConfig(TSPlayer ts) { Config = Config.Read(); Config.write(); }
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, Config.ClanNameLength) { Primary=true, Unique=true }, new SqlColumn("Tag", MySqlDbType.Text), new SqlColumn("Owner", MySqlDbType.Text), new SqlColumn("InviteMode", MySqlDbType.Int32), new SqlColumn("SpawnX", MySqlDbType.Int32), new SqlColumn("SpawnY", MySqlDbType.Int32), new SqlColumn("ChatColor", MySqlDbType.Text), new SqlColumn("Bans", MySqlDbType.Text) ), new SqlTable("ClanMembers", new SqlColumn("UserID",MySqlDbType.Int32) { Primary=true, Unique=true }, new SqlColumn("PlayerName", MySqlDbType.Text), new SqlColumn("ClanName", MySqlDbType.Text) ), new SqlTable("ClanWarps", new SqlColumn("WarpName",MySqlDbType.Text) ) }; for (int i = 0; i < tables.Length; i++) SQLcreator.EnsureTableStructure(tables[i]); Config = Config.Read(); Config.write(); Clans = new Dictionary<string, Clan>(); ClanMembers = new Dictionary<int, ClanMember>(); LoadMembers(); LoadClans(); timer = new Timer(3000); timer.Elapsed += OnElapsed; timer.Start(); for (int i = 0; i < PendingInvites.Length; i++) { PendingInvites[i] = new ClanInvite(); PendingInvites[i].Timeout = 0; } }