From 00ad1c63b43ea39e32437bfb56522ceb12a7d7eb Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 17 Apr 2015 00:17:19 -0600 Subject: [PATCH] Check to see if a player is logged in before calling logout hook on dc --- TShockAPI/TShock.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 771a61a6..a31d2190 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -41,17 +41,30 @@ using TShockAPI.ServerSideCharacters; namespace TShockAPI { + /// + /// This is the TShock main class. TShock is a plugin on the TerrariaServerAPI, so it extends the base TerrariaPlugin. + /// TShock also complies with the API versioning system, and defines its required API version here. + /// [ApiVersion(1, 17)] public class TShock : TerrariaPlugin { + /// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info. public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; + /// VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions. public static readonly string VersionCodename = "Please take our survey: http://bit.ly/ShockSurvey"; + /// SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins). public static string SavePath = "tshock"; + /// LogFormatDefault - This is the default log file naming format. Actually, this is the only log format, because it never gets set again. private const string LogFormatDefault = "yyyy-MM-dd_HH-mm-ss"; + //TODO: Set the log path in the config file. + /// LogFormat - This is the log format, which is never set again. private static string LogFormat = LogFormatDefault; + /// LogPathDefault - The default log path. private const string LogPathDefault = "tshock"; + /// This is the log path, which is initially set to the default log path, and then to the config file log path later. private static string LogPath = LogPathDefault; + /// LogClear - Determines whether or not the log file should be cleared on initialization. private static bool LogClear; public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers]; @@ -1004,7 +1017,6 @@ namespace TShockAPI private void OnLeave(LeaveEventArgs args) { var tsplr = Players[args.Who]; - Hooks.PlayerHooks.OnPlayerLogout(tsplr); Players[args.Who] = null; if (tsplr != null && tsplr.ReceivedInfo) @@ -1030,6 +1042,11 @@ namespace TShockAPI } } + if (tsplr != null && tsplr.IsLoggedIn) + { + Hooks.PlayerHooks.OnPlayerLogout(tsplr); + } + // The last player will leave after this hook is executed. if (Utils.ActivePlayers() == 1) {