Implements panic bunkering. (#9315)
* Implements panic bunkering. Helps with raid management, esp with unknown accounts. * adds an enable/disable command.
This commit is contained in:
@@ -454,6 +454,7 @@ namespace Content.Server.Database
|
||||
Ban = 0,
|
||||
Whitelist = 1,
|
||||
Full = 2,
|
||||
Panic = 3,
|
||||
}
|
||||
|
||||
public class ServerBanHit
|
||||
|
||||
32
Content.Server/Administration/Commands/PanicBunkerCommand.cs
Normal file
32
Content.Server/Administration/Commands/PanicBunkerCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Server)]
|
||||
public sealed class PanicBunkerCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
public string Command => "panicbunker";
|
||||
public string Description => "Enables or disables the panic bunker functionality.";
|
||||
public string Help => "panicbunker <enabled>";
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bool.TryParse(args[0], out var enabled))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-invalid-bool"));
|
||||
return;
|
||||
}
|
||||
|
||||
_cfg.SetCVar(CCVars.PanicBunkerEnabled, enabled);
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,19 @@ The ban reason is: ""{ban.Reason}""
|
||||
}
|
||||
|
||||
var adminData = await _dbManager.GetAdminDataForAsync(e.UserId);
|
||||
|
||||
if (_cfg.GetCVar(CCVars.PanicBunkerEnabled))
|
||||
{
|
||||
var record = await _dbManager.GetPlayerRecordByUserId(userId);
|
||||
if ((record is null ||
|
||||
record.FirstSeenTime.CompareTo(DateTimeOffset.Now - TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.PanicBunkerMinAccountAge))) < 0)
|
||||
&& !await _db.GetWhitelistStatusAsync(userId)
|
||||
)
|
||||
{
|
||||
return (ConnectionDenyReason.Panic, Loc.GetString("panic-bunker-account-denied"), null);
|
||||
}
|
||||
}
|
||||
|
||||
var wasInGame = EntitySystem.TryGet<GameTicker>(out var ticker) && ticker.PlayersInGame.Contains(userId);
|
||||
if ((_plyMgr.PlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && adminData is null) && !wasInGame)
|
||||
{
|
||||
|
||||
@@ -207,6 +207,18 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<int> SoftMaxPlayers =
|
||||
CVarDef.Create("game.soft_max_players", 30, CVar.SERVERONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not panic bunker is currently enabled.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> PanicBunkerEnabled =
|
||||
CVarDef.Create("game.panic_bunker.enabled", false, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Minimum age of the account (from server's PoV, so from first-seen date) in minutes.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> PanicBunkerMinAccountAge =
|
||||
CVarDef.Create("game.panic_bunker.min_account_age", 1440, CVar.SERVERONLY);
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
/// <summary>
|
||||
/// Amount of times round start must fail before the server is shut down.
|
||||
|
||||
@@ -10,3 +10,4 @@ command-kicknonwhitelisted-description = Kicks all non-whitelisted players from
|
||||
command-kicknonwhitelisted-help = kicknonwhitelisted
|
||||
|
||||
soft-player-cap-full = The server is full!
|
||||
panic-bunker-account-denied = This server is in Panic mode and you were rejected. Contact the server administrator for help.
|
||||
|
||||
@@ -24,6 +24,7 @@ shell-invalid-entity-id = Invalid entity ID.
|
||||
shell-invalid-grid-id = Invalid grid ID.
|
||||
shell-invalid-map-id = Invalid map ID.
|
||||
shell-invalid-entity-uid = {$uid} is not a valid entity uid
|
||||
shell-invalid-bool = Invalid boolean.
|
||||
shell-entity-uid-must-be-number = EntityUid must be a number.
|
||||
shell-could-not-find-entity = Could not find entity {$entity}
|
||||
shell-could-not-find-entity-with-uid = Could not find entity with uid {$uid}
|
||||
|
||||
Reference in New Issue
Block a user