mirror of
https://github.com/MSWS/TTT.git
synced 2025-12-05 22:20:25 -08:00
fix: Ensure player has required flags for auto rtds (resolves #193)
This commit is contained in:
@@ -25,6 +25,9 @@ public class AutoRTDCommand(IServiceProvider provider) : ICommand, IListener {
|
|||||||
private readonly IMsgLocalizer localizer =
|
private readonly IMsgLocalizer localizer =
|
||||||
provider.GetRequiredService<IMsgLocalizer>();
|
provider.GetRequiredService<IMsgLocalizer>();
|
||||||
|
|
||||||
|
private readonly IPermissionManager perms =
|
||||||
|
provider.GetRequiredService<IPermissionManager>();
|
||||||
|
|
||||||
private readonly Dictionary<string, bool> playerStatuses = new();
|
private readonly Dictionary<string, bool> playerStatuses = new();
|
||||||
private ICookie? autoRtdCookie;
|
private ICookie? autoRtdCookie;
|
||||||
public string Id => "autortd";
|
public string Id => "autortd";
|
||||||
@@ -75,9 +78,10 @@ public class AutoRTDCommand(IServiceProvider provider) : ICommand, IListener {
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
[EventHandler]
|
[EventHandler]
|
||||||
public void OnRoundStart(GameInitEvent ev) {
|
public void OnRoundStart(GameInitEvent ev) {
|
||||||
var messenger = provider.GetRequiredService<IMessenger>();
|
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
foreach (var player in finder.GetOnline()) {
|
foreach (var player in finder.GetOnline()) {
|
||||||
|
if (!perms.HasFlags(player, RequiredFlags)) continue;
|
||||||
|
|
||||||
if (!playerStatuses.TryGetValue(player.Id, out var status)) {
|
if (!playerStatuses.TryGetValue(player.Id, out var status)) {
|
||||||
await fetchCookie(player);
|
await fetchCookie(player);
|
||||||
status = playerStatuses.GetValueOrDefault(player.Id, false);
|
status = playerStatuses.GetValueOrDefault(player.Id, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user