Do not auto-recreate the default groups on startup
This commit is contained in:
parent
3104e76d21
commit
484ebd6d81
2 changed files with 29 additions and 25 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue