Command resolves. (#38519)
* banlist-command * open-admin-notes-command * stealthmin-command * set-alert-level-command * remove unused usings * whitelist commands
This commit is contained in:
@@ -14,9 +14,10 @@ namespace Content.Server.Administration.Commands;
|
|||||||
[AdminCommand(AdminFlags.Ban)]
|
[AdminCommand(AdminFlags.Ban)]
|
||||||
public sealed class BanListCommand : LocalizedCommands
|
public sealed class BanListCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||||
[Dependency] private readonly EuiManager _eui = default!;
|
[Dependency] private readonly EuiManager _eui = default!;
|
||||||
[Dependency] private readonly IPlayerLocator _locator = default!;
|
|
||||||
|
|
||||||
public override string Command => "banlist";
|
public override string Command => "banlist";
|
||||||
|
|
||||||
@@ -66,8 +67,7 @@ public sealed class BanListCommand : LocalizedCommands
|
|||||||
if (args.Length != 1)
|
if (args.Length != 1)
|
||||||
return CompletionResult.Empty;
|
return CompletionResult.Empty;
|
||||||
|
|
||||||
var playerMgr = IoCManager.Resolve<IPlayerManager>();
|
var options = _playerManager.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
|
||||||
var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
|
|
||||||
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint"));
|
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ namespace Content.Server.Administration.Commands;
|
|||||||
[AdminCommand(AdminFlags.ViewNotes)]
|
[AdminCommand(AdminFlags.ViewNotes)]
|
||||||
public sealed class OpenAdminNotesCommand : LocalizedCommands
|
public sealed class OpenAdminNotesCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IAdminNotesManager _adminNotes = default!;
|
||||||
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
||||||
|
|
||||||
public const string CommandName = "adminnotes";
|
public const string CommandName = "adminnotes";
|
||||||
|
|
||||||
public override string Command => CommandName;
|
public override string Command => CommandName;
|
||||||
@@ -28,8 +31,7 @@ public sealed class OpenAdminNotesCommand : LocalizedCommands
|
|||||||
case 1 when Guid.TryParse(args[0], out notedPlayer):
|
case 1 when Guid.TryParse(args[0], out notedPlayer):
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
var locator = IoCManager.Resolve<IPlayerLocator>();
|
var dbGuid = await _locator.LookupIdByNameAsync(args[0]);
|
||||||
var dbGuid = await locator.LookupIdByNameAsync(args[0]);
|
|
||||||
|
|
||||||
if (dbGuid == null)
|
if (dbGuid == null)
|
||||||
{
|
{
|
||||||
@@ -44,7 +46,7 @@ public sealed class OpenAdminNotesCommand : LocalizedCommands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await IoCManager.Resolve<IAdminNotesManager>().OpenEui(player, notedPlayer);
|
await _adminNotes.OpenEui(player, notedPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands;
|
namespace Content.Server.Administration.Commands;
|
||||||
|
|
||||||
[UsedImplicitly]
|
|
||||||
[AdminCommand(AdminFlags.Stealth)]
|
[AdminCommand(AdminFlags.Stealth)]
|
||||||
public sealed class StealthminCommand : LocalizedCommands
|
public sealed class StealthminCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
|
|
||||||
public override string Command => "stealthmin";
|
public override string Command => "stealthmin";
|
||||||
|
|
||||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
@@ -17,23 +17,17 @@ public sealed class StealthminCommand : LocalizedCommands
|
|||||||
var player = shell.Player;
|
var player = shell.Player;
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("cmd-stealthmin-no-console"));
|
shell.WriteLine(Loc.GetString("shell-cannot-run-command-from-server"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mgr = IoCManager.Resolve<IAdminManager>();
|
var adminData = _adminManager.GetAdminData(player);
|
||||||
|
|
||||||
var adminData = mgr.GetAdminData(player);
|
|
||||||
|
|
||||||
DebugTools.AssertNotNull(adminData);
|
DebugTools.AssertNotNull(adminData);
|
||||||
|
|
||||||
if (!adminData!.Stealth)
|
if (!adminData!.Stealth)
|
||||||
{
|
_adminManager.Stealth(player);
|
||||||
mgr.Stealth(player);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
_adminManager.UnStealth(player);
|
||||||
mgr.UnStealth(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,15 @@
|
|||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
namespace Content.Server.AlertLevel.Commands
|
namespace Content.Server.AlertLevel.Commands
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
|
||||||
[AdminCommand(AdminFlags.Fun)]
|
[AdminCommand(AdminFlags.Fun)]
|
||||||
public sealed class SetAlertLevelCommand : LocalizedCommands
|
public sealed class SetAlertLevelCommand : LocalizedEntityCommands
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystems = default!;
|
[Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!;
|
||||||
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||||
|
|
||||||
public override string Command => "setalertlevel";
|
public override string Command => "setalertlevel";
|
||||||
|
|
||||||
@@ -21,12 +20,10 @@ namespace Content.Server.AlertLevel.Commands
|
|||||||
var player = shell.Player;
|
var player = shell.Player;
|
||||||
if (player?.AttachedEntity != null)
|
if (player?.AttachedEntity != null)
|
||||||
{
|
{
|
||||||
var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
|
var stationUid = _stationSystem.GetOwningStation(player.AttachedEntity.Value);
|
||||||
if (stationUid != null)
|
if (stationUid != null)
|
||||||
{
|
|
||||||
levelNames = GetStationLevelNames(stationUid.Value);
|
levelNames = GetStationLevelNames(stationUid.Value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return args.Length switch
|
return args.Length switch
|
||||||
{
|
{
|
||||||
@@ -60,7 +57,7 @@ namespace Content.Server.AlertLevel.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
|
var stationUid = _stationSystem.GetOwningStation(player.AttachedEntity.Value);
|
||||||
if (stationUid == null)
|
if (stationUid == null)
|
||||||
{
|
{
|
||||||
shell.WriteLine(LocalizationManager.GetString("cmd-setalertlevel-invalid-grid"));
|
shell.WriteLine(LocalizationManager.GetString("cmd-setalertlevel-invalid-grid"));
|
||||||
@@ -75,13 +72,12 @@ namespace Content.Server.AlertLevel.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_entitySystems.GetEntitySystem<AlertLevelSystem>().SetLevel(stationUid.Value, level, true, true, true, locked);
|
_alertLevelSystem.SetLevel(stationUid.Value, level, true, true, true, locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] GetStationLevelNames(EntityUid station)
|
private string[] GetStationLevelNames(EntityUid station)
|
||||||
{
|
{
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
if (!EntityManager.TryGetComponent<AlertLevelComponent>(station, out var alertLevelComp))
|
||||||
if (!entityManager.TryGetComponent<AlertLevelComponent>(station, out var alertLevelComp))
|
|
||||||
return new string[]{};
|
return new string[]{};
|
||||||
|
|
||||||
if (alertLevelComp.AlertLevels == null)
|
if (alertLevelComp.AlertLevels == null)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Atmos.Piping.Components;
|
using Content.Server.Atmos.Piping.Components;
|
||||||
using Content.Server.Atmos.Piping.EntitySystems;
|
using Content.Server.Atmos.Piping.EntitySystems;
|
||||||
using Content.Server.NodeContainer;
|
|
||||||
using Content.Server.NodeContainer.NodeGroups;
|
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.NodeContainer;
|
using Content.Shared.NodeContainer;
|
||||||
using Content.Shared.NodeContainer.NodeGroups;
|
using Content.Shared.NodeContainer.NodeGroups;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Content.Server.Whitelist;
|
|||||||
[AdminCommand(AdminFlags.Ban)]
|
[AdminCommand(AdminFlags.Ban)]
|
||||||
public sealed class AddWhitelistCommand : LocalizedCommands
|
public sealed class AddWhitelistCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
||||||
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||||
public override string Command => "whitelistadd";
|
public override string Command => "whitelistadd";
|
||||||
|
|
||||||
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
@@ -23,23 +25,20 @@ public sealed class AddWhitelistCommand : LocalizedCommands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = IoCManager.Resolve<IServerDbManager>();
|
|
||||||
var loc = IoCManager.Resolve<IPlayerLocator>();
|
|
||||||
|
|
||||||
var name = string.Join(' ', args).Trim();
|
var name = string.Join(' ', args).Trim();
|
||||||
var data = await loc.LookupIdByNameOrIdAsync(name);
|
var data = await _locator.LookupIdByNameOrIdAsync(name);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
var guid = data.UserId;
|
var guid = data.UserId;
|
||||||
var isWhitelisted = await db.GetWhitelistStatusAsync(guid);
|
var isWhitelisted = await _dbManager.GetWhitelistStatusAsync(guid);
|
||||||
if (isWhitelisted)
|
if (isWhitelisted)
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("cmd-whitelistadd-existing", ("username", data.Username)));
|
shell.WriteLine(Loc.GetString("cmd-whitelistadd-existing", ("username", data.Username)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.AddToWhitelistAsync(guid);
|
await _dbManager.AddToWhitelistAsync(guid);
|
||||||
shell.WriteLine(Loc.GetString("cmd-whitelistadd-added", ("username", data.Username)));
|
shell.WriteLine(Loc.GetString("cmd-whitelistadd-added", ("username", data.Username)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -61,6 +60,9 @@ public sealed class AddWhitelistCommand : LocalizedCommands
|
|||||||
[AdminCommand(AdminFlags.Ban)]
|
[AdminCommand(AdminFlags.Ban)]
|
||||||
public sealed class RemoveWhitelistCommand : LocalizedCommands
|
public sealed class RemoveWhitelistCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
||||||
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||||
|
|
||||||
public override string Command => "whitelistremove";
|
public override string Command => "whitelistremove";
|
||||||
|
|
||||||
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
@@ -72,23 +74,20 @@ public sealed class RemoveWhitelistCommand : LocalizedCommands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = IoCManager.Resolve<IServerDbManager>();
|
|
||||||
var loc = IoCManager.Resolve<IPlayerLocator>();
|
|
||||||
|
|
||||||
var name = string.Join(' ', args).Trim();
|
var name = string.Join(' ', args).Trim();
|
||||||
var data = await loc.LookupIdByNameOrIdAsync(name);
|
var data = await _locator.LookupIdByNameOrIdAsync(name);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
var guid = data.UserId;
|
var guid = data.UserId;
|
||||||
var isWhitelisted = await db.GetWhitelistStatusAsync(guid);
|
var isWhitelisted = await _dbManager.GetWhitelistStatusAsync(guid);
|
||||||
if (!isWhitelisted)
|
if (!isWhitelisted)
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("cmd-whitelistremove-existing", ("username", data.Username)));
|
shell.WriteLine(Loc.GetString("cmd-whitelistremove-existing", ("username", data.Username)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.RemoveFromWhitelistAsync(guid);
|
await _dbManager.RemoveFromWhitelistAsync(guid);
|
||||||
shell.WriteLine(Loc.GetString("cmd-whitelistremove-removed", ("username", data.Username)));
|
shell.WriteLine(Loc.GetString("cmd-whitelistremove-removed", ("username", data.Username)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -110,6 +109,11 @@ public sealed class RemoveWhitelistCommand : LocalizedCommands
|
|||||||
[AdminCommand(AdminFlags.Ban)]
|
[AdminCommand(AdminFlags.Ban)]
|
||||||
public sealed class KickNonWhitelistedCommand : LocalizedCommands
|
public sealed class KickNonWhitelistedCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||||
|
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||||
|
|
||||||
public override string Command => "kicknonwhitelisted";
|
public override string Command => "kicknonwhitelisted";
|
||||||
|
|
||||||
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
@@ -121,24 +125,16 @@ public sealed class KickNonWhitelistedCommand : LocalizedCommands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg = IoCManager.Resolve<IConfigurationManager>();
|
if (!_configManager.GetCVar(CCVars.WhitelistEnabled))
|
||||||
|
|
||||||
if (!cfg.GetCVar(CCVars.WhitelistEnabled))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var player = IoCManager.Resolve<IPlayerManager>();
|
foreach (var session in _playerManager.NetworkedSessions)
|
||||||
var db = IoCManager.Resolve<IServerDbManager>();
|
|
||||||
var net = IoCManager.Resolve<IServerNetManager>();
|
|
||||||
|
|
||||||
foreach (var session in player.NetworkedSessions)
|
|
||||||
{
|
{
|
||||||
if (await db.GetAdminDataForAsync(session.UserId) is not null)
|
if (await _dbManager.GetAdminDataForAsync(session.UserId) is not null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!await db.GetWhitelistStatusAsync(session.UserId))
|
if (!await _dbManager.GetWhitelistStatusAsync(session.UserId))
|
||||||
{
|
_netManager.DisconnectChannel(session.Channel, Loc.GetString("whitelist-not-whitelisted"));
|
||||||
net.DisconnectChannel(session.Channel, Loc.GetString("whitelist-not-whitelisted"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
cmd-stealthmin-desc = Toggle whether others can see you in adminwho.
|
cmd-stealthmin-desc = Toggle whether others can see you in adminwho.
|
||||||
cmd-stealthmin-help = Usage: stealthmin\nUse stealthmin to toggle whether you appear in the output of the adminwho command.
|
cmd-stealthmin-help = Usage: stealthmin\nUse stealthmin to toggle whether you appear in the output of the adminwho command.
|
||||||
cmd-stealthmin-no-console = You cannot use this command from the server console.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user