Whitelist player constraints (#13812)
This commit is contained in:
@@ -121,7 +121,7 @@ namespace Content.Server.Connection
|
|||||||
var minOverallHours = _cfg.GetCVar(CCVars.PanicBunkerMinOverallHours);
|
var minOverallHours = _cfg.GetCVar(CCVars.PanicBunkerMinOverallHours);
|
||||||
var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
|
var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
|
||||||
var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours;
|
var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours;
|
||||||
|
|
||||||
if (showReason && !haveMinOverallTime)
|
if (showReason && !haveMinOverallTime)
|
||||||
{
|
{
|
||||||
return (ConnectionDenyReason.Panic,
|
return (ConnectionDenyReason.Panic,
|
||||||
@@ -150,11 +150,21 @@ namespace Content.Server.Connection
|
|||||||
return (ConnectionDenyReason.Ban, firstBan.DisconnectMessage, bans);
|
return (ConnectionDenyReason.Ban, firstBan.DisconnectMessage, bans);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cfg.GetCVar(CCVars.WhitelistEnabled)
|
if (_cfg.GetCVar(CCVars.WhitelistEnabled))
|
||||||
&& await _db.GetWhitelistStatusAsync(userId) == false
|
|
||||||
&& adminData is null)
|
|
||||||
{
|
{
|
||||||
return (ConnectionDenyReason.Whitelist, Loc.GetString(_cfg.GetCVar(CCVars.WhitelistReason)), null);
|
var min = _cfg.GetCVar(CCVars.WhitelistMinPlayers);
|
||||||
|
var max = _cfg.GetCVar(CCVars.WhitelistMaxPlayers);
|
||||||
|
var playerCountValid = _plyMgr.PlayerCount > min && _plyMgr.PlayerCount < max;
|
||||||
|
|
||||||
|
if (playerCountValid && await _db.GetWhitelistStatusAsync(userId) == false
|
||||||
|
&& adminData is null)
|
||||||
|
{
|
||||||
|
var msg = Loc.GetString(_cfg.GetCVar(CCVars.WhitelistReason));
|
||||||
|
// was the whitelist playercount changed?
|
||||||
|
if (min > 0 || max < int.MaxValue)
|
||||||
|
msg += "\n" + Loc.GetString("whitelist-playercount-invalid", ("min", min), ("max", max));
|
||||||
|
return (ConnectionDenyReason.Whitelist, msg, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -940,6 +940,18 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<string> WhitelistReason =
|
public static readonly CVarDef<string> WhitelistReason =
|
||||||
CVarDef.Create("whitelist.reason", "whitelist-not-whitelisted", CVar.SERVERONLY);
|
CVarDef.Create("whitelist.reason", "whitelist-not-whitelisted", CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the playercount is below this number, the whitelist will not apply.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<int> WhitelistMinPlayers =
|
||||||
|
CVarDef.Create("whitelist.min_players", 0, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the playercount is above this number, the whitelist will not apply.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<int> WhitelistMaxPlayers =
|
||||||
|
CVarDef.Create("whitelist.max_players", int.MaxValue, CVar.SERVERONLY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VOTE
|
* VOTE
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
whitelist-not-whitelisted = You are not whitelisted.
|
whitelist-not-whitelisted = You are not whitelisted.
|
||||||
|
|
||||||
|
# proper handling for having a min/max or not
|
||||||
|
whitelist-playercount-invalid = {$min ->
|
||||||
|
[0] The whitelist for this server only applies below {$max} players.
|
||||||
|
*[other] The whitelist for this server only applies above {$min} {$max ->
|
||||||
|
[2147483647] -> players, so you may be able to join later.
|
||||||
|
*[other] -> players and below {$max} players, so you may be able to join later.
|
||||||
|
}
|
||||||
|
}
|
||||||
whitelist-not-whitelisted-rp = You are not whitelisted. To become whitelisted, visit our Discord (which can be found at https://spacestation14.io) and check the #rp-whitelist channel.
|
whitelist-not-whitelisted-rp = You are not whitelisted. To become whitelisted, visit our Discord (which can be found at https://spacestation14.io) and check the #rp-whitelist channel.
|
||||||
|
|
||||||
command-whitelistadd-description = Adds the player with the given username to the server whitelist.
|
command-whitelistadd-description = Adds the player with the given username to the server whitelist.
|
||||||
|
|||||||
Reference in New Issue
Block a user