diff --git a/CHANGELOG.md b/CHANGELOG.md index 41263289..8b81bb18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Replaced `Utils.FindPlayer` with `TSPlayer.FindByNameOrID` to more appropriately be object orientated. (@hakusaro) * Removed `Utils.ActivePlayers()` -- use `TShock.Players.Length` instead. (@hakusaro) * Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro) +* Removed `Utils.ForceKick()`. (@hakusaro) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a3268bf0..d1d004b2 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -77,7 +77,7 @@ namespace TShockAPI if (String.IsNullOrEmpty(args.Player.Name)) { - TShock.Utils.ForceKick(args.Player, "Blank name.", true); + args.Player.Kick("Your client sent a blank character name.", true, true); args.Handled = true; return; } @@ -941,7 +941,7 @@ namespace TShockAPI if (damage > 20000) //Abnormal values have the potential to cause infinite loops in the server. { - TShock.Utils.ForceKick(args.Player, "Crash Exploit Attempt", true); + args.Player.Kick("Failed to shade polygon normals.", true, true); TShock.Log.ConsoleError("Death Exploit Attempt: Damage {0}", damage); args.Handled = true; return; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 93b6e652..89056593 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -349,7 +349,7 @@ namespace TShockAPI } /// /// PlayerInfo - called at a PlayerInfo event - /// If this is cancelled, the server will ForceKick the player. If this should be changed in the future, let someone know. + /// If this is cancelled, the server will kick the player. If this should be changed in the future, let someone know. /// public static HandlerList PlayerInfo = new HandlerList(); @@ -1715,13 +1715,13 @@ namespace TShockAPI if (OnPlayerInfo(args.Player, args.Data, playerid, hair, skinVariant, difficulty, name)) { - TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event.", true); + args.Player.Kick("A plugin on this server stopped your login.", true, true); return true; } if (name.Trim().Length == 0) { - TShock.Utils.ForceKick(args.Player, "Empty Name.", true); + args.Player.Kick("You have been Bounced.", true, true); return true; } if (args.Player.ReceivedInfo) @@ -1749,12 +1749,12 @@ namespace TShockAPI } if (TShock.Config.MediumcoreOnly && difficulty < 1) { - TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!", true); + args.Player.Kick("You need to join with a mediumcore player or higher.", true, true); return true; } if (TShock.Config.HardcoreOnly && difficulty < 2) { - TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!", true); + args.Player.Kick("You need to join with a hardcore player.", true, true); return true; } args.Player.Difficulty = difficulty; @@ -1884,9 +1884,10 @@ namespace TShockAPI Hooks.PlayerHooks.OnPlayerPostLogin(args.Player); return true; } - TShock.Utils.ForceKick(args.Player, "Invalid user account password.", true); + args.Player.Kick("Your password did not match this character's password.", true, true); return true; } + if (!string.IsNullOrEmpty(TShock.Config.ServerPassword)) { if (TShock.Config.ServerPassword == password) @@ -1897,11 +1898,11 @@ namespace TShockAPI NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); return true; } - TShock.Utils.ForceKick(args.Player, "Incorrect server password", true); + args.Player.Kick("Invalid server password.", true, true); return true; } - TShock.Utils.ForceKick(args.Player, "Bad password attempt", true); + args.Player.Kick("You have been Bounced.", true, true); return true; } @@ -1949,7 +1950,7 @@ namespace TShockAPI if (TShock.Players.Length + 1 > TShock.Config.MaxSlots && !args.Player.HasPermission(Permissions.reservedslot)) { - TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason, true); + args.Player.Kick(TShock.Config.ServerFullReason, true, true); return true; } @@ -2439,11 +2440,11 @@ namespace TShockAPI if (TShock.Config.BanOnHardcoreDeath) { if (!TShock.Utils.Ban(args.Player, TShock.Config.HardcoreBanReason, false, "hardcore-death")) - TShock.Utils.ForceKick(args.Player, "Death results in a ban, but you are immune to bans.", true); + args.Player.Kick("You died! Normally, you'd be banned.", true, true); } else { - TShock.Utils.ForceKick(args.Player, TShock.Config.HardcoreKickReason, true, false); + args.Player.Kick(TShock.Config.HardcoreKickReason, true, true, null, false); } } @@ -2503,11 +2504,11 @@ namespace TShockAPI if (TShock.Config.BanOnMediumcoreDeath) { if (!TShock.Utils.Ban(args.Player, TShock.Config.MediumcoreBanReason, false, "mediumcore-death")) - TShock.Utils.ForceKick(args.Player, "Death results in a ban, but you are immune to bans.", true); + args.Player.Kick("You died! Normally, you'd be banned.", true, true); } else { - TShock.Utils.ForceKick(args.Player, TShock.Config.MediumcoreKickReason, true, false); + args.Player.Kick(TShock.Config.MediumcoreKickReason, true, true, null, false); } return true; } diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index 1cf5fe96..cad79834 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -982,7 +982,7 @@ namespace TShockAPI return ret; TSPlayer player = (TSPlayer)ret; - TShock.Utils.ForceKick(player, null == args.Parameters["reason"] ? "Kicked via web" : args.Parameters["reason"], false, true); + player.Kick(null == args.Parameters["reason"] ? "Kicked via web" : args.Parameters["reason"], false, true, null, true); return RestResponse("Player " + player.Name + " was kicked"); } @@ -1002,7 +1002,7 @@ namespace TShockAPI TSPlayer player = (TSPlayer)ret; var reason = null == args.Parameters["reason"] ? "Banned via web" : args.Parameters["reason"]; TShock.Bans.AddBan2(player.IP, player.Name, "", "", reason); - TShock.Utils.ForceKick(player, reason, false, true); + player.Kick(reason, true, false, null, true); return RestResponse("Player " + player.Name + " was banned"); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 61714a8c..18b618e7 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -481,13 +481,13 @@ namespace TShockAPI // And then get rid of them. if (potentialBan.Expiration == "") { - Utils.ForceKick(args.Player, String.Format("Permanently banned by {0} for {1}", potentialBan.BanningUser - ,potentialBan.Reason), false, false); + args.Player.Kick(String.Format("Permanently banned by {0} for {1}", potentialBan.BanningUser + ,potentialBan.Reason), true, true); } else { - Utils.ForceKick(args.Player, String.Format("Still banned by {0} for {1}", potentialBan.BanningUser, - potentialBan.Reason), false, false); + args.Player.Kick(String.Format("Still banned by {0} for {1}", potentialBan.BanningUser, + potentialBan.Reason), true, true); } } } @@ -1245,14 +1245,14 @@ namespace TShockAPI if (TShock.Players.Length + 1 > Config.MaxSlots + Config.ReservedSlots) { - Utils.ForceKick(player, Config.ServerFullNoReservedReason, true, false); + player.Kick(Config.ServerFullNoReservedReason, true, true, null, false); args.Handled = true; return; } if (!FileTools.OnWhitelist(player.IP)) { - Utils.ForceKick(player, Config.WhitelistKickReason, true, false); + player.Kick(Config.WhitelistKickReason, true, true, null, false); args.Handled = true; return; } @@ -1265,7 +1265,7 @@ namespace TShockAPI { if (Config.KickProxyUsers) { - Utils.ForceKick(player, "Proxies are not allowed.", true, false); + player.Kick("Connecting via a proxy is not allowed.", true, true, null, false); args.Handled = true; return; } @@ -1287,7 +1287,7 @@ namespace TShockAPI if (Config.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID)) { - Utils.ForceKick(player, "Your client did not send a UUID, this server is not configured to accept such a client.", true); + player.Kick("Your client sent a blank UUID. Configure it to send one or use a different client.", true, true, null, false); args.Handled = true; return; } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 54411a55..0f4d724a 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -506,7 +506,7 @@ namespace TShockAPI { if (player != null && player.Active) { - ForceKick(player, reason, false, true); + player.Kick(reason, true, true, null, true); } } } @@ -549,18 +549,6 @@ namespace TShockAPI Hooks.GeneralHooks.OnReloadEvent(player); } - /// - /// Kicks a player from the server without checking for immunetokick permission. - /// - /// TSPlayer player - /// string reason - /// bool silent (default: false) - /// bool saveSSI (default: false) - public void ForceKick(TSPlayer player, string reason, bool silent = false, bool saveSSI = false) - { - player.Kick(reason, true, silent, null, saveSSI); - } - /// /// Bans and kicks a player from the server. ///