-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Threading.Tasks; | ||
using Content.Server.Database; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.Players.PlayTimeTracking; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Network; | ||
|
||
namespace Content.Server.Corvax.JoinPlayTime; | ||
|
||
public sealed class JoinPlayTimeManager | ||
{ | ||
[Dependency] private readonly INetManager _net = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly IServerDbManager _db = default!; | ||
|
||
private int _minHours = 0; | ||
|
||
public void Initialize() | ||
{ | ||
_cfg.OnValueChanged(CCVars.JoinPlaytimeHours, (v) => _minHours = v, true); | ||
|
||
_net.Connecting += OnConnecting; | ||
} | ||
|
||
private async Task OnConnecting(NetConnectingArgs arg) | ||
{ | ||
var playTimes = await _db.GetPlayTimes(arg.UserId); | ||
var overallTime = playTimes.Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall); | ||
if (overallTime != null && overallTime.TimeSpent.TotalHours < _minHours) | ||
{ | ||
arg.Deny(Loc.GetString("join-playtime-deny-reason", ("hours", _minHours))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
Resources/Locale/ru-RU/corvax/join-playtime/join-playtime-reason.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
join-playtime-deny-reason = Необходимо минимальное отыгранное время для доступа к серверу - { $hours } { $hours -> | ||
[one] час | ||
[few] часа | ||
*[other] часов | ||
}. |