Merge pull request #422 from stevenh/general-devel
Signature Fix & protection against down stream errors
This commit is contained in:
commit
ab9004df66
2 changed files with 31 additions and 11 deletions
|
|
@ -30,9 +30,19 @@ namespace TShockAPI
|
||||||
/// SaveWorld event handler which notifies users that the server may lag
|
/// SaveWorld event handler which notifies users that the server may lag
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnSaveWorld(bool resettime = false, HandledEventArgs e = null)
|
public void OnSaveWorld(bool resettime = false, HandledEventArgs e = null)
|
||||||
|
{
|
||||||
|
// Protect against internal errors causing save failures
|
||||||
|
// These can be caused by an unexpected error such as a bad or out of date plugin
|
||||||
|
try
|
||||||
{
|
{
|
||||||
TShock.Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red);
|
TShock.Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error("World saved notification failed");
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the map data
|
/// Saves the map data
|
||||||
|
|
@ -87,6 +97,10 @@ namespace TShockAPI
|
||||||
if (null == task)
|
if (null == task)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// Ensure that save handler errors don't bubble up and cause a recursive call
|
||||||
|
// These can be caused by an unexpected error such as a bad or out of date plugin
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (task.direct)
|
if (task.direct)
|
||||||
{
|
{
|
||||||
|
|
@ -98,6 +112,12 @@ namespace TShockAPI
|
||||||
TShock.Utils.Broadcast("World saved.", Color.Yellow);
|
TShock.Utils.Broadcast("World saved.", Color.Yellow);
|
||||||
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("World saved failed");
|
||||||
|
Log.Error(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_wh.WaitOne();
|
_wh.WaitOne();
|
||||||
|
|
|
||||||
|
|
@ -532,9 +532,9 @@ namespace TShockAPI
|
||||||
|
|
||||||
#if COMPAT_SIGS
|
#if COMPAT_SIGS
|
||||||
[Obsolete("This method is for signature compatibility for external code only")]
|
[Obsolete("This method is for signature compatibility for external code only")]
|
||||||
public bool ForceKick(TSPlayer player, string reason)
|
public void ForceKick(TSPlayer player, string reason)
|
||||||
{
|
{
|
||||||
return Kick(player, reason, true, false, string.Empty);
|
Kick(player, reason, true, false, string.Empty);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue