From 957b8de89b0026d67efadac475763ea910339e2f Mon Sep 17 00:00:00 2001 From: Vasilis Date: Sat, 2 Nov 2024 02:34:23 +0100 Subject: [PATCH] Add cvars to votekick to customize requirements for the initiator. (#32490) --- Content.Server/Voting/VotingSystem.cs | 9 +++++++-- Content.Shared/CCVar/CCVars.cs | 12 ++++++++++++ Resources/Locale/en-US/voting/ui/vote-call-menu.ftl | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Content.Server/Voting/VotingSystem.cs b/Content.Server/Voting/VotingSystem.cs index 3d3aeb4859..5df1ce7c1f 100644 --- a/Content.Server/Voting/VotingSystem.cs +++ b/Content.Server/Voting/VotingSystem.cs @@ -13,6 +13,7 @@ using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Timing; using System.Threading.Tasks; +using Content.Shared.Players.PlayTimeTracking; namespace Content.Server.Voting; @@ -26,6 +27,7 @@ public sealed class VotingSystem : EntitySystem [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly JobSystem _jobs = default!; [Dependency] private readonly GameTicker _gameTicker = default!; + [Dependency] private readonly ISharedPlaytimeManager _playtimeManager = default!; public override void Initialize() { @@ -109,10 +111,13 @@ public sealed class VotingSystem : EntitySystem } // Must be whitelisted - if (!await _dbManager.GetWhitelistStatusAsync(initiator.UserId)) + if (!await _dbManager.GetWhitelistStatusAsync(initiator.UserId) && _cfg.GetCVar(CCVars.VotekickInitiatorWhitelistedRequirement)) return false; - return true; + // Must be eligible to vote + var playtime = _playtimeManager.GetPlayTimes(initiator); + return playtime.TryGetValue(PlayTimeTrackingShared.TrackerOverall, out TimeSpan overallTime) && (overallTime >= TimeSpan.FromHours(_cfg.GetCVar(CCVars.VotekickEligibleVoterPlaytime)) + || !_cfg.GetCVar(CCVars.VotekickInitiatorTimeRequirement)); } /// diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index d1dc9d9ade..81a0668bdb 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -1477,6 +1477,18 @@ namespace Content.Shared.CCVar public static readonly CVarDef VotekickInitiatorGhostRequirement = CVarDef.Create("votekick.initiator_ghost_requirement", true, CVar.SERVERONLY); + /// + /// Should the initiator be whitelisted to initiate a votekick? + /// + public static readonly CVarDef VotekickInitiatorWhitelistedRequirement = + CVarDef.Create("votekick.initiator_whitelist_requirement", true, CVar.SERVERONLY); + + /// + /// Should the initiator be able to start a votekick if they are bellow the votekick.voter_playtime requirement? + /// + public static readonly CVarDef VotekickInitiatorTimeRequirement = + CVarDef.Create("votekick.initiator_time_requirement", false, CVar.SERVERONLY); + /// /// Whether a votekick voter must be a ghost or not. /// diff --git a/Resources/Locale/en-US/voting/ui/vote-call-menu.ftl b/Resources/Locale/en-US/voting/ui/vote-call-menu.ftl index fbae3598ed..82e3a5d1f8 100644 --- a/Resources/Locale/en-US/voting/ui/vote-call-menu.ftl +++ b/Resources/Locale/en-US/voting/ui/vote-call-menu.ftl @@ -25,7 +25,7 @@ ui-vote-type-not-available = This vote type has been disabled # Vote option only available for specific users. ui-vote-trusted-users-notice = - This vote option is only available to whitelisted players. + This vote option is only available to players who have enough playtime or are whitelisted. In addition, you must have been a ghost for { $timeReq } seconds. # Warning to not abuse a specific vote option. -- 2.51.2