Remove Utils.ForceKickAll; add TSPlayer.KickAll.

This commit is contained in:
Lucas Nicodemus 2017-12-27 18:06:01 -07:00
parent 1ea04ffd4f
commit 8301d6a6f3
3 changed files with 18 additions and 18 deletions

View file

@ -69,6 +69,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Removed `Utils.ActivePlayers()` -- use `TShock.Players.Length` instead. (@hakusaro) * Removed `Utils.ActivePlayers()` -- use `TShock.Players.Length` instead. (@hakusaro)
* Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro) * Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro)
* Removed `Utils.ForceKick()`. (@hakusaro) * Removed `Utils.ForceKick()`. (@hakusaro)
* Replaced `Utils.ForceKickAll()` with `TSPlayer.KickAll`. (@hakusaro)
## TShock 4.3.25 ## 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. * 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.

View file

@ -110,6 +110,22 @@ namespace TShockAPI
return found; return found;
} }
/// <summary>
/// Disconnects all players from the server without checking for immunetokick permission.
/// </summary>
/// <param name="force">If the kick should bypass permission checks.</param>
/// <param name="reason">The reason for the kick.</param>
public static void KickAll(bool force, string reason)
{
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.Active)
{
player.Kick(reason, force, true, null, true);
}
}
}
/// <summary> /// <summary>
/// The amount of tiles that the player has killed in the last second. /// The amount of tiles that the player has killed in the last second.
/// </summary> /// </summary>

View file

@ -496,21 +496,6 @@ namespace TShockAPI
return GetPrefixByName(idOrName); return GetPrefixByName(idOrName);
} }
/// <summary>
/// Kicks all player from the server without checking for immunetokick permission.
/// </summary>
/// <param name="reason">string reason</param>
public void ForceKickAll(string reason)
{
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.Active)
{
player.Kick(reason, true, true, null, true);
}
}
}
/// <summary> /// <summary>
/// Stops the server after kicking all players with a reason message, and optionally saving the world /// Stops the server after kicking all players with a reason message, and optionally saving the world
/// </summary> /// </summary>
@ -520,12 +505,10 @@ namespace TShockAPI
{ {
TShock.ShuttingDown = true; TShock.ShuttingDown = true;
ForceKickAll(reason);
if (save) if (save)
SaveManager.Instance.SaveWorld(); SaveManager.Instance.SaveWorld();
// Save takes a while so kick again TSPlayer.KickAll(true, reason);
ForceKickAll(reason);
// Broadcast so console can see we are shutting down as well // Broadcast so console can see we are shutting down as well
TShock.Utils.Broadcast(reason, Color.Red); TShock.Utils.Broadcast(reason, Color.Red);