Alert the user if nobody's around to hear a bwoink (#5147)
This commit is contained in:
@@ -10,6 +10,7 @@ using Robust.Shared.GameObjects.Components;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
@@ -28,7 +29,10 @@ namespace Content.Server.Administration
|
|||||||
|
|
||||||
// TODO: Sanitize text?
|
// TODO: Sanitize text?
|
||||||
// Confirm that this person is actually allowed to send a message here.
|
// Confirm that this person is actually allowed to send a message here.
|
||||||
if ((senderSession.UserId != message.ChannelId) && (_adminManager.GetAdminData(senderSession) == null))
|
var senderPersonalChannel = senderSession.UserId == message.ChannelId;
|
||||||
|
var senderAdmin = _adminManager.GetAdminData(senderSession) != null;
|
||||||
|
var authorized = senderPersonalChannel || senderAdmin;
|
||||||
|
if (!authorized)
|
||||||
{
|
{
|
||||||
// Unauthorized bwoink (log?)
|
// Unauthorized bwoink (log?)
|
||||||
return;
|
return;
|
||||||
@@ -38,16 +42,25 @@ namespace Content.Server.Administration
|
|||||||
|
|
||||||
LogBwoink(msg);
|
LogBwoink(msg);
|
||||||
|
|
||||||
var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient);
|
|
||||||
|
|
||||||
// Admins
|
// Admins
|
||||||
foreach (var channel in targets)
|
var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient).ToList();
|
||||||
RaiseNetworkEvent(msg, channel);
|
|
||||||
|
|
||||||
// And involved player
|
// And involved player
|
||||||
if (_playerManager.TryGetSessionById(message.ChannelId, out var session))
|
if (_playerManager.TryGetSessionById(message.ChannelId, out var session))
|
||||||
if (!targets.Contains(session.ConnectedClient))
|
if (!targets.Contains(session.ConnectedClient))
|
||||||
RaiseNetworkEvent(msg, session.ConnectedClient);
|
targets.Add(session.ConnectedClient);
|
||||||
|
|
||||||
|
foreach (var channel in targets)
|
||||||
|
RaiseNetworkEvent(msg, channel);
|
||||||
|
|
||||||
|
if (targets.Count == 1)
|
||||||
|
{
|
||||||
|
var systemText = senderPersonalChannel ?
|
||||||
|
Loc.GetString("bwoink-system-starmute-message-no-other-users-primary") :
|
||||||
|
Loc.GetString("bwoink-system-starmute-message-no-other-users-secondary");
|
||||||
|
var starMuteMsg = new BwoinkTextMessage(message.ChannelId, SystemUserId, systemText);
|
||||||
|
RaiseNetworkEvent(starMuteMsg, senderSession.ConnectedClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ namespace Content.Shared.Administration
|
|||||||
{
|
{
|
||||||
public abstract class SharedBwoinkSystem : EntitySystem
|
public abstract class SharedBwoinkSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
// System users
|
||||||
|
public static NetUserId SystemUserId { get; } = new NetUserId(Guid.Empty);
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|||||||
4
Resources/Locale/en-US/administration/bwoink.ftl
Normal file
4
Resources/Locale/en-US/administration/bwoink.ftl
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
bwoink-system-starmute-message-no-other-users-primary = *System: Nobody is available to receive your message. Try pinging Game Admins on Discord.
|
||||||
|
|
||||||
|
bwoink-system-starmute-message-no-other-users-secondary = *System: Nobody is available to receive your message.
|
||||||
|
|
||||||
Reference in New Issue
Block a user