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

@ -3,6 +3,10 @@
This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large.
## Upcoming Changes ## Upcoming Changes
* API: Version tick 2.0
* API: Added TSPlayer.KillPlayer() (@WhiteXZ)
* API: Added TSPlayer.Logout() (@ProfessorXZ)
* Fixed connections after max slot is reached (@DeathCradle)
## TShock 4.3.21 ## TShock 4.3.21
* Compatibility with Terraria 1.3.4.3 (@Patrikkk, @Zaicon). * Compatibility with Terraria 1.3.4.3 (@Patrikkk, @Zaicon).
@ -26,7 +30,6 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion). * Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion).
* Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion). * Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion).
* Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue. * Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue.
* Fixed server-sided inventory issues caused by bank3 (@ProfessorXZ)
## TShock 4.3.20 ## TShock 4.3.20
* Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy). * Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy).

View file

@ -892,29 +892,7 @@ namespace TShockAPI
return; return;
} }
PlayerHooks.OnPlayerLogout(args.Player); args.Player.Logout();
if (Main.ServerSideCharacter)
{
args.Player.IgnoreActionsForInventory = String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier);
if (!args.Player.IgnoreActionsForClearingTrashCan && (!args.Player.Dead || args.Player.TPlayer.difficulty != 2))
{
args.Player.PlayerData.CopyCharacter(args.Player);
TShock.CharacterDB.InsertPlayerData(args.Player);
}
}
args.Player.PlayerData = new PlayerData(args.Player);
args.Player.Group = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
args.Player.tempGroup = null;
if (args.Player.tempGroupTimer != null)
{
args.Player.tempGroupTimer.Stop();
}
args.Player.User = null;
args.Player.IsLoggedIn = false;
args.Player.SendSuccessMessage("You have been successfully logged out of your account."); args.Player.SendSuccessMessage("You have been successfully logged out of your account.");
if (Main.ServerSideCharacter) if (Main.ServerSideCharacter)
{ {

View file

@ -637,6 +637,33 @@ namespace TShockAPI
return null; 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> /// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class. /// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary> /// </summary>