1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

update mute plugin to IPluginV2

This commit is contained in:
RaidMax
2023-02-11 20:48:31 -06:00
parent 44e40aefee
commit dbc059c6a4
8 changed files with 143 additions and 123 deletions

View File

@ -4,13 +4,16 @@ using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
namespace Mute.Commands;
namespace IW4MAdmin.Plugins.Mute.Commands;
public class MuteCommand : Command
{
public MuteCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config,
private readonly MuteManager _muteManager;
public MuteCommand(CommandConfiguration config, ITranslationLookup translationLookup, MuteManager muteManager) : base(config,
translationLookup)
{
_muteManager = muteManager;
Name = "mute";
Description = translationLookup["PLUGINS_MUTE_COMMANDS_MUTE_DESC"];
Alias = "mu";
@ -40,7 +43,7 @@ public class MuteCommand : Command
return;
}
if (await Plugin.MuteManager.Mute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, null, gameEvent.Data))
if (await _muteManager.Mute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, null, gameEvent.Data))
{
gameEvent.Origin.Tell(_translationLookup["PLUGINS_MUTE_COMMANDS_MUTE_MUTED"]
.FormatExt(gameEvent.Target.CleanedName));

View File

@ -5,13 +5,16 @@ using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
namespace Mute.Commands;
namespace IW4MAdmin.Plugins.Mute.Commands;
public class MuteInfoCommand : Command
{
public MuteInfoCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config,
private readonly MuteManager _muteManager;
public MuteInfoCommand(CommandConfiguration config, ITranslationLookup translationLookup, MuteManager muteManager) : base(config,
translationLookup)
{
_muteManager = muteManager;
Name = "muteinfo";
Description = translationLookup["PLUGINS_MUTE_COMMANDS_MUTEINFO_DESC"];
Alias = "mi";
@ -30,7 +33,7 @@ public class MuteInfoCommand : Command
public override async Task ExecuteAsync(GameEvent gameEvent)
{
var currentMuteMeta = await Plugin.MuteManager.GetCurrentMuteState(gameEvent.Target);
var currentMuteMeta = await _muteManager.GetCurrentMuteState(gameEvent.Target);
switch (currentMuteMeta.MuteState)
{
case MuteState.Muted when currentMuteMeta.Expiration is null:

View File

@ -5,15 +5,17 @@ using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
namespace Mute.Commands;
namespace IW4MAdmin.Plugins.Mute.Commands;
public class TempMuteCommand : Command
{
private readonly MuteManager _muteManager;
private const string TempBanRegex = @"([0-9]+\w+)\ (.+)";
public TempMuteCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config,
public TempMuteCommand(CommandConfiguration config, ITranslationLookup translationLookup, MuteManager muteManager) : base(config,
translationLookup)
{
_muteManager = muteManager;
Name = "tempmute";
Description = translationLookup["PLUGINS_MUTE_COMMANDS_TEMPMUTE_DESC"];
Alias = "tm";
@ -54,7 +56,7 @@ public class TempMuteCommand : Command
var expiration = DateTime.UtcNow + match.Groups[1].ToString().ParseTimespan();
var reason = match.Groups[2].ToString();
if (await Plugin.MuteManager.Mute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, expiration, reason))
if (await _muteManager.Mute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, expiration, reason))
{
gameEvent.Origin.Tell(_translationLookup["PLUGINS_MUTE_COMMANDS_TEMPMUTE_TEMPMUTED"]
.FormatExt(gameEvent.Target.CleanedName));

View File

@ -4,13 +4,16 @@ using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
namespace Mute.Commands;
namespace IW4MAdmin.Plugins.Mute.Commands;
public class UnmuteCommand : Command
{
public UnmuteCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config,
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";
@ -40,7 +43,7 @@ public class UnmuteCommand : Command
return;
}
if (await Plugin.MuteManager.Unmute(gameEvent.Owner, gameEvent.Origin, gameEvent.Target, gameEvent.Data))
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));