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

@ -79,6 +79,16 @@ namespace TShockAPI
{
Write(message, LogLevel.Error);
}
/// <summary>
/// Writes an error to the log file.
/// </summary>
/// <param name="message">The message to be written.</param>
public static void ConsoleError(String message)
{
Console.WriteLine(message);
Write(message, LogLevel.Error);
}
/// <summary>
/// Writes a warning to the log file.

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.0.0629")]
[assembly: AssemblyFileVersion("2.3.0.0629")]
[assembly: AssemblyVersion("2.3.0.0630")]
[assembly: AssemblyFileVersion("2.3.0.0630")]

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
{