Esempio n. 1
0
        public BanManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Bans",
                                     new SqlColumn("IP", MySqlDbType.String, 16)
            {
                Primary = true
            },
                                     new SqlColumn("Name", MySqlDbType.Text),
                                     new SqlColumn("Reason", MySqlDbType.Text)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            try
            {
                creator.EnsureExists(table);
            }
            catch (DllNotFoundException)
            {
                System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
                throw new Exception("Could not find a database library (probably Sqlite3.dll)");
            }
        }
Esempio n. 2
0
        public UserManager(IDbConnection db, TPulse tPulse)
        {
            this.tPulse = tPulse;

            database = db;

            var table = new SqlTable("Users",
                                     new SqlColumn("ID", MySqlDbType.Int32)
            {
                Primary = true, AutoIncrement = true
            },
                                     new SqlColumn("Username", MySqlDbType.VarChar, 32)
            {
                Unique = true
            },
                                     new SqlColumn("Password", MySqlDbType.VarChar, 128),
                                     new SqlColumn("Usergroup", MySqlDbType.Text),
                                     new SqlColumn("IP", MySqlDbType.VarChar, 16)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);
        }
Esempio n. 3
0
        public RegionManager(IDbConnection db, TPulse tPulse)
        {
            this.tPulse = tPulse;
            database    = db;
            var table = new SqlTable("Regions",
                                     new SqlColumn("X1", MySqlDbType.Int32),
                                     new SqlColumn("Y1", MySqlDbType.Int32),
                                     new SqlColumn("width", MySqlDbType.Int32),
                                     new SqlColumn("height", MySqlDbType.Int32),
                                     new SqlColumn("RegionName", MySqlDbType.VarChar, 50)
            {
                Primary = true
            },
                                     new SqlColumn("WorldID", MySqlDbType.Text),
                                     new SqlColumn("UserIds", MySqlDbType.Text),
                                     new SqlColumn("Protected", MySqlDbType.Int32),
                                     new SqlColumn("Groups", MySqlDbType.Text),
                                     new SqlColumn("Owner", MySqlDbType.VarChar, 50),
                                     new SqlColumn("Z", MySqlDbType.Int32)
            {
                DefaultValue = "0"
            }
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);

            ReloadAllRegions();
        }
Esempio n. 4
0
        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                                     new SqlColumn("Account", MySqlDbType.Int32) {Primary = true},
                                     new SqlColumn("MaxHealth", MySqlDbType.Int32),
                                     new SqlColumn("MaxMana", MySqlDbType.Int32),
                                     new SqlColumn("Inventory", MySqlDbType.Text)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
Esempio n. 5
0
        public RememberedPosManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("RememberedPos",
                                     new SqlColumn("Name", MySqlDbType.VarChar, 50) {Primary = true},
                                     new SqlColumn("IP", MySqlDbType.Text),
                                     new SqlColumn("X", MySqlDbType.Int32),
                                     new SqlColumn("Y", MySqlDbType.Int32),
                                     new SqlColumn("WorldID", MySqlDbType.Text)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
Esempio n. 6
0
        public ItemManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("ItemBans",
                                     new SqlColumn("ItemName", MySqlDbType.VarChar, 50)
            {
                Primary = true
            },
                                     new SqlColumn("AllowedGroups", MySqlDbType.Text)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);
            UpdateItemBans();
        }
Esempio n. 7
0
        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                                     new SqlColumn("Account", MySqlDbType.Int32)
            {
                Primary = true
            },
                                     new SqlColumn("MaxHealth", MySqlDbType.Int32),
                                     new SqlColumn("MaxMana", MySqlDbType.Int32),
                                     new SqlColumn("Inventory", MySqlDbType.Text)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);
        }
Esempio n. 8
0
        public WarpManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Warps",
                                     new SqlColumn("WarpName", MySqlDbType.VarChar, 50)
            {
                Primary = true
            },
                                     new SqlColumn("X", MySqlDbType.Int32),
                                     new SqlColumn("Y", MySqlDbType.Int32),
                                     new SqlColumn("WorldID", MySqlDbType.Text),
                                     new SqlColumn("Private", MySqlDbType.Text)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);
        }
Esempio n. 9
0
        public GroupManager(IDbConnection db, TPulse tPulse)
        {
            this.tPulse = tPulse;
            database    = db;

            var table = new SqlTable("GroupList",
                                     new SqlColumn("GroupName", MySqlDbType.VarChar, 32)
            {
                Primary = true
            },
                                     new SqlColumn("Parent", MySqlDbType.VarChar, 32),
                                     new SqlColumn("Commands", MySqlDbType.Text),
                                     new SqlColumn("ChatColor", MySqlDbType.Text),
                                     new SqlColumn("Prefix", MySqlDbType.Text),
                                     new SqlColumn("Suffix", MySqlDbType.Text)
                                     );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                                                ? (IQueryBuilder) new SqliteQueryCreator()
                                                                : new MysqlQueryCreator());

            creator.EnsureExists(table);

            // Load Permissions from the DB
            LoadPermisions();
            //need to change those permissions for the groups
            //set some preset,
            // Add default groups if they don't exist
            AddDefaultGroup("guest", "", "canbuild,canregister,canlogin,canpartychat,cantalkinthird");
            AddDefaultGroup("default", "guest", "warp,canchangepassword");
            AddDefaultGroup("newadmin", "default", "kick,editspawn,reservedslot");
            AddDefaultGroup("admin", "newadmin",
                            "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
            AddDefaultGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers");
            AddDefaultGroup("vip", "default", "reservedslot");
        }
Esempio n. 10
0
        public UserManager(IDbConnection db, TPulse tPulse)
        {
            this.tPulse = tPulse;

            database = db;

            var table = new SqlTable("Users",
                                     new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true},
                                     new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
                                     new SqlColumn("Password", MySqlDbType.VarChar, 128),
                                     new SqlColumn("Usergroup", MySqlDbType.Text),
                                     new SqlColumn("IP", MySqlDbType.VarChar, 16)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
Esempio n. 11
0
        public RegionManager(IDbConnection db, TPulse tPulse)
        {
            this.tPulse = tPulse;
            database = db;
            var table = new SqlTable("Regions",
                                     new SqlColumn("X1", MySqlDbType.Int32),
                                     new SqlColumn("Y1", MySqlDbType.Int32),
                                     new SqlColumn("width", MySqlDbType.Int32),
                                     new SqlColumn("height", MySqlDbType.Int32),
                                     new SqlColumn("RegionName", MySqlDbType.VarChar, 50) {Primary = true},
                                     new SqlColumn("WorldID", MySqlDbType.Text),
                                     new SqlColumn("UserIds", MySqlDbType.Text),
                                     new SqlColumn("Protected", MySqlDbType.Int32),
                                     new SqlColumn("Groups", MySqlDbType.Text),
                                     new SqlColumn("Owner", MySqlDbType.VarChar, 50),
                                     new SqlColumn("Z", MySqlDbType.Int32){ DefaultValue = "0" }
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);

            ReloadAllRegions();
        }
Esempio n. 12
0
        public BanManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Bans",
                                     new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
                                     new SqlColumn("Name", MySqlDbType.Text),
                                     new SqlColumn("Reason", MySqlDbType.Text)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            try
            {
                creator.EnsureExists(table);
            }
            catch (DllNotFoundException)
            {
                System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
                throw new Exception("Could not find a database library (probably Sqlite3.dll)");
            }
        }