mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-08 06:08:20 -05:00
The MuteManager constructor within the Mute plugin has been refactored for better dependency injection. This change simplifies the class construction by directly initializing fields in the constructor parameters. Additionally, several minor code improvements have been made, including spelling corrections and replacing some conditional checks for readability. Other arrays or methods in the plugin are also revised for better maintainability and readability of the code.
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using Data.Models.Client;
|
|
using SharedLibraryCore;
|
|
using SharedLibraryCore.Commands;
|
|
using SharedLibraryCore.Configuration;
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
namespace IW4MAdmin.Plugins.Mute.Commands;
|
|
|
|
public class UnmuteCommand : Command
|
|
{
|
|
private readonly MuteManager _muteManager;
|
|
|
|
public UnmuteCommand(CommandConfiguration config, ITranslationLookup translationLookup, MuteManager muteManager) : base(config,
|
|
translationLookup)
|
|
{
|
|
_muteManager = muteManager;
|
|
Name = "unmute";
|
|
Description = translationLookup["PLUGINS_MUTE_COMMANDS_UNMUTE_DESC"];
|
|
Alias = "um";
|
|
Permission = EFClient.Permission.Moderator;
|
|
RequiresTarget = true;
|
|
SupportedGames = Plugin.SupportedGames;
|
|
Arguments =
|
|
[
|
|
new CommandArgument
|
|
{
|
|
Name = translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
Required = true
|
|
},
|
|
new CommandArgument
|
|
{
|
|
Name = translationLookup["COMMANDS_ARGS_REASON"],
|
|
Required = true
|
|
}
|
|
];
|
|
}
|
|
|
|
public override async Task ExecuteAsync(GameEvent gameEvent)
|
|
{
|
|
if (gameEvent.Origin.ClientId == gameEvent.Target.ClientId)
|
|
{
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_DENY_SELF_TARGET"]);
|
|
return;
|
|
}
|
|
|
|
if (await _muteManager.Unmute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, gameEvent.Data))
|
|
{
|
|
gameEvent.Origin.Tell(_translationLookup["PLUGINS_MUTE_COMMANDS_UNMUTE_UNMUTED"]
|
|
.FormatExt(gameEvent.Target.CleanedName));
|
|
gameEvent.Target.Tell(_translationLookup["PLUGINS_MUTE_COMMANDS_UNMUTE_TARGET_UNMUTED"]
|
|
.FormatExt(gameEvent.Data));
|
|
return;
|
|
}
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["PLUGINS_MUTE_COMMANDS_UNMUTE_NOT_MUTED"]
|
|
.FormatExt(gameEvent.Target.CleanedName));
|
|
}
|
|
}
|