* I'm just a silly goober * requested changes * Update Content.Server/Interaction/TilePryCommand.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration;
|
|
using Content.Server.Maps;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.CCVar;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.GameTicking.Commands
|
|
{
|
|
[AdminCommand(AdminFlags.Round)]
|
|
public sealed class ForceMapCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
|
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
public override string Command => "forcemap";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteLine(Loc.GetString(Loc.GetString($"shell-need-exactly-one-argument")));
|
|
return;
|
|
}
|
|
|
|
var name = args[0];
|
|
|
|
// An empty string clears the forced map
|
|
if (!string.IsNullOrEmpty(name) && !_gameMapManager.CheckMapExists(name))
|
|
{
|
|
shell.WriteLine(Loc.GetString("cmd-forcemap-map-not-found", ("map", name)));
|
|
return;
|
|
}
|
|
|
|
_configurationManager.SetCVar(CCVars.GameMap, name);
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
shell.WriteLine(Loc.GetString("cmd-forcemap-cleared"));
|
|
else
|
|
shell.WriteLine(Loc.GetString("cmd-forcemap-success", ("map", name)));
|
|
}
|
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length == 1)
|
|
{
|
|
var options = _prototypeManager
|
|
.EnumeratePrototypes<GameMapPrototype>()
|
|
.Select(p => new CompletionOption(p.ID, p.MapName))
|
|
.OrderBy(p => p.Value);
|
|
|
|
return CompletionResult.FromHintOptions(options, Loc.GetString($"cmd-forcemap-hint"));
|
|
}
|
|
|
|
return CompletionResult.Empty;
|
|
}
|
|
}
|
|
}
|