Fixes the ShowRulesCommand and the client not syncing rules correctly (#28752)

This commit is contained in:
AJCM-git
2024-06-15 00:41:25 -04:00
committed by GitHub
parent 2953e87f1c
commit c339773b5f
5 changed files with 50 additions and 27 deletions

View File

@@ -12,6 +12,10 @@ namespace Content.Server.Info;
[AdminCommand(AdminFlags.Admin)]
public sealed class ShowRulesCommand : IConsoleCommand
{
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IConfigurationManager _configuration = default!;
[Dependency] private readonly IPlayerManager _player = default!;
public string Command => "showrules";
public string Description => "Opens the rules popup for the specified player.";
public string Help => "showrules <username> [seconds]";
@@ -25,8 +29,7 @@ public sealed class ShowRulesCommand : IConsoleCommand
case 1:
{
target = args[0];
var configurationManager = IoCManager.Resolve<IConfigurationManager>();
seconds = configurationManager.GetCVar(CCVars.RulesWaitTime);
seconds = _configuration.GetCVar(CCVars.RulesWaitTime);
break;
}
case 2:
@@ -48,15 +51,14 @@ public sealed class ShowRulesCommand : IConsoleCommand
}
var message = new ShowRulesPopupMessage { PopupTime = seconds };
if (!IoCManager.Resolve<IPlayerManager>().TryGetSessionByUsername(target, out var player))
if (!_player.TryGetSessionByUsername(target, out var player))
{
shell.WriteError("Unable to find a player with that name.");
return;
}
var netManager = IoCManager.Resolve<INetManager>();
netManager.ServerSendMessage(message, player.Channel);
var coreRules = _configuration.GetCVar(CCVars.RulesFile);
var message = new SendRulesInformationMessage { PopupTime = seconds, CoreRules = coreRules, ShouldShowRules = true};
_net.ServerSendMessage(message, player.Channel);
}
}