]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add cvars to votekick to customize requirements for the initiator. (#32490)
authorVasilis <vasilis@pikachu.systems>
Sat, 2 Nov 2024 01:34:23 +0000 (02:34 +0100)
committerGitHub <noreply@github.com>
Sat, 2 Nov 2024 01:34:23 +0000 (21:34 -0400)
Content.Server/Voting/VotingSystem.cs
Content.Shared/CCVar/CCVars.cs
Resources/Locale/en-US/voting/ui/vote-call-menu.ftl

index 3d3aeb485989f854701e37c6176da6d161eb46cb..5df1ce7c1f08387155403090d2f65d8ba87ed437 100644 (file)
@@ -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));
     }
 
     /// <summary>
index d1dc9d9ade16dae5378486349832f7ef732b0056..81a0668bdb6be464d108a2d3929f30f1b57cbacd 100644 (file)
@@ -1477,6 +1477,18 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> VotekickInitiatorGhostRequirement =
             CVarDef.Create("votekick.initiator_ghost_requirement", true, CVar.SERVERONLY);
 
+        /// <summary>
+        ///     Should the initiator be whitelisted to initiate a votekick?
+        /// </summary>
+        public static readonly CVarDef<bool> VotekickInitiatorWhitelistedRequirement =
+            CVarDef.Create("votekick.initiator_whitelist_requirement", true, CVar.SERVERONLY);
+
+        /// <summary>
+        ///     Should the initiator be able to start a votekick if they are bellow the votekick.voter_playtime requirement?
+        /// </summary>
+        public static readonly CVarDef<bool> VotekickInitiatorTimeRequirement =
+            CVarDef.Create("votekick.initiator_time_requirement", false, CVar.SERVERONLY);
+
         /// <summary>
         ///     Whether a votekick voter must be a ghost or not.
         /// </summary>
index fbae3598ed619adfdaae0bd74673bf85559697cb..82e3a5d1f82e6af5cd6e37bf7fac53a3aed6da0d 100644 (file)
@@ -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.