Added TSPlayer.Logout()

This commit is contained in:
ProfessorXZ 2016-12-18 12:35:18 +01:00
parent bcd00c0243
commit 7c8bf7712a
3 changed files with 32 additions and 24 deletions

View file

@ -637,6 +637,33 @@ namespace TShockAPI
return null;
}
/// <summary>
/// Logs the player out of an account.
/// </summary>
public void Logout()
{
PlayerHooks.OnPlayerLogout(this);
if (Main.ServerSideCharacter)
{
IgnoreActionsForInventory = $"Server side characters is enabled! Please {Commands.Specifier}register or {Commands.Specifier}login to play!";
if (!IgnoreActionsForClearingTrashCan && (!Dead || TPlayer.difficulty != 2))
{
PlayerData.CopyCharacter(this);
TShock.CharacterDB.InsertPlayerData(this);
}
}
PlayerData = new PlayerData(this);
Group = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
tempGroup = null;
if (tempGroupTimer != null)
{
tempGroupTimer.Stop();
}
User = null;
IsLoggedIn = false;
}
/// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary>