2121 * Work on fork by Hedius (Version >= 8.0.0.0)
2222 *
2323 * AdKats.cs
24- * Version 8.1.4 .0
25- * 15-AUG -2022
24+ * Version 8.1.5 .0
25+ * 07-OCT -2022
2626 *
2727 * Automatic Update Information
28- * <version_code>8.1.4 .0</version_code>
28+ * <version_code>8.1.5 .0</version_code>
2929 */
3030
3131using System;
@@ -68,7 +68,7 @@ public class AdKats : PRoConPluginAPI, IPRoConPluginInterface
6868 {
6969
7070 //Current Plugin Version
71- private const String PluginVersion = "8.1.4 .0";
71+ private const String PluginVersion = "8.1.5 .0";
7272
7373 public enum GameVersionEnum
7474 {
@@ -533,6 +533,7 @@ public enum VoipJoinDisplayType
533533 private Boolean _MutedPlayerIgnoreCommands = true;
534534 private Boolean _UseFirstSpawnMutedMessage = true;
535535 private String _FirstSpawnMutedMessage = "You are perma or temp muted! Talking will cause punishment!";
536+ private Int32 _ForceMuteBanDuration = 60;
536537
537538 //Surrender
538539 private Boolean _surrenderVoteEnable;
@@ -1876,6 +1877,7 @@ public void BuildMuteSettings(List<CPluginVariable> lstReturn)
18761877 {
18771878 buildList.Add(new CPluginVariable(GetSettingSection("A11") + t + "First spawn persistent muted warning text", typeof(String), _FirstSpawnMutedMessage));
18781879 }
1880+ buildList.Add(new CPluginVariable(GetSettingSection("A11") + t + "Persistent force mute temp-ban duration minutes", typeof(int), _ForceMuteBanDuration));
18791881 }
18801882 lstReturn.AddRange(buildList);
18811883 }
@@ -8228,6 +8230,17 @@ public void SetPluginVariable(String strVariable, String strValue)
82288230 QueueSettingForUpload(new CPluginVariable(@"First spawn persistent muted warning text", typeof(String), _FirstSpawnMutedMessage));
82298231 }
82308232 }
8233+ else if (Regex.Match(strVariable, @"Persistent force mute temp-ban duration minutes").Success)
8234+ {
8235+ Int32 tmp = 45;
8236+ int.TryParse(strValue, out tmp);
8237+ if (_ForceMuteBanDuration != tmp)
8238+ {
8239+ _ForceMuteBanDuration = tmp;
8240+ //Once setting has been changed, upload the change to database
8241+ QueueSettingForUpload(new CPluginVariable(@"Persistent force mute temp-ban duration minutes", typeof(Int32), _ForceMuteBanDuration));
8242+ }
8243+ }
82318244 else if (Regex.Match(strVariable, @"Ticket Window High").Success)
82328245 {
82338246 Int32 tmp = 2;
@@ -17351,7 +17364,7 @@ public override void OnPlayerSpawned(String soldierName, Inventory spawnedInvent
1735117364 Threading.Wait(2000);
1735217365
1735317366 // Send warning to player if the player is muted.
17354- if (_UseFirstSpawnMutedMessage && GetMatchingVerboseASPlayersOfGroup("persistent_mute", aPlayer).Any())
17367+ if (_UseFirstSpawnMutedMessage && ( GetMatchingVerboseASPlayersOfGroup("persistent_mute", aPlayer).Any() || GetMatchingVerboseASPlayersOfGroup("persistent_mute_force", aPlayer).Any() ))
1735517368 {
1735617369 PlayerTellMessage(aPlayer.player_name, _FirstSpawnMutedMessage);
1735717370 Threading.Wait(TimeSpan.FromSeconds(_YellDuration));
@@ -20046,13 +20059,32 @@ private void MessagingThreadLoop()
2004620059 Log.Debug(() => "Checking for mute case.", 7);
2004720060 // Persistent mute?
2004820061 var persistentMute = GetMatchingVerboseASPlayersOfGroup("persistent_mute", aPlayer).Any();
20062+ var persistentForceMute = GetMatchingVerboseASPlayersOfGroup("persistent_mute_force", aPlayer).Any();
2004920063 // Add persistent mute to RoundMutedPlayers if the player is missing in the list.
2005020064 if (persistentMute && !_RoundMutedPlayers.ContainsKey(messageObject.Speaker)) {
2005120065 Log.Debug(() => "Adding missing persistent mute to RoundMutedPlayers.", 4);
2005220066 _RoundMutedPlayers.Add(messageObject.Speaker, 0);
2005320067 }
20054- if (_RoundMutedPlayers.ContainsKey(messageObject.Speaker))
20068+ if (persistentForceMute)
20069+ {
20070+ // Force Mute -> Temp Ban Player
20071+ ARecord record = new ARecord();
20072+ record.record_time = UtcNow();
20073+ record.record_source = ARecord.Sources.Automated;
20074+ record.server_id = _serverInfo.ServerID;
20075+ record.source_name = "PlayerMuteSystem";
20076+ _PlayerDictionary.TryGetValue(messageObject.Speaker, out record.target_player);
20077+ record.target_name = messageObject.Speaker;
20078+ record.record_message = _PersistentMutedPlayerKickMessage;
20079+ record.command_type = GetCommandByKey("player_ban_temp");
20080+ record.command_action = GetCommandByKey("player_ban_temp");
20081+ record.command_numeric = _ForceMuteBanDuration;
20082+ QueueRecordForProcessing(record);
20083+ continue;
20084+ }
20085+ else if (_RoundMutedPlayers.ContainsKey(messageObject.Speaker))
2005520086 {
20087+ // Round, Temp Perma Mute Kill -> Kick
2005620088 if (_MutedPlayerIgnoreCommands && isCommand)
2005720089 {
2005820090 Log.Debug(() => "Player muted, but ignoring since message is command.", 3);
@@ -21160,8 +21192,8 @@ private void QueueRecordForProcessing(ARecord record)
2116021192 }
2116121193 Log.Debug(() => record.command_type.command_key + " record allowed to continue processing.", 5);
2116221194 break;
21163- case "player_peristentmute_remove ":
21164- if (!GetMatchingASPlayersOfGroup("persistent_mute", record.target_player).Any())
21195+ case "player_persistentmute_remove ":
21196+ if (!GetMatchingASPlayersOfGroup("persistent_mute", record.target_player).Any() && !GetMatchingASPlayersOfGroup("persistent_mute_force", record.target_player).Any() )
2116521197 {
2116621198 SendMessageToSource(record, "Matching player not perma/temp muted.");
2116721199 FinalizeRecord(record);
@@ -26996,6 +27028,7 @@ public void CompleteRecordInformation(ARecord record, AChatMessage message)
2699627028 }
2699727029 break;
2699827030 case "player_persistentmute":
27031+ case "player_persistentmute_force":
2699927032 {
2700027033 // Rant: GOD THIS IS SO REDUNDANT - .... same code in each case here...
2700127034 // MY EYES ARE BLEEDING :) Hedius.
@@ -30425,8 +30458,11 @@ private void RunAction(ARecord record)
3042530458 case "player_mute":
3042630459 MuteTarget(record);
3042730460 break;
30428- case "player_persistentmute":
30429- PersistentMuteTarget(record);
30461+ case "player_persistentmute":
30462+ PersistentMuteTarget(record, false);
30463+ break;
30464+ case "player_persistentmute_force":
30465+ PersistentMuteTarget(record, true);
3043030466 break;
3043130467 case "player_unmute":
3043230468 case "player_persistentmute_remove":
@@ -34385,10 +34421,11 @@ public void MuteTarget(ARecord record)
3438534421 Log.Debug(() => "Exiting muteTarget", 6);
3438634422 }
3438734423
34388- public void PersistentMuteTarget(ARecord record)
34424+ public void PersistentMuteTarget(ARecord record, bool force )
3438934425 {
3439034426 Log.Debug(() => "Entering PersistentMuteTarget", 6);
34391- if (HasAccess(record.target_player, GetCommandByKey("player_persistentmute")))
34427+ if (HasAccess(record.target_player, GetCommandByKey("player_persistentmute"))
34428+ || HasAccess(record.target_player, GetCommandByKey("player_persistentmute_force")))
3439234429 {
3439334430 SendMessageToSource(record, "You can't mute an admin.");
3439434431 FinalizeRecord(record);
@@ -34405,7 +34442,7 @@ public void PersistentMuteTarget(ARecord record)
3440534442 command.CommandText = @"
3440634443 DELETE FROM
3440734444 `adkats_specialplayers`
34408- WHERE `player_group` = @player_group
34445+ WHERE `player_group` IN ('persistent_mute', 'persistent_mute_force')
3440934446 AND (`player_id` = @player_id OR `player_identifier` = @player_name);
3441034447 INSERT INTO
3441134448 `adkats_specialplayers`
@@ -34435,15 +34472,15 @@ INSERT INTO
3443534472 {
3443634473 record.command_numeric = 10518984;
3443734474 }
34438- command.Parameters.AddWithValue("@player_group", "persistent_mute");
34475+ command.Parameters.AddWithValue("@player_group", force ? "persistent_mute_force": "persistent_mute");
3443934476 command.Parameters.AddWithValue("@player_id", record.target_player.player_id);
3444034477 command.Parameters.AddWithValue("@player_name", record.target_player.player_name);
3444134478 command.Parameters.AddWithValue("@duration_minutes", record.command_numeric);
3444234479
3444334480 Int32 rowsAffected = SafeExecuteNonQuery(command);
3444434481 if (rowsAffected > 0)
3444534482 {
34446- String message = "Player " + record.GetTargetNames() + " given " + ((record.command_numeric == 10518984) ? ("permanent") : (FormatTimeString(TimeSpan.FromMinutes(record.command_numeric), 2))) + " persistent mute on all servers.";
34483+ String message = "Player " + record.GetTargetNames() + " given " + ((record.command_numeric == 10518984) ? ("permanent") : (FormatTimeString(TimeSpan.FromMinutes(record.command_numeric), 2))) + " persistent " + (force ? "force ": "") +" mute on all servers.";
3444734484 AdminSayMessage(message);
3444834485 if (record.record_source != ARecord.Sources.InGame &&
3444934486 record.record_source != ARecord.Sources.Automated &&
@@ -34456,7 +34493,7 @@ INSERT INTO
3445634493 }
3445734494 else
3445834495 {
34459- Log.Error("Unable to add player to persistent mute list. Error uploading." );
34496+ Log.Error("Unable to add player to persistent mute list. Error uploading. Force: " + force );
3446034497 }
3446134498 }
3446234499 }
@@ -34484,10 +34521,12 @@ public void UnMuteTarget(ARecord record)
3448434521 return;
3448534522 }
3448634523 var persistentMute = GetMatchingVerboseASPlayersOfGroup("persistent_mute", record.target_player).Any();
34487- if (persistentMute)
34524+ var persistentForceMute = GetMatchingVerboseASPlayersOfGroup("persistent_mute_force", record.target_player).Any();
34525+ if (persistentMute || persistentForceMute)
3448834526 {
3448934527 List<ASpecialPlayer> matchingPlayers = GetMatchingASPlayersOfGroup("persistent_mute", record.target_player);
34490- if (!matchingPlayers.Any())
34528+ List<ASpecialPlayer> matchingPlayersForce = GetMatchingASPlayersOfGroup("persistent_mute_force", record.target_player);
34529+ if (!matchingPlayers.Any() && !matchingPlayersForce.Any())
3449134530 {
3449234531 SendMessageToSource(record, "Matching player not in the persistent mute list.");
3449334532 FinalizeRecord(record);
@@ -34496,7 +34535,7 @@ public void UnMuteTarget(ARecord record)
3449634535 using (MySqlConnection connection = GetDatabaseConnection())
3449734536 {
3449834537 Boolean updated = false;
34499- foreach (ASpecialPlayer asPlayer in matchingPlayers)
34538+ foreach (ASpecialPlayer asPlayer in matchingPlayers.Concat(matchingPlayersForce).ToList() )
3450034539 {
3450134540 using (MySqlCommand command = connection.CreateCommand())
3450234541 {
@@ -34532,7 +34571,7 @@ public void UnMuteTarget(ARecord record)
3453234571 }
3453334572 else
3453434573 {
34535- if (!persistentMute)
34574+ if (!persistentMute && !persistentForceMute )
3453634575 SendMessageToSource(record, record.GetTargetNames() + " is not muted.");
3453734576 FinalizeRecord(record);
3453834577 return;
@@ -40787,6 +40826,7 @@ private void UploadAllSettings()
4078740826 QueueSettingForUpload(new CPluginVariable(@"Ignore commands for mute enforcement", typeof(Boolean), _MutedPlayerIgnoreCommands));
4078840827 QueueSettingForUpload(new CPluginVariable(@"Send first spawn warning for persistent muted players", typeof(Boolean), _UseFirstSpawnMutedMessage));
4078940828 QueueSettingForUpload(new CPluginVariable(@"First spawn persistent muted warning text", typeof(String), _FirstSpawnMutedMessage));
40829+ QueueSettingForUpload(new CPluginVariable(@"Persistent force mute temp-ban duration minutes", typeof(Int32), _ForceMuteBanDuration));
4079040830 QueueSettingForUpload(new CPluginVariable(@"Ticket Window High", typeof(Int32), _TeamSwapTicketWindowHigh));
4079140831 QueueSettingForUpload(new CPluginVariable(@"Ticket Window Low", typeof(Int32), _TeamSwapTicketWindowLow));
4079240832 QueueSettingForUpload(new CPluginVariable(@"Enable Admin Assistants", typeof(Boolean), _EnableAdminAssistants));
@@ -47116,6 +47156,11 @@ private void FetchCommands()
4711647156 SendNonQuery("Adding command player_watchlist_remove", "INSERT INTO `adkats_commands` VALUES(152, 'Active', 'player_watchlist_remove', 'Log', 'Remove Player from Watchlist', 'rwatch', TRUE, 'AnyHidden')", true);
4711747157 newCommands = true;
4711847158 }
47159+ if (!_CommandIDDictionary.ContainsKey(153))
47160+ {
47161+ SendNonQuery("Adding command player_persistentmute_force", "INSERT INTO `adkats_commands` VALUES(153, 'Active', 'player_persistentmute_force', 'Log', 'Persistent Force Mute Player', 'fmute', TRUE, 'AnyHidden')", true);
47162+ newCommands = true;
47163+ }
4711947164 if (newCommands)
4712047165 {
4712147166 FetchCommands();
@@ -47157,6 +47202,7 @@ private void FillCommandDescDictionary()
4715747202 _CommandDescriptionDictionary["player_forgive"] = "Decreases infraction points and informs the player. Requires a reason.";
4715847203 _CommandDescriptionDictionary["player_mute"] = "Mutes a player for the current round. Talking will cause punishment. Requires a reason.";
4715947204 _CommandDescriptionDictionary["player_persistentmute"] = "Mutes a player for a given time span or permanent. Talking will cause punishment. Requires a reason.";
47205+ _CommandDescriptionDictionary["player_persistentmute_force"] = "Mutes a player for a given time span or permanent. Talking will cause a temp ban. Requires a reason.";
4716047206 _CommandDescriptionDictionary["player_unmute"] = "Unmutes a muted player.";
4716147207 _CommandDescriptionDictionary["player_persistentmute_remove"] = "Unmutes a perma/temp muted player.";
4716247208 _CommandDescriptionDictionary["player_join"] = "Switches you to a players squad if there is room.";
@@ -49551,7 +49597,9 @@ private void ParseExternalCommand(Object commandParams)
4955149597 //Import the command numeric
4955249598 //Only required for temp ban & persistent mutes
4955349599 //ToDo: what about whitelists?
49554- if (record.command_type.command_key == "player_ban_temp" || record.command_type.command_key == "player_persistentmute")
49600+ if (record.command_type.command_key == "player_ban_temp"
49601+ || record.command_type.command_key == "player_persistentmute"
49602+ || record.command_type.command_key == "player_persistentmute_force")
4955549603 {
4955649604 if (!parsedClientInformation.ContainsKey("command_numeric"))
4955749605 {
0 commit comments