Missing group safeguards.

- Server will no longer start up when the guest or default groups cannot
  be located.
- Players joining with unknown groups assigned to them will be
  disconnected with an error
This commit is contained in:
quake1337 2021-07-13 21:33:35 +02:00
parent c5421460ae
commit 48370d74b7
6 changed files with 41 additions and 5 deletions

View file

@ -202,6 +202,21 @@ namespace TShockAPI.DB
Group.DefaultGroup = GetGroupByName(TShock.Config.Settings.DefaultGuestGroupName);
}
internal void EnsureCoreGroupsPresent()
{
if (!GroupExists(TShock.Config.Settings.DefaultGuestGroupName))
{
TShock.Log.ConsoleError("The guest group could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
throw new Exception("The guest group could not be found.");
}
if(!GroupExists(TShock.Config.Settings.DefaultRegistrationGroupName))
{
TShock.Log.ConsoleError("The default usergroup could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
throw new Exception("The default usergroup could not be found.");
}
}
private void AddDefaultGroup(string name, string parent, string permissions)
{
if (!GroupExists(name))