From d6caeb15cc8a627d5c479c20e02bacf24d3be52b Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 7 Oct 2022 18:42:31 +1000 Subject: [PATCH] Fix hard/mediumcore ban on death Removed the force parameter since it is of no use. --- TShockAPI/GetDataHandlers.cs | 2 +- TShockAPI/TSPlayer.cs | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ace40b78..476c42e3 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -4157,7 +4157,7 @@ namespace TShockAPI if (shouldBan) { - if (!args.Player.Ban(banReason, false, "TShock")) + if (!args.Player.Ban(banReason, "TShock")) { TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty); args.Player.Kick("You died! Normally, you'd be banned.", true, true); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 194d11f0..15001757 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1701,30 +1701,26 @@ namespace TShockAPI /// Bans and disconnects the player from the server. /// /// The reason to be displayed to the server. - /// If the ban should bypass immunity to ban checks. /// The player who initiated the ban. - public bool Ban(string reason, bool force = false, string adminUserName = null) + public bool Ban(string reason, string adminUserName = null) { if (!ConnectionAlive) return true; - if (force) - { - TShock.Bans.InsertBan($"{Identifier.IP}{IP}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); - TShock.Bans.InsertBan($"{Identifier.UUID}{UUID}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); - if (Account != null) - { - TShock.Bans.InsertBan($"{Identifier.Account}{Account.Name}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); - } - Disconnect(string.Format("Banned: {0}", reason)); - string verb = force ? "force " : ""; - if (string.IsNullOrWhiteSpace(adminUserName)) - TSPlayer.All.SendInfoMessage("{0} was {1}banned for '{2}'.", Name, verb, reason); - else - TSPlayer.All.SendInfoMessage("{0} {1}banned {2} for '{3}'.", adminUserName, verb, Name, reason); - return true; + TShock.Bans.InsertBan($"{Identifier.IP}{IP}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); + TShock.Bans.InsertBan($"{Identifier.UUID}{UUID}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); + if (Account != null) + { + TShock.Bans.InsertBan($"{Identifier.Account}{Account.Name}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); } - return false; + + Disconnect(string.Format("Banned: {0}", reason)); + + if (string.IsNullOrWhiteSpace(adminUserName)) + TSPlayer.All.SendInfoMessage("{0} was banned for '{1}'.", Name, reason); + else + TSPlayer.All.SendInfoMessage("{0} banned {1} for '{2}'.", adminUserName, Name, reason); + return true; } ///