Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions EXILED/Exiled.API/Features/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ public static bool IsIdleModeEnabled
/// <seealso cref="RestartRedirect(ushort)"/>
public static void Restart() => Round.Restart(false, true, ServerStatic.NextRoundAction.Restart);

/// <summary>
/// Restarts the server with specified options.
/// </summary>
/// <param name="fastRestart">Indicates whether the restart should be fast.</param>
/// <param name="overrideRestartAction">Indicates whether to override the default restart action.</param>
/// <param name="restartAction">Specifies the action to perform after the restart.</param>
public static void Restart(bool fastRestart, bool overrideRestartAction = false, ServerStatic.NextRoundAction restartAction = ServerStatic.NextRoundAction.DoNothing) =>
Round.Restart(fastRestart, overrideRestartAction, restartAction);

/// <summary>
/// Shutdowns the server, disconnects all players.
/// </summary>
Expand Down Expand Up @@ -266,6 +275,19 @@ public static bool RestartRedirect(ushort redirectPort)
return true;
}

/// <summary>
/// Redirects players to a server on another port, restarts the current server.
/// </summary>
/// <param name="redirectPort">The port to redirect players to.</param>
/// <param name="fastRestart">Indicates whether the restart should be fast.</param>
/// <param name="overrideRestartAction">Indicates whether to override the default restart action.</param>
/// <param name="restartAction">Specifies the action to perform after the restart.</param>
public static void RestartRedirect(ushort redirectPort, bool fastRestart, bool overrideRestartAction = false, ServerStatic.NextRoundAction restartAction = ServerStatic.NextRoundAction.DoNothing)
{
NetworkServer.SendToAll(new RoundRestartMessage(RoundRestartType.RedirectRestart, 0.0f, redirectPort, true, false));
Timing.CallDelayed(0.5f, () => { Restart(fastRestart, overrideRestartAction, restartAction); });
}

/// <summary>
/// Redirects players to a server on another port, shutdowns the current server.
/// </summary>
Expand All @@ -280,6 +302,18 @@ public static bool ShutdownRedirect(ushort redirectPort)
return true;
}

/// <summary>
/// Redirects players to a server on another port, shutdowns the current server.
/// </summary>
/// <param name="redirectPort">The port to redirect players to.</param>
/// <param name="quit">Indicates whether to terminate the application after shutting down the server.</param>
/// <param name="suppressShutdownBroadcast">Indicates whether to suppress the broadcast notification about the shutdown.</param>
public static void ShutdownRedirect(ushort redirectPort, bool quit, bool suppressShutdownBroadcast = false)
{
NetworkServer.SendToAll(new RoundRestartMessage(RoundRestartType.RedirectRestart, 0.0f, redirectPort, true, false));
Timing.CallDelayed(0.5f, () => { Shutdown(quit, suppressShutdownBroadcast); });
}

/// <summary>
/// Executes a server command.
/// </summary>
Expand Down
Loading