Soft player cap that lets in only admins. (#5227)
* Soft player cap that lets in only admins. * Update Content.Server/Connection/ConnectionManager.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Server/Connection/ConnectionManager.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Shared;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
@@ -22,6 +24,8 @@ namespace Content.Server.Connection
|
||||
/// </summary>
|
||||
public sealed class ConnectionManager : IConnectionManager
|
||||
{
|
||||
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _plyMgr = default!;
|
||||
[Dependency] private readonly IServerNetManager _netMgr = default!;
|
||||
[Dependency] private readonly IServerDbManager _db = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
@@ -70,6 +74,12 @@ The ban reason is: ""{ban.Reason}""
|
||||
hwId = null;
|
||||
}
|
||||
|
||||
if (_plyMgr.PlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && await _dbManager.GetAdminDataForAsync(e.UserId) is null)
|
||||
{
|
||||
e.Deny("The server is full!");
|
||||
return;
|
||||
}
|
||||
|
||||
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
|
||||
if (ban != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user