mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-07 21:58:06 -05:00
Merge branch 'develop' of github.com:RaidMax/IW4M-Admin into develop
This commit is contained in:
commit
27f5d5f014
@ -193,7 +193,7 @@ NoClipImpl()
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
self Show();
|
||||
|
||||
SetDvar( "sv_cheats", 0 );
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<RootNamespace>IW4MAdmin.Plugins.Mute</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -131,8 +131,11 @@ public class MuteManager
|
||||
{
|
||||
var newPenalty = new EFPenalty
|
||||
{
|
||||
Type = muteState is MuteState.Unmuted ? EFPenalty.PenaltyType.Unmute :
|
||||
dateTime is null ? EFPenalty.PenaltyType.Mute : EFPenalty.PenaltyType.TempMute,
|
||||
Type = muteState is MuteState.Unmuted
|
||||
? EFPenalty.PenaltyType.Unmute
|
||||
: dateTime is null
|
||||
? EFPenalty.PenaltyType.Mute
|
||||
: EFPenalty.PenaltyType.TempMute,
|
||||
Expires = muteState is MuteState.Unmuted ? DateTime.UtcNow : dateTime,
|
||||
Offender = target,
|
||||
Offense = reason,
|
||||
@ -148,10 +151,9 @@ public class MuteManager
|
||||
{
|
||||
await using var context = _databaseContextFactory.CreateContext();
|
||||
var mutePenalties = await context.Penalties
|
||||
.Where(penalty => penalty.OffenderId == client.ClientId &&
|
||||
(penalty.Type == EFPenalty.PenaltyType.Mute ||
|
||||
penalty.Type == EFPenalty.PenaltyType.TempMute) &&
|
||||
(penalty.Expires == null || penalty.Expires > DateTime.UtcNow))
|
||||
.Where(penalty => penalty.OffenderId == client.ClientId)
|
||||
.Where(penalty => penalty.Type == EFPenalty.PenaltyType.Mute || penalty.Type == EFPenalty.PenaltyType.TempMute)
|
||||
.Where(penalty => penalty.Expires == null || penalty.Expires > DateTime.UtcNow)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var mutePenalty in mutePenalties)
|
||||
@ -169,19 +171,20 @@ public class MuteManager
|
||||
switch (muteStateMeta.MuteState)
|
||||
{
|
||||
case MuteState.Muted:
|
||||
await server.ExecuteCommandAsync($"muteClient {client.ClientNumber}");
|
||||
var muteCommand = string.Format(server.RconParser.Configuration.CommandPrefixes.Mute, client.ClientNumber);
|
||||
await server.ExecuteCommandAsync(muteCommand);
|
||||
muteStateMeta.CommandExecuted = true;
|
||||
break;
|
||||
case MuteState.Unmuted:
|
||||
await server.ExecuteCommandAsync($"unmute {client.ClientNumber}");
|
||||
var unMuteCommand = string.Format(server.RconParser.Configuration.CommandPrefixes.Unmute, client.ClientNumber);
|
||||
await server.ExecuteCommandAsync(unMuteCommand);
|
||||
muteStateMeta.CommandExecuted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<MuteState?> ReadPersistentDataV1(EFClient client) => TryParse<MuteState>(
|
||||
(await _metaService.GetPersistentMeta(Plugin.MuteKey, client.ClientId))?.Value,
|
||||
out var muteState)
|
||||
(await _metaService.GetPersistentMeta(Plugin.MuteKey, client.ClientId))?.Value, out var muteState)
|
||||
? muteState
|
||||
: null;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class Plugin : IPluginV2
|
||||
|
||||
public const string MuteKey = "IW4MMute";
|
||||
public static IManager Manager { get; private set; } = null!;
|
||||
public static readonly Server.Game[] SupportedGames = {Server.Game.IW4};
|
||||
public static Server.Game[] SupportedGames { get; private set; } = Array.Empty<Server.Game>();
|
||||
private static readonly string[] DisabledCommands = {nameof(PrivateMessageAdminsCommand), "PrivateMessageCommand"};
|
||||
private readonly IInteractionRegistration _interactionRegistration;
|
||||
private readonly IRemoteCommandService _remoteCommandService;
|
||||
@ -37,9 +37,11 @@ public class Plugin : IPluginV2
|
||||
|
||||
IManagementEventSubscriptions.Load += OnLoad;
|
||||
IManagementEventSubscriptions.Unload += OnUnload;
|
||||
|
||||
IManagementEventSubscriptions.ClientStateInitialized += OnClientStateInitialized;
|
||||
|
||||
IGameServerEventSubscriptions.ClientDataUpdated += OnClientDataUpdated;
|
||||
IGameServerEventSubscriptions.MonitoringStarted += OnServerMonitoredStarted;
|
||||
|
||||
IGameEventSubscriptions.ClientMessaged += OnClientMessaged;
|
||||
}
|
||||
|
||||
@ -319,4 +321,29 @@ public class Plugin : IPluginV2
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Task OnServerMonitoredStarted(MonitorStartEvent serverEvent, CancellationToken token)
|
||||
{
|
||||
var game = (Server.Game)serverEvent.Server.GameCode;
|
||||
|
||||
lock (SupportedGames)
|
||||
{
|
||||
if (SupportedGames.Contains(game))
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var server = Manager.GetServers().FirstOrDefault(x => x == serverEvent.Server);
|
||||
var commandIsEmpty = string.IsNullOrWhiteSpace(server?.RconParser.Configuration.CommandPrefixes.Mute);
|
||||
|
||||
if (commandIsEmpty)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
SupportedGames = SupportedGames.Append(game).ToArray();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ var plugin = {
|
||||
rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.Mute = 'muteClient {0}';
|
||||
rconParser.Configuration.CommandPrefixes.Unmute = 'unmute {0}';
|
||||
|
||||
rconParser.Configuration.DefaultRConPort = 28960;
|
||||
rconParser.Configuration.DefaultInstallationDirectoryHint = 'HKEY_CURRENT_USER\\Software\\Classes\\iw4x\\shell\\open\\command';
|
||||
|
@ -20,6 +20,8 @@ var plugin = {
|
||||
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.TempBan = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.RConResponse = '\xff\xff\xff\xffprint\n';
|
||||
rconParser.Configuration.CommandPrefixes.Mute = 'muteClient {0}';
|
||||
rconParser.Configuration.CommandPrefixes.Unmute = 'unmuteClient {0}';
|
||||
rconParser.Configuration.Dvar.Pattern = '^ *\\"(.+)\\" is: \\"(.+)?\\" default: \\"(.+)?\\"\\n?(?:latched: \\"(.+)?\\"\\n?)?(.*)$';
|
||||
rconParser.Configuration.Status.Pattern = '^ *([0-9]+) +-?([0-9]+) +(Yes|No) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +(\\d+\\.\\d+\\.\\d+.\\d+\\:-*\\d{1,5}|0+.0+:-*\\d{1,5}|loopback|unknown|bot) +(-*[0-9]+) *$';
|
||||
rconParser.Configuration.StatusHeader.Pattern = 'num +score +bot +ping +guid +name +address +qport *';
|
||||
|
Loading…
x
Reference in New Issue
Block a user