Example #1
0
        public void OnInitialize()
        {
            if (!Directory.Exists(CmdParserDataDirectory))
            {
                Directory.CreateDirectory(CmdParserDataDirectory);
            }
            LoadCmdParsersFromText();
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            bool checkcommandcost = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("checkcommandcost"))
                    {
                        checkcommandcost = true;
                    }
                }
            }

            List <string> permlist = new List <string>();

            if (!checkcommandcost)
            {
                permlist.Add("checkcommandcost");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);
            Commands.ChatCommands.Add(new Command("checkcommandcost", CheckCommandCost, "checkcommandcost"));
        }
Example #2
0
        public static void InitMessageDB()
        {
            if (TShock.Config.StorageType.ToLower() == "sqlite")
            {
                DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", dbpath));
                if (!File.Exists(dbpath))
                {
                    SqliteConnection.CreateFile(dbpath);
                }
            }
            else if (TShock.Config.StorageType.ToLower() == "mysql")
            {
                try {
                    var host = TShock.Config.MySqlHost.Split(':');
                    DB = 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
                                                         )
                    };
                }
                catch (MySqlException x) {
                    TShock.Log.Error(x.ToString());
                    throw new Exception("MySQL not setup correctly.");
                }
            }
            else
            {
                throw new Exception("Invalid storage type.");
            }

            SQLWriter = new SqlTableCreator(DB, DB.GetSqlType() == SqlType.Sqlite ?
                                            (IQueryBuilder) new SqliteQueryCreator()
        : new MysqlQueryCreator());

            SQLEditor = new SqlTableEditor(DB, DB.GetSqlType() == SqlType.Sqlite ?
                                           (IQueryBuilder) new SqliteQueryCreator()
        : new MysqlQueryCreator());

            var table = new SqlTable("MessagePlugin",
                                     new SqlColumn("Id", MySqlDbType.Int32)
            {
                Primary = true, AutoIncrement = true
            },
                                     new SqlColumn("mailFrom", MySqlDbType.Text),
                                     new SqlColumn("mailTo", MySqlDbType.Text),
                                     new SqlColumn("mailText", MySqlDbType.Text),
                                     new SqlColumn("Date", MySqlDbType.Text),
                                     new SqlColumn("Seen", MySqlDbType.Int32)
                                     );

            SQLWriter.EnsureTableStructure(table);
        }
Example #3
0
 public void OnInitialize()
 {
     SQLEditor = new SqlTableEditor(TShock.DB,
                                    TShock.DB.GetSqlType() == SqlType.Sqlite
                                        ? (IQueryBuilder) new SqliteQueryCreator()
                                        : new MysqlQueryCreator());
     SQLWriter = new SqlTableCreator(TShock.DB,
                                     TShock.DB.GetSqlType() == SqlType.Sqlite
                                         ? (IQueryBuilder) new SqliteQueryCreator()
                                         : new MysqlQueryCreator());
     SetupConfig();
     Commands.ChatCommands.Add(new Command("duel", Bet, "bet"));
 }
Example #4
0
 public void OnInitialize()
 {
     SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
     SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
     SetupConfig();
     PointRange    = CEConfig.PointRange;
     PvPKillReward = CEConfig.PvPKillReward;
     TDMReward     = CEConfig.TDMReward;
     CTFReward     = CEConfig.CTFReward;
     OFReward      = CEConfig.OFReward;
     MoE           = CEConfig.MoE;
     Commands.ChatCommands.Add(new Command("duel", Bet, "bet"));
 }
Example #5
0
        public static bool InitializeTable()
        {
            var SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            try
            {
                if (SQLEditor.ReadColumn("ShopSystem", "Name", new List <SqlValue>()).Count < 1)
                {
                    Console.WriteLine("Writing item list for ShopSystem (This may take a while, please be patient)...");
                    for (int k = 1; k < 604; k++)
                    {
                        if (k == 269 || k == 270 || k == 271)    //this is a tshock bug
                        {
                        }
                        else
                        {
                            Item item  = TShockAPI.TShock.Utils.GetItemById(k);
                            int  value = item.value;
                            int  copper;
                            int  silver;
                            int  gold;
                            if (value % 10 != 0)
                            {
                                copper = Convert.ToInt32(item.value / 1.5);
                                silver = 0;
                                gold   = 0;
                            }
                            gold   = value / 1000;
                            value  = value - gold * 1000;
                            silver = value / 10;
                            value  = value - silver * 10;
                            copper = Convert.ToInt32(value * 1.5);
                            database.Query("INSERT INTO ShopSystem (Name, Copper, Silver, Gold, ForSale, MaxStack)" +
                                           " VALUES (@0, @1, @2, @3, 1, @4)", item.name, copper, silver, gold, item.maxStack);
                        }
                    }
                    Console.WriteLine("Wrote item list to SQL database successfully.");
                    Thread.Sleep(1000);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to write to SQL Database!");
                Log.Error("Write to SQL exception:(ShopSystem)");
                Log.Error(ex.ToString());
                return(false);
            }
        }
        public void OnInitialize()
        {
            SetupConfig();
            for (int i = 0; i < RankConfig.Ranks.Length; i++)
            {
                for (int j = 0; j < RankConfig.Ranks[i].Length; j++)
                {
                    if (!TShock.Groups.GroupExists(RankConfig.Ranks[i][j]))
                    {
                        TShock.Groups.AddGroup(RankConfig.Ranks[i][j], RankConfig.RankPermissions[i][j]);
                    }
                }
            }
            Commands.ChatCommands.Add(new Command("pouch", Rank, "rank"));
            Commands.ChatCommands.Add(new Command("changerank", ChRank, "chrank"));
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            bool dontchangemyrank = false;
            bool changerank       = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("dontchangemyrank"))
                    {
                        dontchangemyrank = true;
                    }
                    if (group.HasPermission("chrank"))
                    {
                        changerank = true;
                    }
                }
            }

            List <string> permlist = new List <string>();

            if (!dontchangemyrank)
            {
                permlist.Add("dontchangemyrank");
            }
            if (!changerank)
            {
                permlist.Add("chrank");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);
        }
Example #7
0
        public static void SetupDB()
        {
            switch (TShock.Config.StorageType.ToLower())
            {
            case "mysql":
                string[] host = TShock.Config.MySqlHost.Split(':');
                db = 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(TShock.SavePath, "hostbans.sqlite");
                db = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                break;
            }
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            var table = new SqlTable("hostbans",
                                     new SqlColumn("ID", MySqlDbType.Int32)
            {
                Primary = true, AutoIncrement = true
            },
                                     new SqlColumn("Host", MySqlDbType.Text),
                                     new SqlColumn("Username", MySqlDbType.Text),
                                     new SqlColumn("Reason", MySqlDbType.Text),
                                     new SqlColumn("Admin", MySqlDbType.Text),
                                     new SqlColumn("Date", MySqlDbType.Text)
                                     );

            SQLWriter.EnsureExists(table);
            var table2 = new SqlTable("hostbanscache",
                                      new SqlColumn("IP", MySqlDbType.VarChar, 16)
            {
                Unique = true
            },
                                      new SqlColumn("Host", MySqlDbType.Text)
                                      );

            SQLWriter.EnsureExists(table2);
        }
Example #8
0
        public void OnInitialize()
        {
            Main.ignoreErrors = true;
            Main.rand         = new Random();

            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            Commands.ChatCommands.Add(new Command(QCommands.GetCoords, "getcoords"));
            Commands.ChatCommands.Add(new Command(QCommands.HitCoords, "hitcoords"));
            Commands.ChatCommands.Add(new Command("usequest", QCommands.ListQuest, "listquests"));
            Commands.ChatCommands.Add(new Command("usequest", QCommands.StartQuest, "startquest"));
            Commands.ChatCommands.Add(new Command("questregion", QCommands.QuestRegion, "questr"));
            Commands.ChatCommands.Add(new Command("reloadqdata", QCommands.LoadQuestData, "reloadquestdata"));
            Commands.ChatCommands.Add(new Command("giveq", QCommands.GiveQuest, "giveq"));
            Commands.ChatCommands.Add(new Command("stopquest", QCommands.StopQuest, "stopquest"));

            var table = new SqlTable("QuestPlayers",
                                     new SqlColumn("LogInName", MySqlDbType.Text)
            {
                Unique = true
            },
                                     new SqlColumn("QuestPlayerData", MySqlDbType.Text)
                                     );

            SQLWriter.EnsureExists(table);

            table = new SqlTable("QuestRegions",
                                 new SqlColumn("RegionName", MySqlDbType.Text)
            {
                Unique = true
            },
                                 new SqlColumn("X1", MySqlDbType.Int32),
                                 new SqlColumn("Y1", MySqlDbType.Int32),
                                 new SqlColumn("X2", MySqlDbType.Int32),
                                 new SqlColumn("Y2", MySqlDbType.Int32),
                                 new SqlColumn("Quests", MySqlDbType.Text),
                                 new SqlColumn("EntryMessage", MySqlDbType.Text),
                                 new SqlColumn("ExitMessage", MySqlDbType.Text)
                                 );
            SQLWriter.EnsureExists(table);

            QTools.LoadQuestData();
        }
        public void OnInitialize(EventArgs args)
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            var table = new SqlTable("muteList",
                                     new SqlColumn("Name", MySqlDbType.Text),
                                     new SqlColumn("IP", MySqlDbType.Text));

            SQLWriter.EnsureExists(table);

            #region Commands
            Commands.ChatCommands.Add(new Command("mac.kill", Cmds.KillAll, "killall", "kill*"));
            Commands.ChatCommands.Add(new Command("mac.kill", Cmds.AutoKill, "autokill"));
            Commands.ChatCommands.Add(new Command("mac.mute", Cmds.PermaMute, "permamute"));
            Commands.ChatCommands.Add(new Command("mac.mute", Cmds.MuteAll, "muteall"));
            Commands.ChatCommands.Add(new Command("mac.spawn", Cmds.SpawnMobPlayer, "spawnmobplayer", "smp"));
            Commands.ChatCommands.Add(new Command("mac.spawn", Cmds.SpawnGroup, "spawngroup", "sg"));
            Commands.ChatCommands.Add(new Command("mac.spawn", Cmds.SpawnByMe, "spawnbyme", "sbm"));
            Commands.ChatCommands.Add(new Command("mac.search", Cmds.FindPerms, "findperm", "fperm"));
            Commands.ChatCommands.Add(new Command("mac.search", Cmds.FindCommand, "findcommand", "findcmd", "fcmd"));
            Commands.ChatCommands.Add(new Command("mac.search", Cmds.FindItem, "finditem", "fitem"));
            Commands.ChatCommands.Add(new Command("mac.search", Cmds.FindMob, "findmob", "fmob"));
            Commands.ChatCommands.Add(new Command("mac.butcher", Cmds.ButcherAll, "butcherall", "butcher*"));
            Commands.ChatCommands.Add(new Command("mac.butcher", Cmds.ButcherFriendly, "butcherfriendly", "butcherf"));
            Commands.ChatCommands.Add(new Command("mac.butcher", Cmds.ButcherNPC, "butchernpc"));
            Commands.ChatCommands.Add(new Command("mac.butcher", Cmds.ButcherNear, "butchernear"));
            Commands.ChatCommands.Add(new Command("mac.heal", Cmds.AutoHeal, "autoheal"));
            Commands.ChatCommands.Add(new Command("mac.heal.all", Cmds.HealAll, "healall"));
            Commands.ChatCommands.Add(new Command("mac.moon", Cmds.MoonPhase, "moon"));
            Commands.ChatCommands.Add(new Command("mac.give", Cmds.ForceGive, "forcegive"));
            Commands.ChatCommands.Add(new Command("mac.view", Cmds.ViewAll, "view"));
            Commands.ChatCommands.Add(new Command("mac.ghost", Cmds.Ghost, "ghost"));
            Commands.ChatCommands.Add(new Command("mac.reload", Cmds.ReloadMore, "reloadmore"));
            Commands.ChatCommands.Add(new Command("mac.freeze", Cmds.FreezeTime, "freezetime", "ft"));
            Commands.ChatCommands.Add(new Command(Cmds.TeamUnlock, "teamunlock"));
            Commands.ChatCommands.Add(new Command("mac.permabuff", Cmds.Permabuff, "permabuff", "pb"));
            Commands.ChatCommands.Add(new Command("mac.permabuff", Cmds.permDebuff, "permadebuff", "pdb"));
            Commands.ChatCommands.Add(new Command("mac.disable", Cmds.Disable, "disable"));
            #endregion

            Utils.SetUpConfig();

            updateTimers.initializeTimers();
        }
Example #10
0
        public static void Connect()
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite?(IQueryBuilder) new SqliteQueryCreator():new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite?(IQueryBuilder) new SqliteQueryCreator():new MysqlQueryCreator());
            var table = new SqlTable("CDPlugin",
                                     new SqlColumn("userid", MySqlDbType.Int32)
            {
                Primary = true, Unique = true, Length = 6
            },
                                     new SqlColumn("x", MySqlDbType.Float)
            {
            },
                                     new SqlColumn("y", MySqlDbType.Float)
            {
            },
                                     new SqlColumn("logout", MySqlDbType.Int32)
            {
                Length = 1
            }
                                     );

            SQLWriter.EnsureTableStructure(table);
        }
Example #11
0
        private void SetupDb()
        {
            if (TShock.Config.StorageType.ToLower() == "sqlite")
            {
                string sql = Path.Combine(TShock.SavePath, "InanZen_DB.sqlite");
                db = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
            }
            else if (TShock.Config.StorageType.ToLower() == "mysql")
            {
                try
                {
                    var hostport = TShock.Config.MySqlHost.Split(':');
                    db = new MySqlConnection();
                    db.ConnectionString =
                        String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                      hostport[0],
                                      hostport.Length > 1 ? hostport[1] : "3306",
                                      TShock.Config.MySqlDbName,
                                      TShock.Config.MySqlUsername,
                                      TShock.Config.MySqlPassword
                                      );
                }
                catch (MySqlException ex)
                {
                    Log.Error(ex.ToString());
                    throw new Exception("MySql not setup correctly");
                }
            }
            else
            {
                throw new Exception("Invalid storage type");
            }

            SQLcreator = new SqlTableCreator(db, new SqliteQueryCreator());
            SQLeditor  = new SqlTableEditor(db, new SqliteQueryCreator());
            DayRegions_Create();
        }
Example #12
0
        internal void OnInitialize()
        {
            if (C3Config.TeamColor1 < 1 || C3Config.TeamColor1 > 4 || C3Config.TeamColor1 == C3Config.TeamColor2 || C3Config.TeamColor2 > 4 || C3Config.TeamColor2 < 1)
            {
                throw new Exception("Team Colours are inccorectly set up. Check c3config.json");
            }

            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            ApocalypseMonsters.AddNPCs();
            int ArenaCount;

            #region TestPerms
            //Checks to see if permissions have been moved around
            bool vote             = false;
            bool joinvote         = false;
            bool setflags         = false;
            bool setspawns        = false;
            bool managec3settings = false;
            bool cvote            = false;
            bool duel             = false;
            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("vote"))
                    {
                        vote = true;
                    }
                    if (group.HasPermission("joinvote"))
                    {
                        joinvote = true;
                    }
                    if (group.HasPermission("setflags"))
                    {
                        setflags = true;
                    }
                    if (group.HasPermission("managec3settings"))
                    {
                        managec3settings = true;
                    }
                    if (group.HasPermission("cvote"))
                    {
                        cvote = true;
                    }
                    if (group.HasPermission("duel"))
                    {
                        duel = true;
                    }
                    if (group.HasPermission("setspawns"))
                    {
                        setspawns = true;
                    }
                }
            }
            List <string> perm = new List <string>();
            if (!vote)
            {
                perm.Add("vote");
            }
            if (!joinvote)
            {
                perm.Add("joinvote");
            }
            if (!duel)
            {
                perm.Add("duel");
            }
            TShock.Groups.AddPermissions("default", perm);

            perm.Clear();
            if (!setflags)
            {
                perm.Add("setflags");
            }
            if (!setflags)
            {
                perm.Add("setspawns");
            }
            if (!managec3settings)
            {
                perm.Add("managec3settings");
            }
            if (!cvote)
            {
                perm.Add("cvote");
            }
            if (!setspawns)
            {
                perm.Add("setspawns");
            }
            TShock.Groups.AddPermissions("trustedadmin", perm);
            #endregion
            //Converted v2.2
            #region AddCommands
            if (C3Mod.C3Config.TeamColor1 == 1)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfredflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfredspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmredspawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 2)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfgreenflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfgreenspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflaggreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelgreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmgreenspawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 3)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfblueflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfbluespawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmbluespawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 4)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfyellowflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfyellowspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmyellowspawn"));
            }
            if (C3Mod.C3Config.TeamColor2 == 1)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfredflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfredspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmredspawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 2)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfgreenflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfgreenspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflaggreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelgreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmgreenspawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 3)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfblueflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfbluespawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmbluespawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 4)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfyellowflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfyellowspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmyellowspawn"));
            }


            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddCTFArena, "addctfarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlag, "setoneflag"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddOneFlagArena, "addoneflagarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddDuelArena, "addduelarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddTDMArena, "addtdmarena"));

            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetFFASpawn, "setffaspawn"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddFFAArena, "addffaarena"));

            Commands.ChatCommands.Add(new Command("vote", C3Commands.StartVote, "vote"));
            Commands.ChatCommands.Add(new Command("joinvote", C3Commands.JoinVote, "join"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.Stop, "stop"));
            Commands.ChatCommands.Add(new Command(C3Commands.Quit, "quit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetCTFLimit, "setctflimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetOneFlagLimit, "setoneflaglimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetDuelLimit, "setduellimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetTDMLimit, "settdmlimit"));

            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetFFALimit, "setffalimit"));

            Commands.ChatCommands.Add(new Command("cvote", C3Commands.CancelVote, "cvote"));
            Commands.ChatCommands.Add(new Command("duel", C3Commands.ChallengePlayer, "duel"));
            Commands.ChatCommands.Add(new Command(C3Commands.AcceptChallenge, "accept"));

            Commands.ChatCommands.Add(new Command(C3Commands.ListArenaID, "list"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocPlayerSpawn, "setapocplayerspawn"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocMonsterSpawn, "setapocmonsterspawn"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocSpectatorSpawn, "setapocspectatorspawn"));
            #endregion

            #region FlagPoints

            var table = new SqlTable("FlagPoints",
                                     new SqlColumn("Name", MySqlDbType.Text),
                                     new SqlColumn("RedX", MySqlDbType.Int32),
                                     new SqlColumn("RedY", MySqlDbType.Int32),
                                     new SqlColumn("BlueX", MySqlDbType.Int32),
                                     new SqlColumn("BlueY", MySqlDbType.Int32),
                                     new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                     new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                     new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                     new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                     );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("FlagPoints", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name       = SQLEditor.ReadColumn("FlagPoints", "Name", new List <SqlValue>())[i].ToString();
                    int    redx       = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedX", new List <SqlValue>())[i].ToString());
                    int    redy       = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedY", new List <SqlValue>())[i].ToString());
                    int    bluex      = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueX", new List <SqlValue>())[i].ToString());
                    int    bluey      = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueY", new List <SqlValue>())[i].ToString());
                    int    redspawnx  = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redspawny  = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluespawnx = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluespawny = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    CTF.Arenas.Add(new CTFArena(new Vector2(redx, redy), new Vector2(bluex, bluey), new Vector2(redspawnx, redspawny), new Vector2(bluespawnx, bluespawny), name));
                }
            }

            #endregion

            #region DuelSpawns

            table = new SqlTable("DuelSpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("DuelSpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name  = SQLEditor.ReadColumn("DuelSpawns", "Name", new List <SqlValue>())[0].ToString();
                    int    redx  = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "RedSpawnX", new List <SqlValue>())[0].ToString());
                    int    redy  = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "RedSpawnY", new List <SqlValue>())[0].ToString());
                    int    bluex = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "BlueSpawnX", new List <SqlValue>())[0].ToString());
                    int    bluey = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "BlueSpawnY", new List <SqlValue>())[0].ToString());

                    Duel.Arenas.Add(new DuelArena(new Vector2(redx, redy), new Vector2(bluex, bluey), name));
                }
            }

            #endregion

            #region OneFlagPoints

            table = new SqlTable("OneFlagPoints",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("FlagX", MySqlDbType.Int32),
                                 new SqlColumn("FlagY", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("OneFlagPoints", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name       = SQLEditor.ReadColumn("OneFlagPoints", "Name", new List <SqlValue>())[i].ToString();
                    int    flagx      = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "FlagX", new List <SqlValue>())[i].ToString());
                    int    flagy      = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "FlagY", new List <SqlValue>())[i].ToString());
                    int    redspawnx  = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redspawny  = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluespawnx = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluespawny = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    OneFlagCTF.Arenas.Add(new OneFlagArena(new Vector2(flagx, flagy), new Vector2(redspawnx, redspawny), new Vector2(bluespawnx, bluespawny), name));
                }
            }

            #endregion

            #region TDMSpawns

            table = new SqlTable("TDMSpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("TDMSpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name  = SQLEditor.ReadColumn("TDMSpawns", "Name", new List <SqlValue>())[i].ToString();
                    int    redx  = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redy  = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluex = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluey = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    TDM.Arenas.Add(new TDMArena(new Vector2(redx, redy), new Vector2(bluex, bluey), name));
                }
            }

            #endregion

            #region FFASpawns

            table = new SqlTable("FFASpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("SpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("FFASpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name = SQLEditor.ReadColumn("FFASpawns", "Name", new List <SqlValue>())[i].ToString();
                    int    x    = Int32.Parse(SQLEditor.ReadColumn("FFASpawns", "SpawnX", new List <SqlValue>())[i].ToString());
                    int    y    = Int32.Parse(SQLEditor.ReadColumn("FFASpawns", "SpawnY", new List <SqlValue>())[i].ToString());

                    FFA.Arenas.Add(new FFAArena(new Vector2(x, y), name));
                }
            }

            #endregion

            #region Apocalypse

            table = new SqlTable("Apocalypse",
                                 new SqlColumn("SpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpawnY", MySqlDbType.Int32),
                                 new SqlColumn("MonsterSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("MonsterSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("SpectatorSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpectatorSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if (SQLEditor.ReadColumn("Apocalypse", "SpawnX", new List <SqlValue>()).Count == 0)
            {
                List <SqlValue> list = new List <SqlValue>();
                list.Add(new SqlValue("SpawnX", 0));
                list.Add(new SqlValue("SpawnY", 0));
                list.Add(new SqlValue("MonsterSpawnX", 0));
                list.Add(new SqlValue("MonsterSpawnY", 0));
                list.Add(new SqlValue("SpectatorSpawnX", 0));
                list.Add(new SqlValue("SpectatorSpawnY", 0));
                SQLEditor.InsertValues("Apocalypse", list);
            }
            else
            {
                Apocalypse.PlayerSpawn.X   = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.PlayerSpawn.Y   = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpawnY", new List <SqlValue>())[0].ToString());
                Apocalypse.MonsterSpawn.X  = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "MonsterSpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.MonsterSpawn.Y  = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "MonsterSpawnY", new List <SqlValue>())[0].ToString());
                Apocalypse.SpectatorArea.X = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpectatorSpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.SpectatorArea.Y = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpectatorSpawnY", new List <SqlValue>())[0].ToString());
            }

            #endregion
        }
Example #13
0
        public void OnInitialize()
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            var table = new SqlTable("ChatColor",
                                     new SqlColumn("Name", MySqlDbType.Text)
            {
                Unique = true
            },
                                     new SqlColumn("CanChange", MySqlDbType.Int32),
                                     new SqlColumn("R", MySqlDbType.Int32),
                                     new SqlColumn("G", MySqlDbType.Int32),
                                     new SqlColumn("B", MySqlDbType.Int32));

            SQLWriter.EnsureExists(table);
            bool color      = false;
            bool othercolor = false;
            bool admincolor = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("chatcolor"))
                    {
                        color = true;
                    }
                    if (group.HasPermission("otherchatcolor"))
                    {
                        othercolor = true;
                    }
                    if (group.HasPermission("adminchatcolor"))
                    {
                        admincolor = true;
                    }
                }
            }
            List <string> permlist = new List <string>();

            if (!color)
            {
                permlist.Add("chatcolor");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);
            permlist = new List <string>();
            if (!othercolor)
            {
                permlist.Add("otherchatcolor");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);
            permlist = new List <string>();
            if (!admincolor)
            {
                permlist.Add("adminchatcolor");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);

            Commands.ChatCommands.Add(new Command("chatcolor", ChatColor, "chatcolor"));
            Commands.ChatCommands.Add(new Command("otherchatcolor", OtherChatColor, "otherchatcolor"));
            Commands.ChatCommands.Add(new Command("adminchatcolor", blockChatColor, "blockchatcolor"));
            Commands.ChatCommands.Add(new Command("adminchatcolor", unblockChatColor, "unblockchatcolor"));
        }
Example #14
0
        public void OnInitialize()
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            #region Setup
            bool sethouse    = false;
            bool edithouse   = false;
            bool enterlocked = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("sethouse"))
                    {
                        sethouse = true;
                    }
                    if (group.HasPermission("edithouse"))
                    {
                        edithouse = true;
                    }
                    if (group.HasPermission("enterlocked"))
                    {
                        enterlocked = true;
                    }
                }
            }
            List <string> perm = new List <string>();
            if (!sethouse)
            {
                perm.Add("sethouse");
            }
            if (!edithouse)
            {
                perm.Add("edithouse");
            }
            if (!enterlocked)
            {
                perm.Add("enterlocked");
            }
            TShock.Groups.AddPermissions("trustedadmin", perm);

            var table = new SqlTable("HousingDistrict",
                                     new SqlColumn("ID", MySqlDbType.Int32)
            {
                Primary = true, AutoIncrement = true
            },
                                     new SqlColumn("Name", MySqlDbType.Text)
            {
                Unique = true
            },
                                     new SqlColumn("TopX", MySqlDbType.Int32),
                                     new SqlColumn("TopY", MySqlDbType.Int32),
                                     new SqlColumn("BottomX", MySqlDbType.Int32),
                                     new SqlColumn("BottomY", MySqlDbType.Int32),
                                     new SqlColumn("Owners", MySqlDbType.Text),
                                     new SqlColumn("WorldID", MySqlDbType.Text),
                                     new SqlColumn("Locked", MySqlDbType.Int32)
                                     );
            SQLWriter.EnsureExists(table);
            var reader = TShock.DB.QueryReader("Select * from HousingDistrict");
            while (reader.Read())
            {
                int           id     = reader.Get <int>("ID");
                string[]      list   = reader.Get <string>("Owners").Split(',');
                List <string> owners = new List <string>();
                foreach (string i in list)
                {
                    owners.Add(i);
                }
                int locked = reader.Get <int>("Locked");
                Houses.Add(new House(new Rectangle(reader.Get <int>("TopX"), reader.Get <int>("TopY"), reader.Get <int>("BottomX"), reader.Get <int>("BottomY")),
                                     owners, id, reader.Get <string>("Name"), reader.Get <string>("WorldID"), locked));
            }

            /*for (int i = 0; i < SQLEditor.ReadColumn("HousingDistrict", "ID", new List<SqlValue>()).Count; i++)
             * {
             *  string[] list = SQLEditor.ReadColumn("HousingDistrict", "Owners", new List<SqlValue>())[i].ToString().Split(',');
             *  List<string> items = new List<string>();
             *
             *  foreach (string item in list)
             *  {
             *      items.Add(item);
             *  }
             *
             *  int locked = 0;
             *
             *  if (SQLEditor.ReadColumn("HousingDistrict", "Locked", new List<SqlValue>())[i] != null)
             *  {
             *      locked = (int)SQLEditor.ReadColumn("HousingDistrict", "Locked", new List<SqlValue>())[i];
             *  }
             *
             *  Houses.Add(new House(
             *      new Rectangle(
             *      ("HousingDistrict", "TopX", new List<SqlValue>())[i],
             *      (int)SQLEditor.ReadColumn("HousingDistrict", "TopY", new List<SqlValue>())[i],
             *      (int)SQLEditor.ReadColumn("HousingDistrict", "BottomX", new List<SqlValue>())[i],
             *      (int)SQLEditor.ReadColumn("HousingDistrict", "BottomY", new List<SqlValue>())[i]),
             *      items,
             *      (int)SQLEditor.ReadColumn("HousingDistrict", "ID", new List<SqlValue>())[i],
             *      (string)SQLEditor.ReadColumn("HousingDistrict", "Name", new List<SqlValue>())[i],
             *      (string)SQLEditor.ReadColumn("HousingDistrict", "WorldID", new List<SqlValue>())[i],
             *      locked));
             * }*/
            #endregion

            #region Commands
            Commands.ChatCommands.Add(new Command("sethouse", HCommands.House, "house"));
            Commands.ChatCommands.Add(new Command("superadmin", HCommands.Convert, "converthouse"));
            Commands.ChatCommands.Add(new Command(HCommands.ChangeLock, "changelock"));
            Commands.ChatCommands.Add(new Command(HCommands.TellAll, "all"));
            #endregion
        }
Example #15
0
        public void OnInitialize()
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            bool setcost          = false;
            bool freewarp         = false;
            bool freetp           = false;
            bool freeheal         = false;
            bool freebuff         = false;
            bool checkcommandcost = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("setcost"))
                    {
                        setcost = true;
                    }
                    if (group.HasPermission("freewarp"))
                    {
                        freewarp = true;
                    }
                    if (group.HasPermission("freetp"))
                    {
                        freetp = true;
                    }
                    if (group.HasPermission("freeheal"))
                    {
                        freeheal = true;
                    }
                    if (group.HasPermission("freebuff"))
                    {
                        setcost = true;
                    }
                    if (group.HasPermission("checkcommandcost"))
                    {
                        checkcommandcost = true;
                    }
                }
            }

            List <string> permlist = new List <string>();

            if (!setcost)
            {
                permlist.Add("setcost");
            }
            if (!freewarp)
            {
                permlist.Add("freewarp");
            }
            if (!freetp)
            {
                permlist.Add("freetp");
            }
            if (!freeheal)
            {
                permlist.Add("freeheal");
            }
            if (!freebuff)
            {
                permlist.Add("freebuff");
            }
            if (!checkcommandcost)
            {
                permlist.Add("checkcommandcost");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);

            Commands.ChatCommands.Add(new Command("setcost", SetCost, "setcost"));
            Commands.ChatCommands.Add(new Command("setcost", SetWarpCost, "setwarpcost"));
            Commands.ChatCommands.Add(new Command("checkcommandcost", CheckCommandCost, "checkcommandcost"));
            Commands.ChatCommands.Add(new Command("checkcommandcost", CheckWarpCost, "checkwarpcost"));
            var table = new SqlTable("CommandCosts",
                                     new SqlColumn("Command", MySqlDbType.String, 255)
            {
                Unique = true
            },
                                     new SqlColumn("Cost", MySqlDbType.Int32)
                                     );

            SQLWriter.EnsureExists(table);
            if (SQLEditor.ReadColumn("CommandCosts", "Command", new List <SqlValue>()).Count == 0)
            {
                List <SqlValue> tp = new List <SqlValue>();
                tp.Add(new SqlValue("Command", "'" + "tp" + "'"));
                tp.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", tp);
                List <SqlValue> heal = new List <SqlValue>();
                heal.Add(new SqlValue("Command", "'" + "heal" + "'"));
                heal.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", heal);
                List <SqlValue> buff = new List <SqlValue>();
                buff.Add(new SqlValue("Command", "'" + "buff" + "'"));
                buff.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", buff);
                List <SqlValue> warp = new List <SqlValue>();
                warp.Add(new SqlValue("Command", "'" + "warp" + "'"));
                warp.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", warp);
            }
            List <SqlValue> where1 = new List <SqlValue>();

            where1.Add(new SqlValue("Command", "'" + "warp" + "'"));
            warpcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where2 = new List <SqlValue>();

            where2.Add(new SqlValue("Command", "'" + "tp" + "'"));
            tpcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where3 = new List <SqlValue>();

            where3.Add(new SqlValue("Command", "'" + "heal" + "'"));
            healcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where4 = new List <SqlValue>();

            where4.Add(new SqlValue("Command", "'" + "buff" + "'"));
            buffcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
        }