Broadcast on saveWorld.
(Latest API required)
This commit is contained in:
parent
e680e39bb0
commit
e4ee06f659
3 changed files with 20 additions and 3 deletions
|
|
@ -67,7 +67,7 @@ namespace TShockAPI
|
||||||
if (worldpath != null && !Directory.Exists(worldpath))
|
if (worldpath != null && !Directory.Exists(worldpath))
|
||||||
Directory.CreateDirectory(worldpath);
|
Directory.CreateDirectory(worldpath);
|
||||||
|
|
||||||
Tools.Broadcast("Server map saving, potential lag spike");
|
//Tools.Broadcast("Server map saving, potential lag spike");
|
||||||
WorldGen.saveWorld();
|
WorldGen.saveWorld();
|
||||||
|
|
||||||
Console.WriteLine("World backed up");
|
Console.WriteLine("World backed up");
|
||||||
|
|
|
||||||
|
|
@ -1003,9 +1003,9 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static void Save(CommandArgs args)
|
private static void Save(CommandArgs args)
|
||||||
{
|
{
|
||||||
Tools.Broadcast("Server map saving, potential lag spike");
|
//Tools.Broadcast("Server map saving, potential lag spike");
|
||||||
WorldGen.saveWorld();
|
WorldGen.saveWorld();
|
||||||
args.Player.SendMessage("World saved.");
|
//args.Player.SendMessage("World saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MaxSpawns(CommandArgs args)
|
private static void MaxSpawns(CommandArgs args)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static IDbConnection Sql;
|
public static IDbConnection Sql;
|
||||||
|
|
||||||
|
public static bool WorldSaving = false;
|
||||||
|
|
||||||
public override Version Version
|
public override Version Version
|
||||||
{
|
{
|
||||||
get { return VersionNum; }
|
get { return VersionNum; }
|
||||||
|
|
@ -105,6 +107,7 @@ namespace TShockAPI
|
||||||
NetHooks.GreetPlayer += OnGreetPlayer;
|
NetHooks.GreetPlayer += OnGreetPlayer;
|
||||||
NetHooks.SendData += OnSendData;
|
NetHooks.SendData += OnSendData;
|
||||||
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
||||||
|
WorldHooks.SaveWorld += OnSaveWorld;
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
Bans.LoadBans();
|
Bans.LoadBans();
|
||||||
|
|
@ -131,6 +134,7 @@ namespace TShockAPI
|
||||||
NetHooks.GreetPlayer -= OnGreetPlayer;
|
NetHooks.GreetPlayer -= OnGreetPlayer;
|
||||||
NetHooks.SendData -= OnSendData;
|
NetHooks.SendData -= OnSendData;
|
||||||
NpcHooks.StrikeNpc -= NpcHooks_OnStrikeNpc;
|
NpcHooks.StrikeNpc -= NpcHooks_OnStrikeNpc;
|
||||||
|
WorldHooks.SaveWorld -= OnSaveWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -533,6 +537,19 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSaveWorld(bool resettime, HandledEventArgs e)
|
||||||
|
{
|
||||||
|
if (!WorldSaving)
|
||||||
|
{
|
||||||
|
WorldSaving = true;
|
||||||
|
Tools.Broadcast("Saving world, might lag.", Color.Red);
|
||||||
|
WorldGen.saveWorld(resettime);
|
||||||
|
Tools.Broadcast("World saved.", Color.LimeGreen);
|
||||||
|
WorldSaving = false;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useful stuff:
|
* Useful stuff:
|
||||||
* */
|
* */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue