diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index 0d7ffe73..c0e671ff 100755
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -443,13 +443,7 @@ namespace TShockAPI
public static void Off(CommandArgs args)
{
- for (int player = 0; player < Main.maxPlayers; player++)
- {
- if (Main.player[player].active)
- {
- Tools.ForceKick(player, "Server shutting down!");
- }
- }
+ Tools.ForceKickAll("Server shutting down!");
WorldGen.saveWorld();
Netplay.disconnect = true;
}
@@ -1066,13 +1060,7 @@ namespace TShockAPI
Process.Start(new ProcessStartInfo("UpdateTShock.exe"));
- for (int player = 0; player < Main.maxPlayers; player++)
- {
- if (Main.player[player].active)
- {
- Tools.ForceKick(player, "Server shutting down for update!");
- }
- }
+ Tools.ForceKickAll("Server shutting down for update!");
WorldGen.saveWorld();
Netplay.disconnect = true;
}
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 1566645d..79344a7e 100755
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -231,13 +231,7 @@ namespace TShockAPI
}
if (text.StartsWith("exit"))
{
- for (int player = 0; player < Main.maxPlayers; player++)
- {
- if (Main.player[player].active)
- {
- Tools.ForceKick(player, "Server shutting down!");
- }
- }
+ Tools.ForceKickAll("Server shutting down!");
}
if (text.StartsWith("playing"))
{
diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs
index 9059278c..9e82b09a 100755
--- a/TShockAPI/Tools.cs
+++ b/TShockAPI/Tools.cs
@@ -196,6 +196,22 @@ namespace TShockAPI
}
}
+ ///
+ /// Kicks all player from the server without checking for immunetokick permission.
+ ///
+ /// int player
+ /// string reason
+ public static void ForceKickAll(string reason)
+ {
+ for (int player = 0; player < Main.maxPlayers; player++)
+ {
+ if (Main.player[player].active)
+ {
+ Tools.ForceKick(player, reason);
+ }
+ }
+ }
+
///
/// Kicks a player from the server without checking for immunetokick permission.
///