1
0

ToggleDisallowLateJoinCommand.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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.GameTicking.Commands
  7. {
  8. [AdminCommand(AdminFlags.Round)]
  9. sealed class ToggleDisallowLateJoinCommand : IConsoleCommand
  10. {
  11. public string Command => "toggledisallowlatejoin";
  12. public string Description => "Allows or disallows latejoining during mid-game.";
  13. public string Help => $"Usage: {Command} <disallow>";
  14. public void Execute(IConsoleShell shell, string argStr, string[] args)
  15. {
  16. if (args.Length != 1)
  17. {
  18. shell.WriteLine("Need exactly one argument.");
  19. return;
  20. }
  21. var cfgMan = IoCManager.Resolve<IConfigurationManager>();
  22. if (bool.TryParse(args[0], out var result))
  23. {
  24. cfgMan.SetCVar(CCVars.GameDisallowLateJoins, bool.Parse(args[0]));
  25. shell.WriteLine(result ? "Late joining has been disabled." : "Late joining has been enabled.");
  26. }
  27. else
  28. {
  29. shell.WriteLine("Invalid argument.");
  30. }
  31. }
  32. }
  33. }