Add admin alerts (#13589)
This commit is contained in:
@@ -496,6 +496,7 @@ public sealed class ChatUIController : UIController
|
|||||||
if (_admin.HasFlag(AdminFlags.Admin))
|
if (_admin.HasFlag(AdminFlags.Admin))
|
||||||
{
|
{
|
||||||
FilterableChannels |= ChatChannel.Admin;
|
FilterableChannels |= ChatChannel.Admin;
|
||||||
|
FilterableChannels |= ChatChannel.AdminAlert;
|
||||||
FilterableChannels |= ChatChannel.AdminChat;
|
FilterableChannels |= ChatChannel.AdminChat;
|
||||||
CanSendChannels |= ChatSelectChannel.Admin;
|
CanSendChannels |= ChatSelectChannel.Admin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public sealed partial class ChannelFilterPopup : Popup
|
|||||||
ChatChannel.OOC,
|
ChatChannel.OOC,
|
||||||
ChatChannel.Dead,
|
ChatChannel.Dead,
|
||||||
ChatChannel.Admin,
|
ChatChannel.Admin,
|
||||||
|
ChatChannel.AdminAlert,
|
||||||
ChatChannel.AdminChat,
|
ChatChannel.AdminChat,
|
||||||
ChatChannel.Server
|
ChatChannel.Server
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.Administration.Systems;
|
||||||
using Content.Server.AME.Components;
|
using Content.Server.AME.Components;
|
||||||
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.Explosion.EntitySystems;
|
using Content.Server.Explosion.EntitySystems;
|
||||||
using Content.Server.NodeContainer.NodeGroups;
|
using Content.Server.NodeContainer.NodeGroups;
|
||||||
using Content.Server.NodeContainer.Nodes;
|
using Content.Server.NodeContainer.Nodes;
|
||||||
@@ -27,6 +29,8 @@ namespace Content.Server.AME
|
|||||||
|
|
||||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||||
|
|
||||||
|
[Dependency] private readonly IChatManager _chat = default!;
|
||||||
|
|
||||||
public AMEControllerComponent? MasterController => _masterController;
|
public AMEControllerComponent? MasterController => _masterController;
|
||||||
|
|
||||||
private readonly List<AMEShieldComponent> _cores = new();
|
private readonly List<AMEShieldComponent> _cores = new();
|
||||||
@@ -133,10 +137,21 @@ namespace Content.Server.AME
|
|||||||
if (instability != 0)
|
if (instability != 0)
|
||||||
{
|
{
|
||||||
overloading = true;
|
overloading = true;
|
||||||
|
var integrityCheck = 100;
|
||||||
foreach(AMEShieldComponent core in _cores)
|
foreach(AMEShieldComponent core in _cores)
|
||||||
{
|
{
|
||||||
|
var oldIntegrity = core.CoreIntegrity;
|
||||||
core.CoreIntegrity -= instability;
|
core.CoreIntegrity -= instability;
|
||||||
|
|
||||||
|
if (oldIntegrity > 95
|
||||||
|
&& core.CoreIntegrity <= 95
|
||||||
|
&& core.CoreIntegrity < integrityCheck)
|
||||||
|
integrityCheck = core.CoreIntegrity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Admin alert
|
||||||
|
if (integrityCheck != 100 && _masterController != null)
|
||||||
|
_chat.SendAdminAlert($"AME overloading: {_entMan.ToPrettyString(_masterController.Owner)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Note the float conversions. The maths will completely fail if not done using floats.
|
// Note the float conversions. The maths will completely fail if not done using floats.
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Server.Administration.Systems;
|
||||||
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.NodeContainer;
|
using Content.Server.NodeContainer;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
@@ -20,6 +22,7 @@ namespace Content.Server.AME.Components
|
|||||||
[Dependency] private readonly IEntityManager _entities = default!;
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
[Dependency] private readonly IChatManager _chat = default!;
|
||||||
|
|
||||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key);
|
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key);
|
||||||
private bool _injecting;
|
private bool _injecting;
|
||||||
@@ -183,6 +186,10 @@ namespace Content.Server.AME.Components
|
|||||||
|
|
||||||
if (msg.Button == UiButton.ToggleInjection)
|
if (msg.Button == UiButton.ToggleInjection)
|
||||||
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to {humanReadableState}");
|
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to {humanReadableState}");
|
||||||
|
|
||||||
|
// Admin alert
|
||||||
|
if (GetCoreCount() * 2 == InjectionAmount - 2 && msg.Button == UiButton.IncreaseFuel)
|
||||||
|
_chat.SendAdminAlert(player, $"increased AME over safe limit to {InjectionAmount}", mindComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetAMENodeGroup()?.UpdateCoreVisuals();
|
GetAMENodeGroup()?.UpdateCoreVisuals();
|
||||||
|
|||||||
@@ -83,6 +83,15 @@ namespace Content.Server.Administration.Systems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerInfo? GetCachedPlayerInfo(NetUserId? netUserId)
|
||||||
|
{
|
||||||
|
if (netUserId == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
_playerList.TryGetValue(netUserId.Value, out var value);
|
||||||
|
return value ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnIdentityChanged(IdentityChangedEvent ev)
|
private void OnIdentityChanged(IdentityChangedEvent ev)
|
||||||
{
|
{
|
||||||
if (!TryComp<ActorComponent>(ev.CharacterEntity, out var actor))
|
if (!TryComp<ActorComponent>(ev.CharacterEntity, out var actor))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
|
using Content.Server.Administration.Systems;
|
||||||
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.MoMMI;
|
using Content.Server.MoMMI;
|
||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
@@ -39,6 +41,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
[Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
|
[Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum length a player-sent message can be sent
|
/// The maximum length a player-sent message can be sent
|
||||||
@@ -103,6 +106,31 @@ namespace Content.Server.Chat.Managers
|
|||||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Admin announcement: {message}");
|
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Admin announcement: {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendAdminAlert(string message)
|
||||||
|
{
|
||||||
|
var clients = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient);
|
||||||
|
|
||||||
|
var wrappedMessage = Loc.GetString("chat-manager-send-admin-announcement-wrap-message",
|
||||||
|
("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")), ("message", FormattedMessage.EscapeText(message)));
|
||||||
|
|
||||||
|
ChatMessageToMany(ChatChannel.AdminAlert, message, wrappedMessage, default, false, true, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendAdminAlert(EntityUid player, string message, MindComponent? mindComponent = null)
|
||||||
|
{
|
||||||
|
if(mindComponent == null && !_entityManager.TryGetComponent(player, out mindComponent))
|
||||||
|
{
|
||||||
|
SendAdminAlert(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var adminSystem = _entityManager.System<AdminSystem>();
|
||||||
|
var antag = mindComponent.Mind!.UserId != null
|
||||||
|
&& (adminSystem.GetCachedPlayerInfo(mindComponent.Mind!.UserId.Value)?.Antag ?? false);
|
||||||
|
|
||||||
|
SendAdminAlert($"{mindComponent.Mind!.Session?.Name}{(antag ? " (ANTAG)" : "")} {message}");
|
||||||
|
}
|
||||||
|
|
||||||
public void SendHookOOC(string sender, string message)
|
public void SendHookOOC(string sender, string message)
|
||||||
{
|
{
|
||||||
if (!_oocEnabled && _configurationManager.GetCVar(CCVars.DisablingOOCDisablesRelay))
|
if (!_oocEnabled && _configurationManager.GetCVar(CCVars.DisablingOOCDisablesRelay))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Server.Mind.Components;
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
@@ -22,6 +23,8 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
void SendHookOOC(string sender, string message);
|
void SendHookOOC(string sender, string message);
|
||||||
void SendAdminAnnouncement(string message);
|
void SendAdminAnnouncement(string message);
|
||||||
|
void SendAdminAlert(string message);
|
||||||
|
void SendAdminAlert(EntityUid player, string message, MindComponent? mindComponent = null);
|
||||||
|
|
||||||
void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
|
void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
|
||||||
INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0);
|
INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0);
|
||||||
|
|||||||
@@ -64,15 +64,20 @@ namespace Content.Shared.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Admin = 1 << 10,
|
Admin = 1 << 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Admin alerts, messages likely of elevated importance to admins
|
||||||
|
/// </summary>
|
||||||
|
AdminAlert = 1 << 11,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Admin chat
|
/// Admin chat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AdminChat = 1 << 11,
|
AdminChat = 1 << 12,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unspecified.
|
/// Unspecified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Unspecified = 1 << 12,
|
Unspecified = 1 << 13,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Channels considered to be IC.
|
/// Channels considered to be IC.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public static class ChatChannelExtensions
|
|||||||
ChatChannel.OOC => Color.LightSkyBlue,
|
ChatChannel.OOC => Color.LightSkyBlue,
|
||||||
ChatChannel.Dead => Color.MediumPurple,
|
ChatChannel.Dead => Color.MediumPurple,
|
||||||
ChatChannel.Admin => Color.Red,
|
ChatChannel.Admin => Color.Red,
|
||||||
|
ChatChannel.AdminAlert => Color.Red,
|
||||||
ChatChannel.AdminChat => Color.HotPink,
|
ChatChannel.AdminChat => Color.HotPink,
|
||||||
ChatChannel.Whisper => Color.DarkGray,
|
ChatChannel.Whisper => Color.DarkGray,
|
||||||
_ => Color.LightGray
|
_ => Color.LightGray
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ hud-chatbox-select-channel-Visual = Actions
|
|||||||
hud-chatbox-select-channel-Radio = Radio
|
hud-chatbox-select-channel-Radio = Radio
|
||||||
|
|
||||||
hud-chatbox-channel-Admin = Admin Misc
|
hud-chatbox-channel-Admin = Admin Misc
|
||||||
|
hud-chatbox-channel-AdminAlert = Admin Alert
|
||||||
hud-chatbox-channel-AdminChat = Admin Chat
|
hud-chatbox-channel-AdminChat = Admin Chat
|
||||||
hud-chatbox-channel-Dead = Dead
|
hud-chatbox-channel-Dead = Dead
|
||||||
hud-chatbox-channel-Emotes = Emotes
|
hud-chatbox-channel-Emotes = Emotes
|
||||||
|
|||||||
Reference in New Issue
Block a user