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:
Moony
2022-07-01 15:46:37 -05:00
committed by GitHub
parent 2284412def
commit 8e90bf46e9
6 changed files with 60 additions and 0 deletions

View File

@@ -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)
{