Merge branch 'group-mgr-ee' into general-devel

This commit is contained in:
Lucas Nicodemus 2015-02-21 17:14:29 -07:00
commit d3ed04c947
2 changed files with 29 additions and 25 deletions

View file

@ -47,34 +47,35 @@ namespace TShockAPI.DB
db.GetSqlType() == SqlType.Sqlite db.GetSqlType() == SqlType.Sqlite
? (IQueryBuilder) new SqliteQueryCreator() ? (IQueryBuilder) new SqliteQueryCreator()
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); if (creator.EnsureExists(table))
{
// Add default groups if they don't exist
AddDefaultGroup("guest", "",
string.Join(",", Permissions.canbuild, Permissions.canregister, Permissions.canlogin, Permissions.canpartychat,
Permissions.cantalkinthird, Permissions.canchat));
AddDefaultGroup("default", "guest",
string.Join(",", Permissions.warp, Permissions.canchangepassword));
AddDefaultGroup("newadmin", "default",
string.Join(",", Permissions.kick, Permissions.editspawn, Permissions.reservedslot));
AddDefaultGroup("admin", "newadmin",
string.Join(",", Permissions.ban, Permissions.whitelist, "tshock.world.time.*", Permissions.spawnboss,
Permissions.spawnmob, Permissions.managewarp, Permissions.time, Permissions.tp, Permissions.slap,
Permissions.kill, Permissions.logs,
Permissions.immunetokick, Permissions.tpothers));
AddDefaultGroup("trustedadmin", "admin",
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item,
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));
}
// Load Permissions from the DB // Load Permissions from the DB
LoadPermisions(); LoadPermisions();
// Add default groups if they don't exist
AddDefaultGroup("guest", "",
string.Join(",", Permissions.canbuild, Permissions.canregister, Permissions.canlogin, Permissions.canpartychat,
Permissions.cantalkinthird, Permissions.canchat));
AddDefaultGroup("default", "guest",
string.Join(",", Permissions.warp, Permissions.canchangepassword));
AddDefaultGroup("newadmin", "default",
string.Join(",", Permissions.kick, Permissions.editspawn, Permissions.reservedslot));
AddDefaultGroup("admin", "newadmin",
string.Join(",", Permissions.ban, Permissions.whitelist, "tshock.world.time.*", Permissions.spawnboss,
Permissions.spawnmob, Permissions.managewarp, Permissions.time, Permissions.tp, Permissions.slap,
Permissions.kill, Permissions.logs,
Permissions.immunetokick, Permissions.tpothers));
AddDefaultGroup("trustedadmin", "admin",
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item,
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));
Group.DefaultGroup = GetGroupByName(TShock.Config.DefaultGuestGroupName); Group.DefaultGroup = GetGroupByName(TShock.Config.DefaultGuestGroupName);
} }

View file

@ -52,7 +52,8 @@ namespace TShockAPI.DB
creator = provider; creator = provider;
} }
public void EnsureExists(SqlTable table) // Returns true if the table was created; false if it was not.
public bool EnsureExists(SqlTable table)
{ {
var columns = GetColumns(table); var columns = GetColumns(table);
if (columns.Count > 0) if (columns.Count > 0)
@ -66,7 +67,9 @@ namespace TShockAPI.DB
else else
{ {
database.Query(creator.CreateTable(table)); database.Query(creator.CreateTable(table));
return true;
} }
return false;
} }
public List<string> GetColumns(SqlTable table) public List<string> GetColumns(SqlTable table)