mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
Add cvars to votekick to customize requirements for the initiator. (#32490)
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user