2021-07-17 02:37:09 +02:00
|
|
|
|
using Content.Server.Administration;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Shared.Administration;
|
2023-08-30 21:46:11 -07:00
|
|
|
|
using Content.Shared.Mind;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Objectives.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class RemoveObjectiveCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2023-06-18 11:33:19 -07:00
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
|
public string Command => "rmobjective";
|
|
|
|
|
|
public string Description => "Removes an objective from the player's mind.";
|
|
|
|
|
|
public string Help => "rmobjective <username> <index>";
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (args.Length != 2)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Expected exactly 2 arguments.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var mgr = IoCManager.Resolve<IPlayerManager>();
|
2023-08-30 21:46:11 -07:00
|
|
|
|
var minds = _entityManager.System<SharedMindSystem>();
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (!mgr.TryGetSessionByUsername(args[0], out var session))
|
|
|
|
|
|
{
|
|
|
|
|
|
shell.WriteLine("Can't find the playerdata.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-16 07:18:10 +01:00
|
|
|
|
if (!minds.TryGetMind(session, out var mindId, out var mind))
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
|
shell.WriteLine("Can't find the mind.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (int.TryParse(args[1], out var i))
|
|
|
|
|
|
{
|
2023-08-30 21:46:11 -07:00
|
|
|
|
var mindSystem = _entityManager.System<SharedMindSystem>();
|
2023-09-16 07:18:10 +01:00
|
|
|
|
shell.WriteLine(mindSystem.TryRemoveObjective(mindId, mind, i)
|
2023-08-28 16:53:24 -07:00
|
|
|
|
? "Objective successfully removed!"
|
|
|
|
|
|
: "Objective removing failed. Maybe the index is out of bounds? Check lsobjectives!");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
|
shell.WriteLine($"Invalid index {args[1]}!");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|