Fixed merge issues

This commit is contained in:
Valentin Barat
2024-02-12 11:46:16 +01:00
parent 9cecc19060
commit 778c93b170

View File

@@ -527,15 +527,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
{ {
if (caller!.CanTarget(player)) if (caller!.CanTarget(player))
{ {
Gag(caller, player, time, reason, _muteManager); Gag(caller, player, time, reason, _muteManager, playerPenaltyManager);
} }
}); });
} }
internal void Gag(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null) internal void Gag(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null, PlayerPenaltyManager playerPenaltyManager = null)
{ {
reason ??= "Unknown"; reason ??= "Unknown";
muteManager ??= new(_database); muteManager ??= new(_database);
playerPenaltyManager ??= new PlayerPenaltyManager();
PlayerInfo playerInfo = new PlayerInfo PlayerInfo playerInfo = new PlayerInfo
{ {
@@ -544,80 +545,79 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
IpAddress = player?.IpAddress?.Split(":")[0] IpAddress = player?.IpAddress?.Split(":")[0]
}; };
PlayerInfo adminInfo = new PlayerInfo PlayerInfo adminInfo = new PlayerInfo
{
SteamId = caller?.SteamID.ToString(),
Name = caller?.PlayerName,
IpAddress = caller?.IpAddress?.Split(":")[0]
};
Task.Run(async () =>
{
await muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
});
if (TagsDetected)
Server.ExecuteCommand($"css_tag_mute {player!.SteamID}");
playerPenaltyManager.AddPenalty(player!.Slot, PenaltyType.Gag, DateTime.Now.AddMinutes(time), time);
if (time == 0)
{
if (!player!.IsBot && !player.IsHLTV)
{
using (new WithTemporaryCulture(player.GetLanguage()))
{ {
SteamId = caller?.SteamID.ToString(), player.PrintToCenter(_localizer!["sa_player_gag_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
Name = caller?.PlayerName, }
IpAddress = caller?.IpAddress?.Split(":")[0] }
};
Task.Run(async () => if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{ {
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time); using (new WithTemporaryCulture(_player.GetLanguage()))
});
if (TagsDetected)
Server.ExecuteCommand($"css_tag_mute {player!.SteamID}");
playerPenaltyManager.AddPenalty(player!.Slot, PenaltyType.Gag, DateTime.Now.AddMinutes(time), time);
if (time == 0)
{
if (!player!.IsBot && !player.IsHLTV)
{ {
using (new WithTemporaryCulture(player.GetLanguage())) StringBuilder sb = new(_localizer!["sa_prefix"]);
{ sb.Append(_localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
player.PrintToCenter(_localizer!["sa_player_gag_message_perm", reason, caller == null ? "Console" : caller.PlayerName]); _player.PrintToChat(sb.ToString());
}
}
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{
using (new WithTemporaryCulture(_player.GetLanguage()))
{
StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
_player.PrintToChat(sb.ToString());
}
}
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
} }
} }
else if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{ {
if (!player!.IsBot && !player.IsHLTV) LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
{ _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
using (new WithTemporaryCulture(player.GetLanguage())) }
{ }
player!.PrintToCenter(_localizer!["sa_player_gag_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]); }
} else
} {
if (!player!.IsBot && !player.IsHLTV)
{
using (new WithTemporaryCulture(player.GetLanguage()))
{
player!.PrintToCenter(_localizer!["sa_player_gag_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
}
}
if (caller == null || caller != null && caller != null && !silentPlayers.Contains(caller.Slot)) if (caller == null || caller != null && caller != null && !silentPlayers.Contains(caller.Slot))
{
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{
using (new WithTemporaryCulture(_player.GetLanguage()))
{ {
foreach (CCSPlayerController _player in Helper.GetValidPlayers()) StringBuilder sb = new(_localizer!["sa_prefix"]);
{ sb.Append(_localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
using (new WithTemporaryCulture(_player.GetLanguage())) _player.PrintToChat(sb.ToString());
{
StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
_player.PrintToChat(sb.ToString());
}
}
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
} }
} }
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
}
}
} }
[ConsoleCommand("css_addgag")] [ConsoleCommand("css_addgag")]
@@ -860,10 +860,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
}); });
} }
internal void Mute(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null) internal void Mute(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null, PlayerPenaltyManager playerPenaltyManager = null)
{ {
reason ??= "Unknown"; reason ??= "Unknown";
muteManager ??= new(_database); muteManager ??= new(_database);
playerPenaltyManager ??= new PlayerPenaltyManager();
PlayerInfo playerInfo = new PlayerInfo PlayerInfo playerInfo = new PlayerInfo
{ {
@@ -872,73 +873,73 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
IpAddress = player?.IpAddress?.Split(":")[0] IpAddress = player?.IpAddress?.Split(":")[0]
}; };
PlayerInfo adminInfo = new PlayerInfo PlayerInfo adminInfo = new PlayerInfo
{
SteamId = caller?.SteamID.ToString(),
Name = caller?.PlayerName,
IpAddress = caller?.IpAddress?.Split(":")[0]
};
player!.VoiceFlags = VoiceFlags.Muted;
Task.Run(async () =>
{
await muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1);
});
playerPenaltyManager.AddPenalty(player!.Slot, PenaltyType.Mute, DateTime.Now.AddMinutes(time), time);
if (time == 0)
{
if (!player.IsBot && !player.IsHLTV)
using (new WithTemporaryCulture(player.GetLanguage()))
{ {
SteamId = caller?.SteamID.ToString(), player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
Name = caller?.PlayerName, }
IpAddress = caller?.IpAddress?.Split(":")[0]
};
player!.VoiceFlags = VoiceFlags.Muted; if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{
Task.Run(async () => foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{ {
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1); using (new WithTemporaryCulture(_player.GetLanguage()))
});
playerPenaltyManager.AddPenalty(player!.Slot, PenaltyType.Mute, DateTime.Now.AddMinutes(time), time);
if (time == 0)
{
if (!player.IsBot && !player.IsHLTV)
using (new WithTemporaryCulture(player.GetLanguage()))
{
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{ {
foreach (CCSPlayerController _player in Helper.GetValidPlayers()) StringBuilder sb = new(_localizer!["sa_prefix"]);
{ sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
using (new WithTemporaryCulture(_player.GetLanguage())) _player.PrintToChat(sb.ToString());
{
StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
_player.PrintToChat(sb.ToString());
}
}
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
} }
} }
else if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{ {
if (!player.IsBot && !player.IsHLTV) LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
using (new WithTemporaryCulture(player.GetLanguage())) _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
{ }
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]); }
} }
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot)) else
{
if (!player.IsBot && !player.IsHLTV)
using (new WithTemporaryCulture(player.GetLanguage()))
{
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{
using (new WithTemporaryCulture(_player.GetLanguage()))
{ {
foreach (CCSPlayerController _player in Helper.GetValidPlayers()) StringBuilder sb = new(_localizer!["sa_prefix"]);
{ sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
using (new WithTemporaryCulture(_player.GetLanguage())) _player.PrintToChat(sb.ToString());
{
StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
_player.PrintToChat(sb.ToString());
}
}
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
} }
} }
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
{
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}
}
}
} }
[ConsoleCommand("css_addmute")] [ConsoleCommand("css_addmute")]
@@ -1509,7 +1510,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
Task.Run(async () => Task.Run(async () =>
{ {
await _banManager.BanPlayer(playerInfo, adminInfo, reason, time); await banManager.BanPlayer(playerInfo, adminInfo, reason, time);
}); });
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE); AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);