Skip to content

Commit

Permalink
add admin time (#390)
Browse files Browse the repository at this point in the history
Co-authored-by: Artur Zhidkov <[email protected]>
  • Loading branch information
Werzet and TheArturZh authored Oct 2, 2023
1 parent 28afec6 commit 9c61476
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly PlayTimeTrackingManager _tracking = default!;

private string AdminTrackerTime => "AdminTime";

public override void Initialize()
{
base.Initialize();

_tracking.CalcTrackers += CalcTrackers;
_adminManager.OnPermsChanged += AdminManager_OnPermsChanged;

SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundEnd);
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
Expand All @@ -50,6 +53,12 @@ public override void Initialize()
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
}

private void AdminManager_OnPermsChanged(Administration.AdminPermsChangedEventArgs obj)
{
if (_minds.TryGetSession(obj.Player.GetMind(), out var session))
_tracking.QueueRefreshTrackers(session);
}

public override void Shutdown()
{
base.Shutdown();
Expand All @@ -66,6 +75,11 @@ private void CalcTrackers(IPlayerSession player, HashSet<string> trackers)
if (_afk.IsAfk(player))
return;

if (_adminManager.IsAdmin(player, includeDeAdmin: false))
{
trackers.Add(AdminTrackerTime);
}

if (!IsPlayerAlive(player))
return;

Expand Down

0 comments on commit 9c61476

Please sign in to comment.