Fix not showing ahelp relay label to players (#15327)

This commit is contained in:
DrSmugleaf
2023-04-11 17:19:09 -07:00
committed by GitHub
parent 21378f6e41
commit c25d7ba7bd
3 changed files with 24 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ public sealed class AHelpUIController: UIController, IOnStateChanged<GameplaySta
{ {
base.Initialize(); base.Initialize();
SubscribeNetworkEvent<SharedBwoinkSystem.BwoinkDiscordRelayUpdated>(DiscordRelayUpdated); SubscribeNetworkEvent<BwoinkDiscordRelayUpdated>(DiscordRelayUpdated);
} }
public void OnStateEntered(GameplayState state) public void OnStateEntered(GameplayState state)
@@ -137,7 +137,7 @@ public sealed class AHelpUIController: UIController, IOnStateChanged<GameplaySta
UIHelper!.Receive(message); UIHelper!.Receive(message);
} }
private void DiscordRelayUpdated(SharedBwoinkSystem.BwoinkDiscordRelayUpdated args, EntitySessionEventArgs session) private void DiscordRelayUpdated(BwoinkDiscordRelayUpdated args, EntitySessionEventArgs session)
{ {
_discordRelayActive = args.DiscordRelayEnabled; _discordRelayActive = args.DiscordRelayEnabled;
UIHelper?.DiscordRelayChanged(_discordRelayActive); UIHelper?.DiscordRelayChanged(_discordRelayActive);

View File

@@ -15,6 +15,7 @@ using JetBrains.Annotations;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared; using Robust.Shared;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -63,10 +64,19 @@ namespace Content.Server.Administration.Systems
_config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true); _config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP"); _sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true).Length; _maxAdditionalChars = GenerateAHelpMessage("", "", true).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged); SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
} }
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
{
if (e.NewStatus != SessionStatus.InGame)
return;
RaiseNetworkEvent(new BwoinkDiscordRelayUpdated(!string.IsNullOrWhiteSpace(_webhookUrl)), e.Session);
}
private void OnGameRunLevelChanged(GameRunLevelChangedEvent args) private void OnGameRunLevelChanged(GameRunLevelChangedEvent args)
{ {
// Don't make a new embed if we // Don't make a new embed if we

View File

@@ -46,20 +46,20 @@ namespace Content.Shared.Administration
Text = text; Text = text;
} }
} }
}
/// <summary> /// <summary>
/// Sent by the server to notify all clients when the webhook url is sent. /// Sent by the server to notify all clients when the webhook url is sent.
/// The webhook url itself is not and should not be sent. /// The webhook url itself is not and should not be sent.
/// </summary> /// </summary>
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class BwoinkDiscordRelayUpdated : EntityEventArgs public sealed class BwoinkDiscordRelayUpdated : EntityEventArgs
{
public bool DiscordRelayEnabled { get; }
public BwoinkDiscordRelayUpdated(bool enabled)
{ {
public bool DiscordRelayEnabled { get; } DiscordRelayEnabled = enabled;
public BwoinkDiscordRelayUpdated(bool enabled)
{
DiscordRelayEnabled = enabled;
}
} }
} }
} }