Add LOOC and change OOC color (#5841)
This commit is contained in:
56
Content.Server/Chat/Commands/LOOCCommand.cs
Normal file
56
Content.Server/Chat/Commands/LOOCCommand.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Chat.Commands
|
||||
{
|
||||
[AnyCommand]
|
||||
internal class LOOCCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "looc";
|
||||
public string Description => "Send Local Out Of Character chat messages.";
|
||||
public string Help => "looc <text>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine("This command cannot be run from the server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
||||
return;
|
||||
|
||||
if (args.Length < 1)
|
||||
return;
|
||||
|
||||
var message = string.Join(" ", args).Trim();
|
||||
if (string.IsNullOrEmpty(message))
|
||||
return;
|
||||
|
||||
var chat = IoCManager.Resolve<IChatManager>();
|
||||
var mindComponent = player.ContentData()?.Mind;
|
||||
|
||||
if (mindComponent == null)
|
||||
{
|
||||
shell.WriteError("You don't have a mind!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mindComponent.OwnedEntity == null)
|
||||
{
|
||||
shell.WriteError("You don't have an entity!");
|
||||
return;
|
||||
}
|
||||
|
||||
chat.EntityLOOC(mindComponent.OwnedEntity.Value, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Content.Server/Chat/Commands/SetLOOCCommand.cs
Normal file
44
Content.Server/Chat/Commands/SetLOOCCommand.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Chat.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Server)]
|
||||
public class SetLOOCCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "setlooc";
|
||||
public string Description => Loc.GetString("set-looc-command-description");
|
||||
public string Help => Loc.GetString("set-looc-command-help");
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var cfg = IoCManager.Resolve<IConfigurationManager>();
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("set-looc-command-too-many-arguments-error"));
|
||||
return;
|
||||
}
|
||||
|
||||
var looc = cfg.GetCVar(CCVars.LoocEnabled);
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
looc = !looc;
|
||||
}
|
||||
|
||||
if (args.Length == 1 && !bool.TryParse(args[0], out looc))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("set-looc-command-invalid-argument-error"));
|
||||
return;
|
||||
}
|
||||
|
||||
cfg.SetCVar(CCVars.LoocEnabled, looc);
|
||||
|
||||
shell.WriteLine(Loc.GetString(looc ? "set-looc-command-looc-enabled" : "set-looc-command-looc-disabled"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user