Missing null check in OnChat.

Added exception handler to command runner so it wont get swallowed by terraria
This commit is contained in:
high 2011-06-30 12:41:12 -04:00
parent 527d9bb203
commit c52e8cbf5d
3 changed files with 24 additions and 7 deletions

View file

@ -307,14 +307,14 @@ namespace TShockAPI
if (Main.netMode != 2 || e.Handled)
return;
if (msg.whoAmI != ply)
var tsplr = Players[msg.whoAmI];
if (msg.whoAmI != ply || tsplr == null)
{
e.Handled = Tools.HandleGriefer(Players[ply], "Faking Chat");
return;
}
var tsplr = Players[msg.whoAmI];
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/"))
{
Tools.Broadcast(ConfigurationManager.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
@ -325,8 +325,15 @@ namespace TShockAPI
if (text.StartsWith("/"))
{
if (Commands.HandleCommand(tsplr, text))
e.Handled = true;
try
{
e.Handled = Commands.HandleCommand(tsplr, text);
}
catch (Exception ex)
{
Log.ConsoleError("Command exception");
Log.Error(ex.ToString());
}
}
else
{