Un-revert IPlayerManager refactor (#21244)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Motd;
|
||||
@@ -14,10 +13,10 @@ internal sealed class MOTDCommand : LocalizedCommands
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
|
||||
public override string Command => "motd";
|
||||
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = (IPlayerSession?)shell.Player;
|
||||
var player = shell.Player;
|
||||
if (args.Length < 1 || (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd")))
|
||||
shell.ConsoleHost.ExecuteCommand(shell.Player, "get-motd");
|
||||
else
|
||||
@@ -26,7 +25,7 @@ internal sealed class MOTDCommand : LocalizedCommands
|
||||
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
var player = (IPlayerSession?)shell.Player;
|
||||
var player = shell.Player;
|
||||
if (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd"))
|
||||
return CompletionResult.Empty;
|
||||
if (args.Length == 1)
|
||||
|
||||
@@ -2,9 +2,9 @@ using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Motd;
|
||||
|
||||
@@ -41,7 +41,7 @@ public sealed class MOTDSystem : EntitySystem
|
||||
{
|
||||
if (string.IsNullOrEmpty(_messageOfTheDay))
|
||||
return;
|
||||
|
||||
|
||||
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
|
||||
_chatManager.ChatMessageToAll(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, recordReplay: true);
|
||||
}
|
||||
@@ -49,11 +49,11 @@ public sealed class MOTDSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Sends the Message Of The Day, if any, to a specific player.
|
||||
/// </summary>
|
||||
public void TrySendMOTD(IPlayerSession player)
|
||||
public void TrySendMOTD(ICommonSession player)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_messageOfTheDay))
|
||||
return;
|
||||
|
||||
|
||||
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient);
|
||||
}
|
||||
@@ -68,10 +68,10 @@ public sealed class MOTDSystem : EntitySystem
|
||||
{
|
||||
if (string.IsNullOrEmpty(_messageOfTheDay))
|
||||
return;
|
||||
|
||||
|
||||
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
|
||||
shell.WriteLine(wrappedMessage);
|
||||
if (shell.Player is IPlayerSession player)
|
||||
if (shell.Player is { } player)
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public sealed class MOTDSystem : EntitySystem
|
||||
{
|
||||
if (val == _messageOfTheDay)
|
||||
return;
|
||||
|
||||
|
||||
_messageOfTheDay = val;
|
||||
TrySendMOTD();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
@@ -21,18 +20,18 @@ public sealed class SetMotdCommand : LocalizedCommands
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
|
||||
public override string Command => "set-motd";
|
||||
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
string motd = "";
|
||||
var player = (IPlayerSession?)shell.Player;
|
||||
var player = shell.Player;
|
||||
if (args.Length > 0)
|
||||
{
|
||||
motd = string.Join(" ", args).Trim();
|
||||
if (player != null && _chatManager.MessageCharacterLimit(player, motd))
|
||||
return; // check function prints its own error response
|
||||
}
|
||||
|
||||
|
||||
_configurationManager.SetCVar(CCVars.MOTD, motd); // A hook in MOTDSystem broadcasts changes to the MOTD to everyone so we don't need to do it here.
|
||||
if (string.IsNullOrEmpty(motd))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user