using Robust.Shared.Player;
using Robust.Shared.Timing;
using System.Threading.Tasks;
+using Content.Shared.Players.PlayTimeTracking;
namespace Content.Server.Voting;
[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()
{
}
// 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>
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>
# 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.