From 44ca294f1e3b76c5014469eb9969789da29773fc Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Thu, 21 Nov 2024 14:00:34 +0100 Subject: [PATCH] add Replace : to # in friend codes (just in case) --- Modules/BanManager.cs | 23 +++++++++++++++-------- Modules/DevManager.cs | 2 ++ Patches/ChatCommandPatch.cs | 12 ++++++++---- Roles/Crewmate/Enigma.cs | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs index b494ccca9..4c53b11e2 100644 --- a/Modules/BanManager.cs +++ b/Modules/BanManager.cs @@ -96,15 +96,17 @@ namespace EHR { if (!AmongUsClient.Instance.AmHost || player == null) return; - if (!CheckBanList(player.FriendCode, player.GetHashedPuid()) && !TempBanWhiteList.Contains(player.GetHashedPuid())) + string friendCode = player.FriendCode.Replace(':', '#'); + + if (!CheckBanList(friendCode, player.GetHashedPuid()) && !TempBanWhiteList.Contains(player.GetHashedPuid())) { if (player.GetHashedPuid() != "" && player.GetHashedPuid() != null && player.GetHashedPuid() != "e3b0cb855") { - File.AppendAllText(BanListPath, $"{player.FriendCode},{player.GetHashedPuid()},{player.PlayerName.RemoveHtmlTags()}\n"); + File.AppendAllText(BanListPath, $"{friendCode},{player.GetHashedPuid()},{player.PlayerName.RemoveHtmlTags()}\n"); Logger.SendInGame(string.Format(GetString("Message.AddedPlayerToBanList"), player.PlayerName)); } else - Logger.Info($"Failed to add player {player.PlayerName.RemoveHtmlTags()}/{player.FriendCode}/{player.GetHashedPuid()} to ban list!", "AddBanPlayer"); + Logger.Info($"Failed to add player {player.PlayerName.RemoveHtmlTags()}/{friendCode}/{player.GetHashedPuid()} to ban list!", "AddBanPlayer"); } } @@ -145,7 +147,7 @@ namespace EHR { if (!AmongUsClient.Instance.AmHost || !Options.ApplyBanList.GetBool() || player == null) return; - string friendcode = player.FriendCode; + string friendcode = player.FriendCode.Replace(':', '#'); if (friendcode.Length < 7) // #1234 is 5 chars, and it's impossible for a friend code to only have 3 { @@ -155,7 +157,7 @@ namespace EHR return; } - if (friendcode.Count(c => c == '#') > 1) + if (friendcode.Count(c => c == '#') != 1) { // This is part of eac, so that's why it will say banned by EAC list. AmongUsClient.Instance.KickPlayer(player.Id, true); @@ -175,7 +177,7 @@ namespace EHR return; } - if (CheckBanList(player.FriendCode, player.GetHashedPuid())) + if (CheckBanList(friendcode, player.GetHashedPuid())) { AmongUsClient.Instance.KickPlayer(player.Id, true); Logger.SendInGame(string.Format(GetString("Message.BanedByBanList"), player.PlayerName)); @@ -183,7 +185,7 @@ namespace EHR return; } - if (CheckEACList(player.FriendCode, player.GetHashedPuid())) + if (CheckEACList(friendcode, player.GetHashedPuid())) { AmongUsClient.Instance.KickPlayer(player.Id, true); Logger.SendInGame(string.Format(GetString("Message.BanedByEACList"), player.PlayerName)); @@ -200,6 +202,8 @@ namespace EHR public static bool CheckBanList(string code, string hashedpuid = "") { + code = code.Replace(':', '#'); + var OnlyCheckPuid = false; switch (code) @@ -239,6 +243,8 @@ namespace EHR public static bool CheckEACList(string code, string hashedPuid) { + code = code.Replace(':', '#'); + var OnlyCheckPuid = false; switch (code) @@ -262,7 +268,8 @@ namespace EHR ClientData recentClient = AmongUsClient.Instance.GetRecentClient(clientId); if (recentClient == null) return; - if (!BanManager.CheckBanList(recentClient.FriendCode, recentClient.GetHashedPuid())) __instance.BanButton.GetComponent().SetEnabledColors(); + if (!BanManager.CheckBanList(recentClient.FriendCode, recentClient.GetHashedPuid())) + __instance.BanButton.GetComponent().SetEnabledColors(); } } } \ No newline at end of file diff --git a/Modules/DevManager.cs b/Modules/DevManager.cs index 2c1d29ea0..aaff8b111 100644 --- a/Modules/DevManager.cs +++ b/Modules/DevManager.cs @@ -131,6 +131,7 @@ namespace EHR new("strangeant#6543", isUp: true), // after.edits new("ninjanice#3990", isUp: true), // void_daora new("magicmill#4146", isUp: true), // Sr.Angel + new("grassyprey#9593", isUp: true), // LucasCarr new("blessedtes#6684", "#ff0000", "YouTuber", true), // Gabriel So Capa // Sponsor @@ -159,6 +160,7 @@ namespace EHR public static DevUser GetDevUser(this string code) { + code = code.Replace(':', '#'); return code.IsDevUser() ? DevUserList.Find(x => x.Code == code) : DefaultDevUser; } } diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 103fee62e..d8406a29e 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -192,6 +192,8 @@ namespace EHR // Function to check if a player is a moderator public static bool IsPlayerModerator(string friendCode) { + friendCode = friendCode.Replace(':', '#'); + if (friendCode == "" || friendCode == string.Empty || !Options.ApplyModeratorList.GetBool()) return false; const string friendCodesFilePath = "./EHR_DATA/Moderators.txt"; @@ -209,6 +211,8 @@ namespace EHR // Function to check if a player is a VIP public static bool IsPlayerVIP(string friendCode) { + friendCode = friendCode.Replace(':', '#'); + if (friendCode == "" || friendCode == string.Empty || !Options.ApplyVIPList.GetBool()) return false; const string friendCodesFilePath = "./EHR_DATA/VIPs.txt"; @@ -555,7 +559,7 @@ namespace EHR PlayerControl VIPPc = Utils.GetPlayerById(VIPId); if (VIPPc == null) return; - string fc = VIPPc.FriendCode; + string fc = VIPPc.FriendCode.Replace(':', '#'); if (!IsPlayerVIP(fc)) Utils.SendMessage(GetString("PlayerNotVIP"), player.PlayerId); string[] lines = File.ReadAllLines("./EHR_DATA/VIPs.txt").Where(line => !line.Contains(fc)).ToArray(); @@ -570,7 +574,7 @@ namespace EHR PlayerControl newVIPPc = Utils.GetPlayerById(newVIPId); if (newVIPPc == null) return; - string fc = newVIPPc.FriendCode; + string fc = newVIPPc.FriendCode.Replace(':', '#'); if (IsPlayerVIP(fc)) Utils.SendMessage(GetString("PlayerAlreadyVIP"), player.PlayerId); File.AppendAllText("./EHR_DATA/VIPs.txt", $"\n{fc}"); @@ -1453,7 +1457,7 @@ namespace EHR PlayerControl remModPc = Utils.GetPlayerById(remModId); if (remModPc == null) return; - string remFc = remModPc.FriendCode; + string remFc = remModPc.FriendCode.Replace(':', '#'); if (!IsPlayerModerator(remFc)) Utils.SendMessage(GetString("PlayerNotMod"), player.PlayerId); File.WriteAllLines("./EHR_DATA/Moderators.txt", File.ReadAllLines("./EHR_DATA/Moderators.txt").Where(x => !x.Contains(remFc))); @@ -1467,7 +1471,7 @@ namespace EHR PlayerControl newModPc = Utils.GetPlayerById(newModId); if (newModPc == null) return; - string fc = newModPc.FriendCode; + string fc = newModPc.FriendCode.Replace(':', '#'); if (IsPlayerModerator(fc)) Utils.SendMessage(GetString("PlayerAlreadyMod"), player.PlayerId); File.AppendAllText("./EHR_DATA/Moderators.txt", $"\n{fc}"); diff --git a/Roles/Crewmate/Enigma.cs b/Roles/Crewmate/Enigma.cs index 5b85f078b..11eb62146 100644 --- a/Roles/Crewmate/Enigma.cs +++ b/Roles/Crewmate/Enigma.cs @@ -464,7 +464,7 @@ namespace EHR.Crewmate public override string GetMessage(PlayerControl killer, bool showStageClue) { - string friendCode = killer.Data.FriendCode; + string friendCode = killer.Data.FriendCode.Replace(':', '#'); return string.Format(GetString("EnigmaClueFriendCode"), friendCode); } }