Kill resolves in vote commands (#37637)
* kill resolves in VoteCommand.cs * consistency and cleanup * final touch
This commit is contained in:
@@ -8,23 +8,20 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Voting;
|
||||
using Robust.Server;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Voting
|
||||
{
|
||||
[AnyCommand]
|
||||
public sealed class CreateVoteCommand : IConsoleCommand
|
||||
public sealed class CreateVoteCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
|
||||
public string Command => "createvote";
|
||||
public string Description => Loc.GetString("cmd-createvote-desc");
|
||||
public string Help => Loc.GetString("cmd-createvote-help");
|
||||
public override string Command => "createvote";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 1 && args[0] != StandardVoteType.Votekick.ToString())
|
||||
{
|
||||
@@ -44,19 +41,17 @@ namespace Content.Server.Voting
|
||||
return;
|
||||
}
|
||||
|
||||
var mgr = IoCManager.Resolve<IVoteManager>();
|
||||
|
||||
if (shell.Player != null && !mgr.CanCallVote(shell.Player, type))
|
||||
if (shell.Player != null && !_voteManager.CanCallVote(shell.Player, type))
|
||||
{
|
||||
_adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} failed to start {type.ToString()} vote");
|
||||
shell.WriteError(Loc.GetString("cmd-createvote-cannot-call-vote-now"));
|
||||
return;
|
||||
}
|
||||
|
||||
mgr.CreateStandardVote(shell.Player, type, args.Skip(1).ToArray());
|
||||
_voteManager.CreateStandardVote(shell.Player, type, args.Skip(1).ToArray());
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
@@ -77,16 +72,12 @@ namespace Content.Server.Voting
|
||||
[Dependency] private readonly VoteWebhooks _voteWebhooks = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
private const int MaxArgCount = 10;
|
||||
|
||||
public override string Command => "customvote";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
_sawmill = Logger.GetSawmill("vote");
|
||||
|
||||
if (args.Length < 3 || args.Length > MaxArgCount)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-need-between-arguments",("lower", 3), ("upper", 10)));
|
||||
@@ -154,13 +145,13 @@ namespace Content.Server.Voting
|
||||
}
|
||||
|
||||
[AnyCommand]
|
||||
public sealed class VoteCommand : IConsoleCommand
|
||||
public sealed class VoteCommand : LocalizedEntityCommands
|
||||
{
|
||||
public string Command => "vote";
|
||||
public string Description => Loc.GetString("cmd-vote-desc");
|
||||
public string Help => Loc.GetString("cmd-vote-help");
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public override string Command => "vote";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (shell.Player == null)
|
||||
{
|
||||
@@ -186,8 +177,7 @@ namespace Content.Server.Voting
|
||||
return;
|
||||
}
|
||||
|
||||
var mgr = IoCManager.Resolve<IVoteManager>();
|
||||
if (!mgr.TryGetVote(voteId, out var vote))
|
||||
if (!_voteManager.TryGetVote(voteId, out var vote))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("cmd-vote-on-execute-error-invalid-vote"));
|
||||
return;
|
||||
@@ -213,17 +203,15 @@ namespace Content.Server.Voting
|
||||
}
|
||||
|
||||
[AnyCommand]
|
||||
public sealed class ListVotesCommand : IConsoleCommand
|
||||
public sealed class ListVotesCommand : LocalizedEntityCommands
|
||||
{
|
||||
public string Command => "listvotes";
|
||||
public string Description => Loc.GetString("cmd-listvotes-desc");
|
||||
public string Help => Loc.GetString("cmd-listvotes-help");
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public override string Command => "listvotes";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var mgr = IoCManager.Resolve<IVoteManager>();
|
||||
|
||||
foreach (var vote in mgr.ActiveVotes)
|
||||
foreach (var vote in _voteManager.ActiveVotes)
|
||||
{
|
||||
shell.WriteLine($"[{vote.Id}] {vote.InitiatorText}: {vote.Title}");
|
||||
}
|
||||
@@ -231,25 +219,22 @@ namespace Content.Server.Voting
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Moderator)]
|
||||
public sealed class CancelVoteCommand : IConsoleCommand
|
||||
public sealed class CancelVoteCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
|
||||
public string Command => "cancelvote";
|
||||
public string Description => Loc.GetString("cmd-cancelvote-desc");
|
||||
public string Help => Loc.GetString("cmd-cancelvote-help");
|
||||
public override string Command => "cancelvote";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var mgr = IoCManager.Resolve<IVoteManager>();
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("cmd-cancelvote-error-missing-vote-id"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var id) || !mgr.TryGetVote(id, out var vote))
|
||||
if (!int.TryParse(args[0], out var id) || !_voteManager.TryGetVote(id, out var vote))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("cmd-cancelvote-error-invalid-vote-id"));
|
||||
return;
|
||||
@@ -262,7 +247,7 @@ namespace Content.Server.Voting
|
||||
vote.Cancel();
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
var mgr = IoCManager.Resolve<IVoteManager>();
|
||||
if (args.Length == 1)
|
||||
|
||||
Reference in New Issue
Block a user