Un-revert IPlayerManager refactor (#21244)

This commit is contained in:
Leon Friedrich
2023-10-28 09:59:53 +11:00
committed by GitHub
parent c55e1dcafd
commit e685cb626b
245 changed files with 781 additions and 943 deletions

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Chat.Commands
@@ -15,7 +14,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = (IPlayerSession?) shell.Player;
var player = shell.Player;
if (player == null)
{

View File

@@ -1,6 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -15,7 +14,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -15,7 +14,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Chat.Commands
@@ -14,7 +13,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -15,7 +14,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;

View File

@@ -1,7 +1,6 @@
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -18,7 +17,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteLine(Loc.GetString("shell-cannot-run-command-from-server"));
return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -15,7 +14,7 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;

View File

@@ -10,11 +10,9 @@ using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.Database;
using Content.Shared.Mind;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Replays;
using Robust.Shared.Utility;
@@ -51,8 +49,8 @@ namespace Content.Server.Chat.Managers
private bool _oocEnabled = true;
private bool _adminOocEnabled = true;
public Dictionary<IPlayerSession, int> SenderKeys { get; } = new();
public Dictionary<IPlayerSession, HashSet<NetEntity>> SenderEntities { get; } = new();
public Dictionary<ICommonSession, int> SenderKeys { get; } = new();
public Dictionary<ICommonSession, HashSet<NetEntity>> SenderEntities { get; } = new();
public void Initialize()
{
@@ -79,7 +77,7 @@ namespace Content.Server.Chat.Managers
DispatchServerAnnouncement(Loc.GetString(val ? "chat-manager-admin-ooc-chat-enabled-message" : "chat-manager-admin-ooc-chat-disabled-message"));
}
public void DeleteMessagesBy(IPlayerSession player)
public void DeleteMessagesBy(ICommonSession player)
{
var key = SenderKeys.GetValueOrDefault(player);
var entities = SenderEntities.GetValueOrDefault(player) ?? new HashSet<NetEntity>();
@@ -165,7 +163,7 @@ namespace Content.Server.Chat.Managers
/// <param name="player">The player sending the message.</param>
/// <param name="message">The message.</param>
/// <param name="type">The type of message.</param>
public void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type)
public void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type)
{
// Check if message exceeds the character limit
if (message.Length > MaxMessageLength)
@@ -189,7 +187,7 @@ namespace Content.Server.Chat.Managers
#region Private API
private void SendOOC(IPlayerSession player, string message)
private void SendOOC(ICommonSession player, string message)
{
if (_adminManager.IsAdmin(player))
{
@@ -226,7 +224,7 @@ namespace Content.Server.Chat.Managers
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"OOC from {player:Player}: {message}");
}
private void SendAdminChat(IPlayerSession player, string message)
private void SendAdminChat(ICommonSession player, string message)
{
if (!_adminManager.IsAdmin(player))
{
@@ -326,7 +324,7 @@ namespace Content.Server.Chat.Managers
}
}
public bool MessageCharacterLimit(IPlayerSession? player, string message)
public bool MessageCharacterLimit(ICommonSession? player, string message)
{
var isOverLength = false;

View File

@@ -1,8 +1,6 @@
using Content.Shared.Chat;
using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
namespace Content.Server.Chat.Managers
{
@@ -12,12 +10,12 @@ namespace Content.Server.Chat.Managers
/// Keys identifying messages sent by a specific player, used when sending
/// <see cref="MsgChatMessage"/>
/// </summary>
Dictionary<IPlayerSession, int> SenderKeys { get; }
Dictionary<ICommonSession, int> SenderKeys { get; }
/// <summary>
/// Tracks which entities a player was attached to while sending messages.
/// </summary>
Dictionary<IPlayerSession, HashSet<NetEntity>> SenderEntities { get; }
Dictionary<ICommonSession, HashSet<NetEntity>> SenderEntities { get; }
void Initialize();
@@ -30,7 +28,7 @@ namespace Content.Server.Chat.Managers
void DispatchServerMessage(ICommonSession player, string message, bool suppressLog = false);
void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type);
void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type);
void SendHookOOC(string sender, string message);
void SendAdminAnnouncement(string message);
@@ -47,8 +45,8 @@ namespace Content.Server.Chat.Managers
void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0, int? senderKey = null);
bool MessageCharacterLimit(IPlayerSession player, string message);
bool MessageCharacterLimit(ICommonSession player, string message);
void DeleteMessagesBy(IPlayerSession player);
void DeleteMessagesBy(ICommonSession player);
}
}

View File

@@ -7,7 +7,6 @@ using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Players;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.ActionBlocker;
@@ -18,6 +17,7 @@ using Content.Shared.Ghost;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Mobs.Systems;
using Content.Shared.Players;
using Content.Shared.Radio;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -26,7 +26,6 @@ using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Replays;
@@ -147,7 +146,7 @@ public sealed partial class ChatSystem : SharedChatSystem
InGameICChatType desiredType,
bool hideChat, bool hideLog = false,
IConsoleShell? shell = null,
IPlayerSession? player = null, string? nameOverride = null,
ICommonSession? player = null, string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false)
{
@@ -172,7 +171,7 @@ public sealed partial class ChatSystem : SharedChatSystem
ChatTransmitRange range,
bool hideLog = false,
IConsoleShell? shell = null,
IPlayerSession? player = null,
ICommonSession? player = null,
string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false
@@ -253,7 +252,7 @@ public sealed partial class ChatSystem : SharedChatSystem
InGameOOCChatType type,
bool hideChat,
IConsoleShell? shell = null,
IPlayerSession? player = null
ICommonSession? player = null
)
{
if (!CanSendInGame(message, shell, player))
@@ -547,7 +546,7 @@ public sealed partial class ChatSystem : SharedChatSystem
}
// ReSharper disable once InconsistentNaming
private void SendLOOC(EntityUid source, IPlayerSession player, string message, bool hideChat)
private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat)
{
var name = FormattedMessage.EscapeText(Identity.Name(source, EntityManager));
@@ -571,7 +570,7 @@ public sealed partial class ChatSystem : SharedChatSystem
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"LOOC from {player:Player}: {message}");
}
private void SendDeadChat(EntityUid source, IPlayerSession player, string message, bool hideChat)
private void SendDeadChat(EntityUid source, ICommonSession player, string message, bool hideChat)
{
var clients = GetDeadChatClients();
var playerName = Name(source);
@@ -628,13 +627,13 @@ public sealed partial class ChatSystem : SharedChatSystem
initialResult = MessageRangeCheckResult.Full;
break;
case ChatTransmitRange.GhostRangeLimit:
initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full;
initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full;
break;
case ChatTransmitRange.HideChat:
initialResult = MessageRangeCheckResult.HideChat;
break;
case ChatTransmitRange.NoGhosts:
initialResult = (data.Observer && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full;
initialResult = (data.Observer && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full;
break;
}
var insistHideChat = data.HideChatOverride ?? false;
@@ -666,7 +665,7 @@ public sealed partial class ChatSystem : SharedChatSystem
/// <summary>
/// Returns true if the given player is 'allowed' to send the given message, false otherwise.
/// </summary>
private bool CanSendInGame(string message, IConsoleShell? shell = null, IPlayerSession? player = null)
private bool CanSendInGame(string message, IConsoleShell? shell = null, ICommonSession? player = null)
{
// Non-players don't have to worry about these restrictions.
if (player == null)
@@ -694,7 +693,7 @@ public sealed partial class ChatSystem : SharedChatSystem
{
var newMessage = message.Trim();
newMessage = SanitizeMessageReplaceWords(newMessage);
if (capitalize)
newMessage = SanitizeMessageCapital(newMessage);
if (capitalizeTheWordI)