diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index e1cbaf15..a2a52de7 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -500,6 +500,8 @@ namespace TShockAPI { return Tools.HandleGriefer(args.Player, TShock.Config.KillMeAbuseReason); } + args.Player.LastDeath = DateTime.Now; + args.Player.ForceSpawn = true; return false; } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 9fab4321..426f9638 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -58,6 +58,8 @@ namespace TShockAPI public bool TpLock = false; Player FakePlayer; public List RequestedSections = new List(); + public DateTime LastDeath { get; set; } + public bool ForceSpawn = false; public bool RealPlayer { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index e4ae03f5..87711492 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -385,6 +385,11 @@ namespace TShockAPI } if (CheckPlayerCollision(player.TileX, player.TileY)) player.SendMessage("You are currently nocliping!", Color.Red); + if (player.LastDeath != null && player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3) + { + player.Spawn(); + player.ForceSpawn = false; + } } } }