1
0

SetOOCCommand.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Content.Server.Administration;
  2. using Content.Shared.Administration;
  3. using Content.Shared.CCVar;
  4. using Robust.Shared.Configuration;
  5. using Robust.Shared.Console;
  6. namespace Content.Server.Chat.Commands;
  7. [AdminCommand(AdminFlags.Admin)]
  8. public sealed class SetOOCCommand : IConsoleCommand
  9. {
  10. public string Command => "setooc";
  11. public string Description => Loc.GetString("set-ooc-command-description");
  12. public string Help => Loc.GetString("set-ooc-command-help");
  13. public void Execute(IConsoleShell shell, string argStr, string[] args)
  14. {
  15. var cfg = IoCManager.Resolve<IConfigurationManager>();
  16. if (args.Length > 1)
  17. {
  18. shell.WriteError(Loc.GetString("set-ooc-command-too-many-arguments-error"));
  19. return;
  20. }
  21. var ooc = cfg.GetCVar(CCVars.OocEnabled);
  22. if (args.Length == 0)
  23. {
  24. ooc = !ooc;
  25. }
  26. if (args.Length == 1 && !bool.TryParse(args[0], out ooc))
  27. {
  28. shell.WriteError(Loc.GetString("set-ooc-command-invalid-argument-error"));
  29. return;
  30. }
  31. cfg.SetCVar(CCVars.OocEnabled, ooc);
  32. shell.WriteLine(Loc.GetString(ooc ? "set-ooc-command-ooc-enabled" : "set-ooc-command-ooc-disabled"));
  33. }
  34. }