2020-12-03 03:40:47 +01:00
|
|
|
using Content.Server.Players;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2021-06-20 10:09:24 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.GameTicking.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
sealed class RespawnCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
public string Command => "respawn";
|
|
|
|
|
public string Description => "Respawns a player, kicking them back to the lobby.";
|
|
|
|
|
public string Help => "respawn [player]";
|
|
|
|
|
|
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
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
var player = shell.Player as IPlayerSession;
|
2020-12-03 03:40:47 +01:00
|
|
|
if (args.Length > 1)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Must provide <= 1 argument.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var playerMgr = IoCManager.Resolve<IPlayerManager>();
|
2021-06-20 10:09:24 +02:00
|
|
|
var ticker = EntitySystem.Get<GameTicker>();
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
|
|
|
NetUserId userId;
|
|
|
|
|
if (args.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
if (player == null)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("If not a player, an argument must be given.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userId = player.UserId;
|
|
|
|
|
}
|
|
|
|
|
else if (!playerMgr.TryGetUserId(args[0], out userId))
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Unknown player");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!playerMgr.TryGetSessionById(userId, out var targetPlayer))
|
|
|
|
|
{
|
|
|
|
|
if (!playerMgr.TryGetPlayerData(userId, out var data))
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Unknown player");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
data.ContentData()?.WipeMind();
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Player is not currently online, but they will respawn if they come back online");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ticker.Respawn(targetPlayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-01 16:49:43 -08:00
|
|
|
}
|