Files
crystall-punk-14/Content.Server/Administration/Commands/PlayerPanelCommand.cs

57 lines
1.7 KiB
C#
Raw Permalink Normal View History

Implement a playerpanel (#30238) * Basic structure for the player panel ui * Ensure basic functionality Player panel now receives and displays basic info * Make whitelistcommands accept user ids * Make PlayerPanel use GUIDs where possible * Add functionality to most playerpanel buttons * Implement remaining playerpanel features * Localize everything * Finish up * Put command arguments in quotes I am not sure if it's even possible to have something like a space in them considering they are guids and usernames but sure why not * Make playerpanel a verb * Add Logs button to player panel * Change Notesbutton text and make whitelistbutton a confirmtion button * Add freeze button that does not mute the player * Add sharedconnections counter to playerpanel * Make the playetime format clearer * Allow for copying of the a player's username * Do minor cleanup * Rearrange buttons * Fix unfreeze button not updating * Fix wrong localisation text * "Fix" the same role ban counting multiple times The way rolebans are stored is horrible. As such if you ban someone from a departmenrt or something role bans are individually placed for every role. The only way I found to distinguish them is the bantime. This is horrible but I do not want to rewrite how all the bans are stored right now. * Add Delete and Rejuvenate buttons to player panel By popular demand * Marginally improve ui * Add logs * review update * Fix verb * Fix double notes --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-08-09 08:33:25 +03:00
using System.Linq;
using Content.Server.EUI;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Admin)]
public sealed class PlayerPanelCommand : LocalizedCommands
{
[Dependency] private readonly IPlayerLocator _locator = default!;
[Dependency] private readonly EuiManager _euis = default!;
[Dependency] private readonly IPlayerManager _players = default!;
public override string Command => "playerpanel";
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } admin)
{
shell.WriteError(Loc.GetString("cmd-playerpanel-server"));
return;
}
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("cmd-playerpanel-invalid-arguments"));
return;
}
var queriedPlayer = await _locator.LookupIdByNameOrIdAsync(args[0]);
if (queriedPlayer == null)
{
shell.WriteError(Loc.GetString("cmd-playerpanel-invalid-player"));
return;
}
var ui = new PlayerPanelEui(queriedPlayer);
_euis.OpenEui(ui, admin);
ui.SetPlayerState();
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
var options = _players.Sessions.OrderBy(c => c.Name).Select(c => c.Name).ToArray();
return CompletionResult.FromHintOptions(options, LocalizationManager.GetString("cmd-playerpanel-completion"));
}
return CompletionResult.Empty;
}
}