Minor update.
- AssertGroupValid now both sends the message and kicks the player depending on input parameter. - /login and DataHandler code is now an identical assert check.
This commit is contained in:
parent
048aaf6f0c
commit
c759af6d49
3 changed files with 10 additions and 6 deletions
|
|
@ -825,9 +825,9 @@ namespace TShockAPI
|
|||
{
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (group == null)
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group, false))
|
||||
{
|
||||
args.Player.SendErrorMessage("Login failed: The account references a group that doesn't exist.");
|
||||
args.Player.SendErrorMessage("Login attempt failed - see the message above.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2452,7 +2452,7 @@ namespace TShockAPI
|
|||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group))
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group, true))
|
||||
return true;
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
|
@ -3007,7 +3007,7 @@ namespace TShockAPI
|
|||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group))
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group, true))
|
||||
return true;
|
||||
|
||||
args.Player.Group = group;
|
||||
|
|
|
|||
|
|
@ -214,15 +214,19 @@ namespace TShockAPI
|
|||
|
||||
/// <summary>
|
||||
/// Asserts that the group reference can be safely assigned to the player object.
|
||||
/// <para>If this assertion fails, and <paramref name="kick"/> is true, the player is disconnected. If <paramref name="kick"/> is false, the player will receive an error message.</para>
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
public bool AssertGroupValid(TSPlayer player, Group group)
|
||||
public bool AssertGroupValid(TSPlayer player, Group group, bool kick)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
player.Disconnect("Your account's group could not be found. Please contact server administrators about this.");
|
||||
if (kick)
|
||||
player.Disconnect("Your account's group could not be loaded. Please contact server administrators about this.");
|
||||
else
|
||||
player.SendErrorMessage("Your account's group could not be loaded. Please contact server administrators about this.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue