From e2499b6ea45847fac7c99b6a67d3ce3a7f84b335 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sun, 22 Sep 2024 18:45:55 -0500 Subject: [PATCH 01/20] fix --- Modules/AntiCheat.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 6d076ab..b4124d7 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -623,6 +623,7 @@ class AntiCheat if (callId is (byte)RpcCalls.SendChatNote) { + _ = reader.ReadByte(); var type = reader.ReadByte(); if (!GameStates.IsMeeting || (ChatNoteTypes)type == ChatNoteTypes.DidVote && player.BetterData().AntiCheatInfo.ChatDidVote) From 59b055b58f3fac200072691ec1f3dd7f6b19573a Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sun, 22 Sep 2024 19:40:34 -0500 Subject: [PATCH 02/20] Modded lobby auto kick fix --- Modules/RPC.cs | 21 +++++++++++---------- Resources/Lang/en_US.json | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 4fa3b8d..23cf613 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -151,7 +151,7 @@ internal static class RPC public static void HandleCustomRPC(PlayerControl player, byte callId, MessageReader oldReader) { - if (player == null || player.IsLocalPlayer() || player.Data == null) return; + if (player == null || player.IsLocalPlayer() || player.Data == null || Enum.IsDefined(typeof(RpcCalls), callId)) return; if (Enum.IsDefined(typeof(CustomRPC), (int)unchecked(callId))) { @@ -206,21 +206,22 @@ internal static class RPC */ } } - - try + else if (!Enum.IsDefined(typeof(CustomRPC), (int)unchecked(callId))) { - if (!GameStates.IsTOHEHostLobby && callId is not unchecked((byte)CustomRPC.Sicko) or unchecked((byte)CustomRPC.AUM) or (byte)CustomRPC.AUMChat) + try { - var flag = Enum.IsDefined(typeof(CustomRPC), (int)callId) || Enum.IsDefined(typeof(RpcCalls), callId); - - if (!flag && player.IsHost()) + if (!GameStates.IsHost && !GameStates.IsTOHEHostLobby) { - var BAU = "♻BetterAmongUs♻"; - Utils.DisconnectSelf($"{BAU} does not support\nModded Lobbies!"); + if (player.IsHost()) + { + var Icon = Translator.GetString("BAUMark"); + var BAU = $"{Icon}{Translator.GetString("BAU")}{Icon}"; + Utils.DisconnectSelf(string.Format(Translator.GetString("ModdedLobbyMsg"), BAU)); + } } } + catch { } } - catch { } } public static void HandleRPC(PlayerControl player, byte callId, MessageReader oldReader) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index b78ac37..10085c5 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -15,6 +15,7 @@ "Timer": "Timer", "SystemMessage": "System Message", "SystemNotification": "System Notification", + "ModdedLobbyMsg": "{0} does not support\nModded Lobbies", "Player.Loading": "Loading", "Player.NoFriendCode": "No Friend Code", From 0f45e0faffb5f98bf37bd70b7b905013e9feda90 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sun, 22 Sep 2024 20:24:45 -0500 Subject: [PATCH 03/20] Enable console --- Modules/Debugger.cs | 3 +++ main.cs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Modules/Debugger.cs b/Modules/Debugger.cs index d4a958d..e235e59 100644 --- a/Modules/Debugger.cs +++ b/Modules/Debugger.cs @@ -1,4 +1,6 @@  +using BepInEx; + namespace BetterAmongUs; class Logger @@ -10,6 +12,7 @@ class Logger string newLine = $"{mark}: {Utils.RemoveHtmlText(info)}"; File.AppendAllText(logFilePath, newLine + Environment.NewLine); Main.Logger.LogInfo($"[{tag}] {info}"); + ConsoleManager.ConsoleStream.WriteLine($"{DateTime.Now:HH:mm} BetterAmongUs[{tag}]: {info}"); } public static void LogHeader(string info, string tag = "LogHeader") => Log($" >-------------- {info} --------------<", tag); public static void LogCheat(string info, string tag = "AntiCheat") => Log(info, tag); diff --git a/main.cs b/main.cs index fa37047..b8ba49a 100644 --- a/main.cs +++ b/main.cs @@ -3,12 +3,14 @@ using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BetterAmongUs.Patches; +using Epic.OnlineServices.Presence; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Innersloth.IO; using System.Security.Cryptography; using System.Text; using UnityEngine; +using static UnityEngine.RemoteConfigSettingsHelper; namespace BetterAmongUs; @@ -153,6 +155,11 @@ public class Main : BasePlugin { try { + ConsoleManager.CreateConsole(); + ConsoleManager.SetConsoleTitle("Among Us - BAU Console"); + ConsoleManager.ConfigPreventClose.Value = true; + ConsoleManager.ConsoleStream.WriteLine($".--------------------------------------------------------------------------------.\r\n| ____ _ _ _ _ _ |\r\n| | __ ) ___| |_| |_ ___ _ __ / \\ _ __ ___ ___ _ __ __ _ | | | |___ |\r\n| | _ \\ / _ \\ __| __/ _ \\ '__| / _ \\ | '_ ` _ \\ / _ \\| '_ \\ / _` | | | | / __||\r\n| | |_) | __/ |_| || __/ | / ___ \\| | | | | | (_) | | | | (_| | | |_| \\__ \\|\r\n| |____/ \\___|\\__|\\__\\___|_| /_/ \\_\\_| |_| |_|\\___/|_| |_|\\__, | \\___/|___/|\r\n| |___/ |\r\n'--------------------------------------------------------------------------------'"); + Logger = BepInEx.Logging.Logger.CreateLogSource(PluginGuid); BetterDataManager.SetUp(); From cfaa6606db29763b6650bfc3494502afb180c7c6 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 00:41:50 -0500 Subject: [PATCH 04/20] prefix --- Patches/CommandsPatch.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs index 2f1ba70..aa7a521 100644 --- a/Patches/CommandsPatch.cs +++ b/Patches/CommandsPatch.cs @@ -17,7 +17,7 @@ class CommandsPatch private static bool HasPermission => Permission != null && AmongUsClient.Instance?.GetHost()?.Character?.Data == Permission; public static NetworkedPlayerInfo? Permission = null; - + public static string CommandPrefix => !GameStates.IsTOHEHostLobby ? Main.CommandPrefix.Value : Main.CommandPrefix.Value == "/" ? "." : Main.CommandPrefix.Value; // List of helper text when a command is being typed out // First word is command, {} are arguments, first --- is command description, second --- is for help command. @@ -116,7 +116,7 @@ class CommandsPatch { if (i < allCommands.Length) { - list += $"\n{mid}{Main.CommandPrefix.Value}{allCommands[i].Split(' ')[0].Split("---")[0]} {allCommands[i].Split("---")[1]}."; + list += $"\n{mid}{CommandPrefix}{allCommands[i].Split(' ')[0].Split("---")[0]} {allCommands[i].Split("---")[1]}."; } } if (Main.myAccountInfo.IsSponsor == true) @@ -127,7 +127,7 @@ class CommandsPatch { if (i < allSponsorCommands.Length) { - list += $"\n{mid}{Main.CommandPrefix.Value}{allSponsorCommands[i].Split(' ')[0].Split("---")[0]} {allSponsorCommands[i].Split("---")[1]}."; + list += $"\n{mid}{CommandPrefix}{allSponsorCommands[i].Split(' ')[0].Split("---")[0]} {allSponsorCommands[i].Split("---")[1]}."; } } } @@ -139,7 +139,7 @@ class CommandsPatch { if (i < allDebugCommands.Length) { - list += $"\n{mid}{Main.CommandPrefix.Value}{allDebugCommands[i].Split(' ')[0].Split("---")[0]} {allDebugCommands[i].Split("---")[1]}."; + list += $"\n{mid}{CommandPrefix}{allDebugCommands[i].Split(' ')[0].Split("---")[0]} {allDebugCommands[i].Split("---")[1]}."; } } } @@ -253,7 +253,7 @@ class CommandsPatch { RPC.SyncAllNames(); hasSet = true; - }, 1f, $"Command {Main.CommandPrefix.Value}name"); + }, 1f, $"Command {CommandPrefix}name"); } else if (command.Length > 1 && !string.IsNullOrWhiteSpace(command[1]) && System.Text.RegularExpressions.Regex.IsMatch(command[1], @"^[a-zA-Z0-9]+$")) { @@ -588,7 +588,7 @@ class CommandsPatch string text = __instance.freeChatField.textArea.text; - if (string.IsNullOrEmpty(text) || text.Length <= 1 || text[0].ToString() != Main.CommandPrefix.Value || 3f - __instance.timeSinceLastMessage > 0f) + if (string.IsNullOrEmpty(text) || text.Length <= 1 || text[0].ToString() != CommandPrefix || 3f - __instance.timeSinceLastMessage > 0f) { if (GameStates.InGame && !GameStates.IsLobby && !GameStates.IsFreePlay && !GameStates.IsMeeting && !GameStates.IsExilling && PlayerControl.LocalPlayer.IsAlive()) return false; @@ -671,7 +671,7 @@ class CommandsPatch if (commandText != null && commandInfo != null) { // Check if the first character is the command prefix - if (text.Length > 0 && text[0].ToString() == Main.CommandPrefix.Value) + if (text.Length > 0 && text[0].ToString() == CommandPrefix) { // Get the typed command without the prefix string typedCommand = text.Substring(1); @@ -712,11 +712,11 @@ class CommandsPatch if (Input.GetKeyDown(KeyCode.Tab) && typedParts.Length < 2) { - __instance.freeChatField.textArea.SetText(Main.CommandPrefix.Value + commandParts[0]); + __instance.freeChatField.textArea.SetText(CommandPrefix + commandParts[0]); } // Display the command suggestion - commandText.GetComponent().text = Main.CommandPrefix.Value + suggestion; + commandText.GetComponent().text = CommandPrefix + suggestion; commandInfo.GetComponent().text = CommandInfo; } else From d8dc6c5e624784f8278b8c0403cebb197fe2bf21 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 13:03:09 -0500 Subject: [PATCH 05/20] Fix chat not sensor and clean up --- Patches/ChatPatch.cs | 189 ++++++++++++++++--------------------------- 1 file changed, 70 insertions(+), 119 deletions(-) diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index 0f84992..dea6e9e 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -107,137 +107,88 @@ class ChatPatch } } + // Add extra information to chat bubble [HarmonyPatch(nameof(ChatController.AddChat))] - [HarmonyPrefix] - [HarmonyPriority(Priority.First)] - public static bool AddChat_Prefix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText) + [HarmonyPostfix] + public static void AddChat_Postfix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText) { - bool censor = false; - if (!sourcePlayer || !PlayerControl.LocalPlayer) + ChatBubble Get() => __instance.chatBubblePool.activeChildren.ToArray() + .Select(c => c.GetComponent()) + .Last(); + + ChatBubble chatBubble = Get(); + StringBuilder sbTag = new StringBuilder(); + StringBuilder sbInfo = new StringBuilder(); + + string hashPuid = Utils.GetHashPuid(sourcePlayer); + string friendCode = sourcePlayer.Data.FriendCode; + string playerName = sourcePlayer.Data.PlayerName; + string Role = $"{sourcePlayer.GetRoleName()}+++"; + + if (GameStates.IsLobby && !GameStates.IsFreePlay) { - return false; + Role = ""; + + if (sourcePlayer.IsDev()) + sbTag.Append($"Dev+++"); + + if (((sourcePlayer.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value) + || (!sourcePlayer.IsLocalPlayer() && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost()))) + sbTag.AppendFormat("{1}{0}+++", Translator.GetString("Player.BetterHost"), sourcePlayer.BetterData().IsVerifiedBetterUser || sourcePlayer.IsLocalPlayer() ? "✓ " : ""); + else if ((sourcePlayer.IsLocalPlayer() || sourcePlayer.BetterData().IsBetterUser)) + sbTag.AppendFormat("{1}{0}+++", Translator.GetString("Player.BetterUser"), sourcePlayer.BetterData().IsVerifiedBetterUser || sourcePlayer.IsLocalPlayer() ? "✓ " : ""); + + if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode)) + sbTag.Append($"{Translator.GetString("Player.SickoUser")}+++"); + else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.AUMData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.AUMData.ContainsValue(friendCode)) + sbTag.Append($"{Translator.GetString("Player.AUMUser")}+++"); + else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.PlayerData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.PlayerData.ContainsValue(friendCode)) + sbTag.Append($"{Translator.GetString("Player.KnownCheater")}+++"); } - NetworkedPlayerInfo data = PlayerControl.LocalPlayer.Data; - NetworkedPlayerInfo data2 = sourcePlayer.Data; - if (data2 == null || data == null || (data2.IsDead && !data.IsDead)) + + if (!sourcePlayer.IsImpostorTeammate()) { - return false; - } - ChatBubble pooledBubble = __instance.GetPooledBubble(); - try - { - if (sourcePlayer.BetterData().IsBetterUser && GameStates.IsBetterHostLobby) - chatText = chatText.Replace("\n", ""); - - pooledBubble.transform.SetParent(__instance.scroller.Inner); - pooledBubble.transform.localScale = Vector3.one; - bool flag = sourcePlayer.IsLocalPlayer(); - if (flag) - { - pooledBubble.SetRight(); - } - else - { - pooledBubble.SetLeft(); - } - bool didVote = MeetingHud.Instance && MeetingHud.Instance.DidVote(sourcePlayer.PlayerId); - pooledBubble.Background.color = new Color(0.05f, 0.05f, 0.05f, 1f); - pooledBubble.SetCosmetics(data2); - __instance.SetChatBubbleName(pooledBubble, data2, data2.IsDead, didVote, PlayerNameColor.Get(data2), null); - if (censor && DataManager.Settings.Multiplayer.CensorChat) - { - chatText = BlockedWords.CensorWords(chatText, false); - } - pooledBubble.SetText(chatText); - pooledBubble.AlignChildren(); - __instance.AlignAllBubbles(); - if (!__instance.IsOpenOrOpening && __instance.notificationRoutine == null) - { - __instance.notificationRoutine = __instance.StartCoroutine(__instance.BounceDot()); - } - if (!flag) - { - SoundManager.Instance.PlaySound(__instance.messageSound, false, 1f, null).pitch = 0.5f + (float)sourcePlayer.PlayerId / 15f; - __instance.chatNotification.SetUp(sourcePlayer, chatText); - } - - StringBuilder sbTag = new StringBuilder(); - StringBuilder sbInfo = new StringBuilder(); - - string hashPuid = Utils.GetHashPuid(sourcePlayer); - string friendCode = sourcePlayer.Data.FriendCode; - string playerName = sourcePlayer.Data.PlayerName; - string Role = $"{sourcePlayer.GetRoleName()}+++"; - - if (GameStates.IsLobby && !GameStates.IsFreePlay) + if (PlayerControl.LocalPlayer.IsAlive() && !sourcePlayer.IsLocalPlayer()) { Role = ""; - - if (sourcePlayer.IsDev()) - sbTag.Append($"Dev+++"); - - if (((sourcePlayer.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value) - || (!sourcePlayer.IsLocalPlayer() && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost()))) - sbTag.AppendFormat("{1}{0}+++", Translator.GetString("Player.BetterHost"), sourcePlayer.BetterData().IsVerifiedBetterUser || sourcePlayer.IsLocalPlayer() ? "✓ " : ""); - else if ((sourcePlayer.IsLocalPlayer() || sourcePlayer.BetterData().IsBetterUser)) - sbTag.AppendFormat("{1}{0}+++", Translator.GetString("Player.BetterUser"), sourcePlayer.BetterData().IsVerifiedBetterUser || sourcePlayer.IsLocalPlayer() ? "✓ " : ""); - - if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode)) - sbTag.Append($"{Translator.GetString("Player.SickoUser")}+++"); - else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.AUMData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.AUMData.ContainsValue(friendCode)) - sbTag.Append($"{Translator.GetString("Player.AUMUser")}+++"); - else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.PlayerData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.PlayerData.ContainsValue(friendCode)) - sbTag.Append($"{Translator.GetString("Player.KnownCheater")}+++"); } - - if (!sourcePlayer.IsImpostorTeammate()) - { - if (PlayerControl.LocalPlayer.IsAlive() && !sourcePlayer.IsLocalPlayer()) - { - Role = ""; - } - } - - if (PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel) && !sourcePlayer.IsAlive() || !PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel)) - { - sbTag.Append(Role); - } - - sbInfo.Append(""); - for (int i = 0; i < sbTag.ToString().Split("+++").Length; i++) - { - if (!string.IsNullOrEmpty(sbTag.ToString().Split("+++")[i])) - { - if (i < sbTag.ToString().Split("+++").Length) - { - sbInfo.Append(sbTag.ToString().Split("+++")[i]); - } - if (i != sbTag.ToString().Split("+++").Length - 2) - { - sbInfo.Append(" - "); - } - } - } - sbInfo.Append(""); - - if (flag) - { - playerName = $"{sbInfo} " + playerName; - } - else - { - playerName += $" {sbInfo}"; - } - - pooledBubble.NameText.SetText(playerName); - - Logger.Log($"{sourcePlayer.Data.PlayerName} -> {chatText}", "ChatLog"); } - catch + + if (PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel) && !sourcePlayer.IsAlive() || !PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel)) { + sbTag.Append(Role); } - return false; + sbInfo.Append(""); + for (int i = 0; i < sbTag.ToString().Split("+++").Length; i++) + { + if (!string.IsNullOrEmpty(sbTag.ToString().Split("+++")[i])) + { + if (i < sbTag.ToString().Split("+++").Length) + { + sbInfo.Append(sbTag.ToString().Split("+++")[i]); + } + if (i != sbTag.ToString().Split("+++").Length - 2) + { + sbInfo.Append(" - "); + } + } + } + sbInfo.Append(""); + + bool flag = sourcePlayer == PlayerControl.LocalPlayer; + if (flag) + { + playerName = $"{sbInfo} " + playerName; + } + else + { + playerName += $" {sbInfo}"; + } + + chatBubble.NameText.text = playerName; + chatBubble.ColorBlindName.text = $"{chatBubble.ColorBlindName.text}"; + Logger.Log($"{sourcePlayer.Data.PlayerName} -> {chatText}", "ChatLog"); } } From fde3d9127a4dab759bfb289d7f766d491c9de4ed Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 17:17:32 -0500 Subject: [PATCH 06/20] Add chat theme option --- Modules/Utils.cs | 3 +- Patches/ChatPatch.cs | 131 ++++++++++++++++++++++-------- Patches/ClientOptionsPatch.cs | 7 ++ Patches/PlayerJoinAndLeftPatch.cs | 5 +- Resources/Lang/en_US.json | 1 + main.cs | 2 + 6 files changed, 113 insertions(+), 36 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 656a84f..266aa47 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1,5 +1,6 @@ using AmongUs.Data; using AmongUs.GameOptions; +using BetterAmongUs.Patches; using InnerNet; using Sentry.Internal.Extensions; using System.Reflection; @@ -39,7 +40,6 @@ public static class Utils { pooledBubble.transform.SetParent(chat.scroller.Inner); pooledBubble.transform.localScale = Vector3.one; - pooledBubble.Background.color = new Color(0.05f, 0.05f, 0.05f, 1f); pooledBubble.SetCosmetics(data); pooledBubble.gameObject.transform.Find("PoolablePlayer").gameObject.SetActive(false); pooledBubble.ColorBlindName.gameObject.SetActive(false); @@ -63,6 +63,7 @@ public static class Utils chat.notificationRoutine = chat.StartCoroutine(chat.BounceDot()); } SoundManager.Instance.PlaySound(chat.messageSound, false, 1f, null).pitch = 0.5f + (float)data.PlayerId / 15f; + ChatPatch.ChatControllerPatch.SetChatTheme(pooledBubble); } catch (Exception ex) { diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index dea6e9e..4beaafd 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -51,41 +51,54 @@ class ChatPatch } [HarmonyPatch(typeof(ChatController))] - class ChatControllerPatch + public class ChatControllerPatch { + [HarmonyPatch(nameof(ChatController.Toggle))] + [HarmonyPostfix] + public static void Toggle_Postfix(ChatController __instance) + { + if (Main.ChatDarkMode.Value) + { + // Free chat color + __instance.freeChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); + __instance.freeChatField.textArea.compoText.Color(Color.white); + __instance.freeChatField.textArea.outputText.color = Color.white; + + // Quick chat color + __instance.quickChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); + __instance.quickChatField.text.color = Color.white; + + // Icons + __instance.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); + __instance.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); + } + else + { + // Free chat color + __instance.freeChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); + __instance.freeChatField.textArea.compoText.Color(Color.black); + __instance.freeChatField.textArea.outputText.color = Color.black; + + // Quick chat color + __instance.quickChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); + __instance.quickChatField.text.color = Color.black; + + // Icons + __instance.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); + __instance.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); + } + + foreach (var item in HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray().Select(c => c.GetComponent())) + { + SetChatTheme(item); + } + } + [HarmonyPatch(nameof(ChatController.Update))] [HarmonyPrefix] [HarmonyPriority(Priority.First)] public static void Update_Prefix(ChatController __instance) { - for (int i = 0; i < __instance.scroller.Inner.gameObject.transform.childCount; i++) - { - GameObject chatItem = __instance.scroller.Inner.transform.GetChild(i).gameObject; - - chatItem.transform.Find("ChatText (TMP)").GetComponent().color = new Color(1f, 1f, 1f, 1f); - chatItem.transform.Find("Background").GetComponent().color = new Color(0.05f, 0.05f, 0.05f, 1f); - - if (chatItem.transform.Find("PoolablePlayer/xMark") != null) - { - if (chatItem.transform.Find("PoolablePlayer/xMark").GetComponent().enabled == true) - { - chatItem.transform.Find("Background").GetComponent().color = new Color(0.05f, 0.05f, 0.05f, 0.5f); - } - } - } - - // Free chat color - __instance.freeChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); - __instance.freeChatField.textArea.compoText.Color(Color.white); - __instance.freeChatField.textArea.outputText.color = Color.white; - - // Quick chat color - __instance.quickChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); - __instance.quickChatField.text.color = Color.white; - - __instance.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); - __instance.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); - if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.X)) { ClipboardHelper.PutClipboardString(__instance.freeChatField.textArea.text); @@ -112,11 +125,8 @@ class ChatPatch [HarmonyPostfix] public static void AddChat_Postfix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText) { - ChatBubble Get() => __instance.chatBubblePool.activeChildren.ToArray() - .Select(c => c.GetComponent()) - .Last(); + ChatBubble chatBubble = SetChatTheme(); - ChatBubble chatBubble = Get(); StringBuilder sbTag = new StringBuilder(); StringBuilder sbInfo = new StringBuilder(); @@ -187,9 +197,62 @@ class ChatPatch } chatBubble.NameText.text = playerName; - chatBubble.ColorBlindName.text = $"{chatBubble.ColorBlindName.text}"; + chatBubble.ColorBlindName.color = Palette.PlayerColors[sourcePlayer.Data.DefaultOutfit.ColorId]; Logger.Log($"{sourcePlayer.Data.PlayerName} -> {chatText}", "ChatLog"); } + + [HarmonyPatch(nameof(ChatController.AddChatNote))] + [HarmonyPostfix] + public static void AddChatNote_Postfix(ChatController __instance) + { + SetChatTheme(); + } + + [HarmonyPatch(nameof(ChatController.AddChatWarning))] + [HarmonyPostfix] + public static void AddChatWarning_Postfix(ChatController __instance) + { + SetChatTheme(); + } + + // Set chat theme + public static ChatBubble SetChatTheme(ChatBubble? asChatBubble = null) + { + ChatBubble Get() => HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray() + .Select(c => c.GetComponent()) + .Last(); + + ChatBubble chatBubble = asChatBubble ??= Get(); + + if (Main.ChatDarkMode.Value) + { + chatBubble.transform.Find("ChatText (TMP)").GetComponent().color = new Color(1f, 1f, 1f, 1f); + chatBubble.transform.Find("Background").GetComponent().color = new Color(0.05f, 0.05f, 0.05f, 1f); + + if (chatBubble.transform.Find("PoolablePlayer/xMark") != null) + { + if (chatBubble.transform.Find("PoolablePlayer/xMark").GetComponent().enabled == true) + { + chatBubble.transform.Find("Background").GetComponent().color = new Color(0.05f, 0.05f, 0.05f, 0.5f); + } + } + } + else + { + chatBubble.transform.Find("ChatText (TMP)").GetComponent().color = new Color(0f, 0f, 0f, 1f); + chatBubble.transform.Find("Background").GetComponent().color = new Color(1f, 1f, 1f, 1f); + + if (chatBubble.transform.Find("PoolablePlayer/xMark") != null) + { + if (chatBubble.transform.Find("PoolablePlayer/xMark").GetComponent().enabled == true) + { + chatBubble.transform.Find("Background").GetComponent().color = new Color(1f, 1f, 1f, 0.5f); + } + } + } + + return chatBubble; + } } [HarmonyPatch(typeof(FreeChatInputField))] diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index 34d4f79..cf7bc42 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -12,6 +12,7 @@ public static class OptionsMenuBehaviourPatch private static ClientOptionItem? BetterHost; private static ClientOptionItem? BetterNotifications; private static ClientOptionItem? ForceOwnLanguage; + private static ClientOptionItem? ChatDarkMode; private static ClientOptionItem? ChatInGameplay; private static ClientOptionItem? LobbyPlayerInfo; private static ClientOptionItem? DisableLobbyTheme; @@ -85,6 +86,12 @@ public static class OptionsMenuBehaviourPatch ForceOwnLanguage = ClientOptionItem.Create(title, Main.ForceOwnLanguage, __instance); } + if (ChatDarkMode == null || ChatDarkMode.ToggleButton == null) + { + string title = Translator.GetString("BetterOption.ChatDarkMode"); + ChatDarkMode = ClientOptionItem.Create(title, Main.ChatDarkMode, __instance); + } + if (ChatInGameplay == null || ChatInGameplay.ToggleButton == null) { string title = Translator.GetString("BetterOption.ChatInGame"); diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index f0651eb..2522a5a 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -73,7 +73,10 @@ public static class OnPlayerJoinedPatch } } } - catch { } + catch (Exception ex) + { + Logger.Error(ex); + } } } diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 10085c5..1b3a6ea 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -45,6 +45,7 @@ "BetterOption.BetterHost": "Better Host", "BetterOption.BetterNotifications": "Better Notifications", "BetterOption.ForceOwnLanguage": "Force System language", + "BetterOption.ChatDarkMode": "Chat Dark Mode", "BetterOption.ChatInGame": "Chat In Gameplay", "BetterOption.LobbyInfo": "Show Lobby Info", "BetterOption.LobbyTheme": "Disable Lobby Theme", diff --git a/main.cs b/main.cs index b8ba49a..24a40f3 100644 --- a/main.cs +++ b/main.cs @@ -206,6 +206,7 @@ public class Main : BasePlugin public static ConfigEntry BetterHost { get; private set; } public static ConfigEntry BetterNotifications { get; private set; } public static ConfigEntry ForceOwnLanguage { get; private set; } + public static ConfigEntry ChatDarkMode { get; private set; } public static ConfigEntry ChatInGameplay { get; private set; } public static ConfigEntry LobbyPlayerInfo { get; private set; } public static ConfigEntry DisableLobbyTheme { get; private set; } @@ -218,6 +219,7 @@ public class Main : BasePlugin BetterHost = Config.Bind("Better Options", "BetterHost", false); BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true); ForceOwnLanguage = Config.Bind("Better Options", "ForceOwnLanguage", false); + ChatDarkMode = Config.Bind("Better Options", "ChatDarkMode", true); ChatInGameplay = Config.Bind("Better Options", "ChatInGameplay", true); LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true); DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true); From 604f4bc62afc65b6283f7dedc0ccba3c94315142 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 17:22:04 -0500 Subject: [PATCH 07/20] More translation --- Patches/PlayerJoinAndLeftPatch.cs | 4 ++-- Resources/Lang/en_US.json | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 2522a5a..9a763e7 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -68,7 +68,7 @@ public static class OnPlayerJoinedPatch if (!string.IsNullOrEmpty(player.Data.FriendCode) && text.Contains(player.Data.FriendCode) || !string.IsNullOrEmpty(Utils.GetHashPuid(player)) && text.Contains(Utils.GetHashPuid(player))) { - player.Kick(true, $"has been banned due to being on the ban player list!"); + player.Kick(true, Translator.GetString("AntiCheat.BanPlayerListMessage")); break; } } @@ -103,7 +103,7 @@ public static class OnPlayerJoinedPatch if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned) { - player.Kick(false, $"has been kicked due to their name being on the ban name list!"); + player.Kick(false, Translator.GetString("AntiCheat.BanNameListMessage")); } } catch { } diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 1b3a6ea..f89848f 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -94,6 +94,8 @@ "AntiCheat.UnauthorizedAction": "Has been detected doing an unauthorized action", "AntiCheat.ByAntiCheat": "{0} by Anti-Cheat", "AntiCheat.KickMessage": "{0}! Reason: {1}", + "AntiCheat.BanPlayerListMessage": "has been {0} due to being on the ban player list!", + "AntiCheat.BanNameListMessage": "has been {0} due to their name being on the ban name list!", "AntiCheat.HasBeenDetectedWithCheat": "Has been detected with a cheat", "AntiCheat.HasBeenDetectedWithCheat2": "Has been detected with a cheat client", "AntiCheat.InvalidAction": "Invalid Action RPC: {0}", From 8a898ffa4aa07869574e5aa7755c6b106f3d0c07 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 18:09:14 -0500 Subject: [PATCH 08/20] Fixed ban lists --- Modules/ExtendedPlayerControl.cs | 10 +++------- Modules/ExtendedPlayerInfo.cs | 1 + Patches/PlayerJoinAndLeftPatch.cs | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index cb08a60..bcd9872 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -22,12 +22,7 @@ static class ExtendedPlayerControl } } // Get players client id - public static int GetClientId(this PlayerControl player) - { - if (player == null) return -1; - var client = player.GetClient(); - return client == null ? -1 : client.Id; - } + public static int GetClientId(this PlayerControl player) => player?.GetClient()?.Id != null ? player.GetClient().Id : -1; // Get player name with outfit color public static string GetPlayerNameAndColor(this PlayerControl player) { @@ -103,7 +98,7 @@ static class ExtendedPlayerControl { var Ban = ban; - if (!GameStates.IsHost || PlayerControl.LocalPlayer == player || !player.DataIsCollected() && !bypassDataCheck || player.IsHost() || player.isDummy) + if (!GameStates.IsHost || player.IsLocalPlayer() || !player.DataIsCollected() && !bypassDataCheck || player.IsHost() || player.isDummy) { return; } @@ -125,6 +120,7 @@ static class ExtendedPlayerControl AmongUsClient.Instance.KickPlayer(player.GetClientId(), Ban); + player.BetterData().HasBeenKicked = true; player.BetterData().AntiCheatInfo.BannedByAntiCheat = AntiCheatBan; } // Set color outline on player diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs index f6351df..20c32e6 100644 --- a/Modules/ExtendedPlayerInfo.cs +++ b/Modules/ExtendedPlayerInfo.cs @@ -17,6 +17,7 @@ public static class PlayerControlDataExtension public bool IsVerifiedBetterUser { get; set; } = false; public bool IsBetterHost { get; set; } = false; public bool IsTOHEHost { get; set; } = false; + public bool HasBeenKicked { get; set; } = false; // Track Game Info public DisconnectReasons DisconnectReason { get; set; } = DisconnectReasons.Unknown; diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 9a763e7..97657cb 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -35,18 +35,19 @@ public static class OnPlayerJoinedPatch { public static void Postfix(/*AmongUsClient __instance,*/ [HarmonyArgument(0)] ClientData client) { - var player = Utils.PlayerFromClientId(client.Id); PlayerControlPatch.infotime = 0f; - if (player != null) - { - player.BetterData().ClearData(); - } - _ = new LateTask(() => { if (GameStates.IsInGame) { + var player = Utils.PlayerFromClientId(client.Id); + + if (player != null) + { + player.BetterData().ClearData(); + } + // Send Better Among Us Check RPC RPC.SendBetterCheck(); @@ -68,7 +69,7 @@ public static class OnPlayerJoinedPatch if (!string.IsNullOrEmpty(player.Data.FriendCode) && text.Contains(player.Data.FriendCode) || !string.IsNullOrEmpty(Utils.GetHashPuid(player)) && text.Contains(Utils.GetHashPuid(player))) { - player.Kick(true, Translator.GetString("AntiCheat.BanPlayerListMessage")); + player.Kick(true, Translator.GetString("AntiCheat.BanPlayerListMessage"), bypassDataCheck: true); break; } } @@ -103,7 +104,7 @@ public static class OnPlayerJoinedPatch if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned) { - player.Kick(false, Translator.GetString("AntiCheat.BanNameListMessage")); + player.Kick(false, Translator.GetString("AntiCheat.BanNameListMessage"), bypassDataCheck: true); } } catch { } @@ -139,7 +140,7 @@ class GameDataShowNotificationPatch { public static void BetterShowNotification(NetworkedPlayerInfo playerData, DisconnectReasons reason = DisconnectReasons.Unknown, string forceReasonText = "") { - if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat) return; + if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat || playerData.BetterData().HasBeenKicked) return; string playerName = playerData.BetterData().RealName; From fbb08ad38b8ab75049090271a16f9a66bbd3d85a Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 18:11:04 -0500 Subject: [PATCH 09/20] Clear AccountInfo --- Modules/ExtendedPlayerInfo.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs index 20c32e6..0658595 100644 --- a/Modules/ExtendedPlayerInfo.cs +++ b/Modules/ExtendedPlayerInfo.cs @@ -51,7 +51,8 @@ public static class PlayerControlDataExtension { _Data = BetterData._Data, RoleInfo = new ExtendedRoleInfo(), - AntiCheatInfo = new ExtendedAntiCheatInfo() + AntiCheatInfo = new ExtendedAntiCheatInfo(), + AccountInfo = new BetterAccountInfo() }; // Reset info when needed From 68ceaf1e56e60f28a55a14dff53a78cf49042f2c Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 18:40:21 -0500 Subject: [PATCH 10/20] Fix chat theme issues --- Modules/Utils.cs | 2 +- Patches/ChatPatch.cs | 92 ++++++++++++++++++++--------------- Patches/ClientOptionsPatch.cs | 7 ++- main.cs | 2 - 4 files changed, 59 insertions(+), 44 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 266aa47..024aa4b 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -63,7 +63,7 @@ public static class Utils chat.notificationRoutine = chat.StartCoroutine(chat.BounceDot()); } SoundManager.Instance.PlaySound(chat.messageSound, false, 1f, null).pitch = 0.5f + (float)data.PlayerId / 15f; - ChatPatch.ChatControllerPatch.SetChatTheme(pooledBubble); + ChatPatch.ChatControllerPatch.SetChatPoolTheme(pooledBubble); } catch (Exception ex) { diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index 4beaafd..517a20f 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -55,43 +55,9 @@ class ChatPatch { [HarmonyPatch(nameof(ChatController.Toggle))] [HarmonyPostfix] - public static void Toggle_Postfix(ChatController __instance) + public static void Toggle_Postfix(/*ChatController __instance*/) { - if (Main.ChatDarkMode.Value) - { - // Free chat color - __instance.freeChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); - __instance.freeChatField.textArea.compoText.Color(Color.white); - __instance.freeChatField.textArea.outputText.color = Color.white; - - // Quick chat color - __instance.quickChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); - __instance.quickChatField.text.color = Color.white; - - // Icons - __instance.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); - __instance.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); - } - else - { - // Free chat color - __instance.freeChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); - __instance.freeChatField.textArea.compoText.Color(Color.black); - __instance.freeChatField.textArea.outputText.color = Color.black; - - // Quick chat color - __instance.quickChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); - __instance.quickChatField.text.color = Color.black; - - // Icons - __instance.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); - __instance.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); - } - - foreach (var item in HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray().Select(c => c.GetComponent())) - { - SetChatTheme(item); - } + SetChatTheme(); } [HarmonyPatch(nameof(ChatController.Update))] @@ -99,6 +65,21 @@ class ChatPatch [HarmonyPriority(Priority.First)] public static void Update_Prefix(ChatController __instance) { + if (Main.ChatDarkMode.Value) + { + // Free chat color + __instance.freeChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); + __instance.freeChatField.textArea.compoText.Color(Color.white); + __instance.freeChatField.textArea.outputText.color = Color.white; + } + else + { + // Free chat color + __instance.freeChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); + __instance.freeChatField.textArea.compoText.Color(Color.black); + __instance.freeChatField.textArea.outputText.color = Color.black; + } + if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.X)) { ClipboardHelper.PutClipboardString(__instance.freeChatField.textArea.text); @@ -125,7 +106,7 @@ class ChatPatch [HarmonyPostfix] public static void AddChat_Postfix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText) { - ChatBubble chatBubble = SetChatTheme(); + ChatBubble chatBubble = SetChatPoolTheme(); StringBuilder sbTag = new StringBuilder(); StringBuilder sbInfo = new StringBuilder(); @@ -205,18 +186,49 @@ class ChatPatch [HarmonyPostfix] public static void AddChatNote_Postfix(ChatController __instance) { - SetChatTheme(); + SetChatPoolTheme(); } [HarmonyPatch(nameof(ChatController.AddChatWarning))] [HarmonyPostfix] public static void AddChatWarning_Postfix(ChatController __instance) { - SetChatTheme(); + SetChatPoolTheme(); + } + + public static void SetChatTheme() + { + var chat = HudManager.Instance.Chat; + + if (Main.ChatDarkMode.Value) + { + // Quick chat color + chat.quickChatField.background.color = new Color32(40, 40, 40, byte.MaxValue); + chat.quickChatField.text.color = Color.white; + + // Icons + chat.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); + chat.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(0.5f, 0.5f, 0.5f, 1f); + } + else + { + // Quick chat color + chat.quickChatField.background.color = new Color32(255, 255, 255, byte.MaxValue); + chat.quickChatField.text.color = Color.black; + + // Icons + chat.quickChatButton.transform.Find("QuickChatIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); + chat.openKeyboardButton.transform.Find("OpenKeyboardIcon").GetComponent().color = new Color(1f, 1f, 1f, 1f); + } + + foreach (var item in HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray().Select(c => c.GetComponent())) + { + SetChatPoolTheme(item); + } } // Set chat theme - public static ChatBubble SetChatTheme(ChatBubble? asChatBubble = null) + public static ChatBubble SetChatPoolTheme(ChatBubble? asChatBubble = null) { ChatBubble Get() => HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray() .Select(c => c.GetComponent()) diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index cf7bc42..b1c9d69 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -89,7 +89,12 @@ public static class OptionsMenuBehaviourPatch if (ChatDarkMode == null || ChatDarkMode.ToggleButton == null) { string title = Translator.GetString("BetterOption.ChatDarkMode"); - ChatDarkMode = ClientOptionItem.Create(title, Main.ChatDarkMode, __instance); + ChatDarkMode = ClientOptionItem.Create(title, Main.ChatDarkMode, __instance, ChatDarkModeToggle); + + static void ChatDarkModeToggle() + { + ChatPatch.ChatControllerPatch.SetChatTheme(); + } } if (ChatInGameplay == null || ChatInGameplay.ToggleButton == null) diff --git a/main.cs b/main.cs index 24a40f3..c0b34d4 100644 --- a/main.cs +++ b/main.cs @@ -3,14 +3,12 @@ using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BetterAmongUs.Patches; -using Epic.OnlineServices.Presence; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Innersloth.IO; using System.Security.Cryptography; using System.Text; using UnityEngine; -using static UnityEngine.RemoteConfigSettingsHelper; namespace BetterAmongUs; From 3354f2719f9482f36a174cc5f9691d2dc272faf9 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 18:56:18 -0500 Subject: [PATCH 11/20] Fix intro issues and re add intro skip --- Patches/SplashIntroPatch.cs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Patches/SplashIntroPatch.cs b/Patches/SplashIntroPatch.cs index 145bd1d..b3eb773 100644 --- a/Patches/SplashIntroPatch.cs +++ b/Patches/SplashIntroPatch.cs @@ -7,7 +7,6 @@ class SplashIntroPatch { public static bool BetterIntro = false; public static bool IsReallyDoneLoading = false; - private static float ShowTime = 0f; private static GameObject BetterLogo; [HarmonyPatch(typeof(SplashManager))] @@ -24,27 +23,20 @@ class SplashIntroPatch [HarmonyPrefix] public static bool Update_Prefix(SplashManager __instance) { - ShowTime += Time.deltaTime; - - if (ShowTime > 6f && BetterIntro) + if (Time.time - __instance.startTime > 2f && BetterIntro) { UnityEngine.Object.Destroy(__instance.logoAnimFinish.GetComponent()); } - /* if (Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.Mouse1)) { - if (ShowTime > 2.5f && !IsReallyDoneLoading) + if (Time.time - __instance.startTime > 2f || BetterIntro) { IsReallyDoneLoading = true; - __instance.startedSceneLoad = true; - __instance.sceneChanger.BeginLoadingScene(); __instance.sceneChanger.AllowFinishLoadingScene(); - __instance.logoAnimFinish.gameObject.SetActive(false); - __instance.loadingObject.SetActive(true); + __instance.startedSceneLoad = true; } } - */ if (__instance.doneLoadingRefdata && !__instance.startedSceneLoad && Time.time - __instance.startTime > __instance.minimumSecondsBeforeSceneChange) { @@ -55,22 +47,24 @@ class SplashIntroPatch __instance.logoAnimFinish.gameObject.SetActive(true); GameObject InnerLogo = __instance.logoAnimFinish.transform.Find("LogoRoot/ISLogo").gameObject; BetterLogo = UnityEngine.Object.Instantiate(InnerLogo, InnerLogo.transform.parent); - GameObject.Destroy(InnerLogo); + UnityEngine.Object.Destroy(InnerLogo); BetterLogo.name = "BetterLogo"; BetterLogo.GetComponent().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-By-The-Enhanced-Network-Logo.png", 150f); __instance.logoAnimFinish.transform.Find("BlackOverlay").transform.SetLocalY(0f); __instance.loadingObject.SetActive(false); + + __instance.startedSceneLoad = false; + BetterIntro = true; + return false; } - __instance.startedSceneLoad = BetterIntro; - BetterIntro = true; + __instance.startedSceneLoad = true; if (__instance.startedSceneLoad && BetterIntro) { + IsReallyDoneLoading = true; __instance.sceneChanger.AllowFinishLoadingScene(); __instance.startedSceneLoad = true; - __instance.loadingObject.SetActive(true); - IsReallyDoneLoading = true; } } From f5e5661d6709684bf1505446c28ce95ae2e39755 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 19:07:27 -0500 Subject: [PATCH 12/20] v1.1.4 Hotfix 2 --- main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cs b/main.cs index c0b34d4..6304602 100644 --- a/main.cs +++ b/main.cs @@ -25,11 +25,11 @@ public class Main : BasePlugin { public static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Release; public const string BetaNum = "0"; - public const string HotfixNum = "1"; + public const string HotfixNum = "2"; public const bool IsHotFix = true; public const string PluginGuid = "com.ten.betteramongus"; public const string PluginVersion = "1.1.4"; - public const string ReleaseDate = "09.20.2024"; // mm/dd/yyyy + public const string ReleaseDate = "09.23.2024"; // mm/dd/yyyy public const string Github = "https://github.com/EnhancedNetwork/BetterAmongUs-Public"; public const string Discord = "https://discord.gg/ten"; public static BetterAccountInfo myAccountInfo = new(); From 8fa1e678d2c147bd20a2cbe51bda71ea138014d7 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 19:09:09 -0500 Subject: [PATCH 13/20] clean up --- Modules/AntiCheat.cs | 1 - Modules/BetterDataManager.cs | 9 ++++----- Modules/DataBaseConnect.cs | 7 ++----- Modules/OptionItems/BetterOptionFloatItem.cs | 1 - Modules/OptionItems/BetterOptionPlayerItem.cs | 5 ++--- Modules/RPC.cs | 4 ++-- Modules/Translator.cs | 5 ++--- Modules/Utils.cs | 1 - Patches/ChatNotificationPatch.cs | 1 - Patches/ChatPatch.cs | 5 ++--- Patches/ClientOptionsPatch.cs | 6 +++--- Patches/ClientPatch.cs | 4 +--- Patches/CommandsPatch.cs | 1 - Patches/GamePlayManagerPatch.cs | 2 +- Patches/MatchMakerGameButtonPatch.cs | 4 ++-- Patches/PingTrackerPatch.cs | 2 +- Patches/RoleManagerPatch.cs | 1 - 17 files changed, 22 insertions(+), 37 deletions(-) diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index b4124d7..2179b55 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -3,7 +3,6 @@ using BetterAmongUs.Patches; using HarmonyLib; using Hazel; using InnerNet; -using Sentry.Internal.Extensions; namespace BetterAmongUs; diff --git a/Modules/BetterDataManager.cs b/Modules/BetterDataManager.cs index 2f4ec0c..a5f3c21 100644 --- a/Modules/BetterDataManager.cs +++ b/Modules/BetterDataManager.cs @@ -1,5 +1,4 @@ -using BetterAmongUs.Patches; -using System.Text.Json; +using System.Text.Json; namespace BetterAmongUs; @@ -198,7 +197,7 @@ class BetterDataManager return bool.Parse(jsonData[id.ToString()]); } } - catch + catch { SaveSetting(id, Default.ToString()); } @@ -219,7 +218,7 @@ class BetterDataManager return float.Parse(jsonData[id.ToString()]); } } - catch + catch { SaveSetting(id, Default.ToString()); } @@ -240,7 +239,7 @@ class BetterDataManager return int.Parse(jsonData[id.ToString()]); } } - catch + catch { SaveSetting(id, Default.ToString()); } diff --git a/Modules/DataBaseConnect.cs b/Modules/DataBaseConnect.cs index fb8c7d5..a7078c1 100644 --- a/Modules/DataBaseConnect.cs +++ b/Modules/DataBaseConnect.cs @@ -1,10 +1,7 @@ -using System; +using System.Reflection; using System.Text.Json; -using System.IO; -using System.Reflection; -using AmongUs.Data; -using IEnumerator = System.Collections.IEnumerator; using UnityEngine.Networking; +using IEnumerator = System.Collections.IEnumerator; namespace BetterAmongUs; diff --git a/Modules/OptionItems/BetterOptionFloatItem.cs b/Modules/OptionItems/BetterOptionFloatItem.cs index 39f3e5e..381f11f 100644 --- a/Modules/OptionItems/BetterOptionFloatItem.cs +++ b/Modules/OptionItems/BetterOptionFloatItem.cs @@ -1,5 +1,4 @@ using UnityEngine; -using static Il2CppSystem.Net.Http.Headers.Parser; namespace BetterAmongUs; diff --git a/Modules/OptionItems/BetterOptionPlayerItem.cs b/Modules/OptionItems/BetterOptionPlayerItem.cs index 8fb9193..36044e2 100644 --- a/Modules/OptionItems/BetterOptionPlayerItem.cs +++ b/Modules/OptionItems/BetterOptionPlayerItem.cs @@ -1,5 +1,4 @@ -using System.Dynamic; -using UnityEngine; +using UnityEngine; namespace BetterAmongUs; @@ -92,7 +91,7 @@ public class BetterOptionPlayerItem : BetterOptionItem { ThisOption.ValueText.text = Utils.PlayerFromPlayerId(CurrentIndex).GetPlayerNameAndColor(); } - else + else { ThisOption.ValueText.text = "Random"; } diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 23cf613..192a7f4 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -105,8 +105,8 @@ internal static class RPC messageWriter.WriteBytesAndSize(optionsByteArray); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); } - } - + } + public static void SendBetterCheck() { var flag = GameStates.IsHost && Main.BetterHost.Value; diff --git a/Modules/Translator.cs b/Modules/Translator.cs index 82ea4a1..818ca97 100644 --- a/Modules/Translator.cs +++ b/Modules/Translator.cs @@ -1,6 +1,5 @@ using Il2CppInterop.Runtime.InteropTypes.Arrays; using System.Globalization; -using System.Text; using System.Text.Json; using System.Text.RegularExpressions; @@ -38,11 +37,11 @@ public static class Translator { // Read the JSON file content using Stream resourceStream = assembly.GetManifestResourceStream(jsonFileName); - + if (resourceStream != null) { using StreamReader reader = new(resourceStream); - + string jsonContent = reader.ReadToEnd(); // Deserialize the JSON into a dictionary Dictionary jsonDictionary = JsonSerializer.Deserialize>(jsonContent); diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 024aa4b..480de8b 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -2,7 +2,6 @@ using AmongUs.GameOptions; using BetterAmongUs.Patches; using InnerNet; -using Sentry.Internal.Extensions; using System.Reflection; using System.Security.Cryptography; using System.Text; diff --git a/Patches/ChatNotificationPatch.cs b/Patches/ChatNotificationPatch.cs index 33a16a0..a7c7697 100644 --- a/Patches/ChatNotificationPatch.cs +++ b/Patches/ChatNotificationPatch.cs @@ -1,5 +1,4 @@ using HarmonyLib; -using TMPro; using UnityEngine; namespace BetterAmongUs.Patches; diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index 517a20f..429f046 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -1,5 +1,4 @@ -using AmongUs.Data; -using AmongUs.GameOptions; +using AmongUs.GameOptions; using Assets.CoreScripts; using HarmonyLib; using Hazel; @@ -249,7 +248,7 @@ class ChatPatch } } } - else + else { chatBubble.transform.Find("ChatText (TMP)").GetComponent().color = new Color(0f, 0f, 0f, 1f); chatBubble.transform.Find("Background").GetComponent().color = new Color(1f, 1f, 1f, 1f); diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index b1c9d69..0080c35 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -85,7 +85,7 @@ public static class OptionsMenuBehaviourPatch string title = Translator.GetString("BetterOption.ForceOwnLanguage"); ForceOwnLanguage = ClientOptionItem.Create(title, Main.ForceOwnLanguage, __instance); } - + if (ChatDarkMode == null || ChatDarkMode.ToggleButton == null) { string title = Translator.GetString("BetterOption.ChatDarkMode"); @@ -96,7 +96,7 @@ public static class OptionsMenuBehaviourPatch ChatPatch.ChatControllerPatch.SetChatTheme(); } } - + if (ChatInGameplay == null || ChatInGameplay.ToggleButton == null) { string title = Translator.GetString("BetterOption.ChatInGame"); @@ -155,7 +155,7 @@ public static class OptionsMenuBehaviourPatch } } } - + if (SwitchToVanilla == null || SwitchToVanilla.ToggleButton == null) { string title = Translator.GetString("BetterOption.ToVanilla"); diff --git a/Patches/ClientPatch.cs b/Patches/ClientPatch.cs index d27a3f8..7952d72 100644 --- a/Patches/ClientPatch.cs +++ b/Patches/ClientPatch.cs @@ -1,8 +1,6 @@ -using BepInEx.Unity.IL2CPP.Utils; -using HarmonyLib; +using HarmonyLib; using InnerNet; using UnityEngine; -using static UnityEngine.GraphicsBuffer; namespace BetterAmongUs.Patches; diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs index aa7a521..767d3d2 100644 --- a/Patches/CommandsPatch.cs +++ b/Patches/CommandsPatch.cs @@ -3,7 +3,6 @@ using AmongUs.GameOptions; using HarmonyLib; using Hazel; using Il2CppSystem.Text; -using Steamworks; using TMPro; using UnityEngine; diff --git a/Patches/GamePlayManagerPatch.cs b/Patches/GamePlayManagerPatch.cs index d89142b..256e28e 100644 --- a/Patches/GamePlayManagerPatch.cs +++ b/Patches/GamePlayManagerPatch.cs @@ -150,7 +150,7 @@ class GamePlayManager __instance.StartButton.gameObject.SetActive(true); if (__instance.startState == GameStartManager.StartingStates.Countdown) { - __instance.StartButton.buttonText.text = string.Format("{0}: {1}", Translator.GetString(StringNames.Cancel),(int)__instance.countDownTimer + 1); + __instance.StartButton.buttonText.text = string.Format("{0}: {1}", Translator.GetString(StringNames.Cancel), (int)__instance.countDownTimer + 1); } else { diff --git a/Patches/MatchMakerGameButtonPatch.cs b/Patches/MatchMakerGameButtonPatch.cs index fe60923..47f03e9 100644 --- a/Patches/MatchMakerGameButtonPatch.cs +++ b/Patches/MatchMakerGameButtonPatch.cs @@ -1,5 +1,5 @@ -using InnerNet; -using HarmonyLib; +using HarmonyLib; +using InnerNet; namespace BetterAmongUs; diff --git a/Patches/PingTrackerPatch.cs b/Patches/PingTrackerPatch.cs index 4b1e697..06db025 100644 --- a/Patches/PingTrackerPatch.cs +++ b/Patches/PingTrackerPatch.cs @@ -86,7 +86,7 @@ public class PingTrackerPatch return newPing; } - + private static string GetTimeColor(float time) { float minutes = (int)time / 60 + 1f; diff --git a/Patches/RoleManagerPatch.cs b/Patches/RoleManagerPatch.cs index 36508d9..dee21e8 100644 --- a/Patches/RoleManagerPatch.cs +++ b/Patches/RoleManagerPatch.cs @@ -1,7 +1,6 @@ using AmongUs.GameOptions; using HarmonyLib; using Hazel; -using static Il2CppSystem.Globalization.CultureInfo; namespace BetterAmongUs.Patches; From c2af4816d382efc8de3667c6eb76bc6bdf503341 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 19:40:14 -0500 Subject: [PATCH 14/20] fix Tranlation --- Patches/PlayerJoinAndLeftPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 97657cb..55dd98f 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -171,7 +171,7 @@ class GameDataShowNotificationPatch ReasonText = string.Format(Translator.GetString("DisconnectReason.Banned"), playerName, AmongUsClient.Instance.GetHost().Character.Data.PlayerName); break; case DisconnectReasons.Hacking: - ReasonText = string.Format(Translator.GetString("DisconnectReason.Disconnect"), playerName); + ReasonText = string.Format(Translator.GetString("DisconnectReason.Cheater"), playerName); break; case DisconnectReasons.Error: ReasonText = string.Format(Translator.GetString("DisconnectReason.Error"), playerName); From c8b180d1a20b51e72fe129310836778e3961ba35 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 19:51:39 -0500 Subject: [PATCH 15/20] Translation to meeting disconnect reason --- Patches/MeetingHudPatch.cs | 12 ++++++------ Resources/Lang/en_US.json | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index d9d4d7b..3554784 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -81,26 +81,26 @@ class MeetingHudUpdatePatch switch (playerData.BetterData().DisconnectReason) { case DisconnectReasons.ExitGame: - DisconnectText = "Left The Game"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.Left"); break; case DisconnectReasons.Banned: if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat) { - DisconnectText = "Banned By Anti-Cheat"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.AntiCheat"); } else { - DisconnectText = "Banned By Host"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.Banned"); } break; case DisconnectReasons.Kicked: - DisconnectText = "Kicked By Host"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.Kicked"); break; case DisconnectReasons.Hacking: - DisconnectText = "Banned By Server"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.Cheater"); break; default: - DisconnectText = "Disconnected"; + DisconnectText = Translator.GetString("DisconnectReasonMeeting.Disconnect"); break; } diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index f89848f..5506321 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -35,6 +35,13 @@ "DisconnectReason.Error": "{0} Was kicked due to an error!", "DisconnectReason.Unknown": "{0} Left the game due to unknown reason?", + "DisconnectReasonMeeting.Left": "Left The Game", + "DisconnectReasonMeeting.Disconnect": "Disconnected", + "DisconnectReasonMeeting.Kicked": "Kicked By Host", + "DisconnectReasonMeeting.Banned": "Banned By Host", + "DisconnectReasonMeeting.AntiCheat": "Banned By Anti-Cheat", + "DisconnectReasonMeeting.Cheater": "Banned By Server", + "WelcomeMsg.WelcomeToBAU": "Welcome To {0}", "WelcomeMsg.ThanksForDownloading": "Thanks for downloading!", "WelcomeMsg.BAUDescription1": "{0} Is a mod for improving the vanilla Among Us experience with a built-in {1} and other futures, {0} is a client-sided mod so it can be used with other vanilla Among Us players.", From 52f284c7b822847306589c2f545692c5d231059e Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 23:01:45 -0500 Subject: [PATCH 16/20] remove html for consoleFix kick message command --- Modules/ExtendedPlayerControl.cs | 1 - Modules/ExtendedPlayerInfo.cs | 2 +- Patches/CommandsPatch.cs | 2 +- Patches/PlayerJoinAndLeftPatch.cs | 5 +++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index bcd9872..4050df9 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -120,7 +120,6 @@ static class ExtendedPlayerControl AmongUsClient.Instance.KickPlayer(player.GetClientId(), Ban); - player.BetterData().HasBeenKicked = true; player.BetterData().AntiCheatInfo.BannedByAntiCheat = AntiCheatBan; } // Set color outline on player diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs index 0658595..bd63a22 100644 --- a/Modules/ExtendedPlayerInfo.cs +++ b/Modules/ExtendedPlayerInfo.cs @@ -17,7 +17,7 @@ public static class PlayerControlDataExtension public bool IsVerifiedBetterUser { get; set; } = false; public bool IsBetterHost { get; set; } = false; public bool IsTOHEHost { get; set; } = false; - public bool HasBeenKicked { get; set; } = false; + public bool HasShowDcMsg { get; set; } = false; // Track Game Info public DisconnectReasons DisconnectReason { get; set; } = DisconnectReasons.Unknown; diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs index 767d3d2..72968fd 100644 --- a/Patches/CommandsPatch.cs +++ b/Patches/CommandsPatch.cs @@ -281,7 +281,7 @@ class CommandsPatch if (HandleIsHost(command) == true) { var player = cmdTarget; - var cmdFlag = command[0][1..].ToLower().Trim() != "kick"; + var cmdFlag = command[0][1..].ToLower().Trim() != FormatCommandTranslation("Command.Helper.kick"); player.Kick(cmdFlag); } } diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 55dd98f..a7d1a96 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -140,9 +140,10 @@ class GameDataShowNotificationPatch { public static void BetterShowNotification(NetworkedPlayerInfo playerData, DisconnectReasons reason = DisconnectReasons.Unknown, string forceReasonText = "") { - if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat || playerData.BetterData().HasBeenKicked) return; + if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat || playerData.BetterData().HasShowDcMsg) return; + playerData.BetterData().HasShowDcMsg = true; - string playerName = playerData.BetterData().RealName; + string? playerName = playerData.BetterData().RealName; if (forceReasonText != "") { From 550aeb0f7b1db9b8e4227da2810bb9d65f46cbc6 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 23:02:13 -0500 Subject: [PATCH 17/20] Hide better host logging --- Modules/BetterHostManager.cs | 4 ++-- Modules/Debugger.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/BetterHostManager.cs b/Modules/BetterHostManager.cs index d34c8fc..36dd437 100644 --- a/Modules/BetterHostManager.cs +++ b/Modules/BetterHostManager.cs @@ -197,7 +197,7 @@ class BetterHostManager if (player.Data.PlayerName != player.CurrentOutfit.PlayerName && !player.IsInShapeshift() || force) { player.RpcSetName(player.Data.PlayerName); - Logger.Log($"Reset {player.Data.PlayerName} name", "RPC"); + Logger.LogPrivate($"Reset {player.Data.PlayerName} name", "RPC"); } return; } @@ -305,7 +305,7 @@ class BetterHostManager } player.RpcSetNamePrivate(NewName, target); - Logger.Log($"Set {player.Data.PlayerName} name to {NewName.Replace("\n", "-")} for {target.Data.PlayerName}", "RPC"); + Logger.LogPrivate($"Set {player.Data.PlayerName} name to {NewName.Replace("\n", "-")} for {target.Data.PlayerName}", "RPC"); } } } diff --git a/Modules/Debugger.cs b/Modules/Debugger.cs index e235e59..5c4a065 100644 --- a/Modules/Debugger.cs +++ b/Modules/Debugger.cs @@ -5,14 +5,14 @@ namespace BetterAmongUs; class Logger { - public static void Log(string info, string tag = "Log") + public static void Log(string info, string tag = "Log", bool logConsole = true) { string mark = $"{DateTime.Now:HH:mm} [BetterLog][{tag}]"; string logFilePath = Path.Combine(BetterDataManager.filePathFolder, "better-log.txt"); string newLine = $"{mark}: {Utils.RemoveHtmlText(info)}"; File.AppendAllText(logFilePath, newLine + Environment.NewLine); Main.Logger.LogInfo($"[{tag}] {info}"); - ConsoleManager.ConsoleStream.WriteLine($"{DateTime.Now:HH:mm} BetterAmongUs[{tag}]: {info}"); + if (logConsole) ConsoleManager.ConsoleStream.WriteLine($"{DateTime.Now:HH:mm} BetterAmongUs[{tag}]: {Utils.RemoveHtmlText(info)}"); } public static void LogHeader(string info, string tag = "LogHeader") => Log($" >-------------- {info} --------------<", tag); public static void LogCheat(string info, string tag = "AntiCheat") => Log(info, tag); From e27a99ce72f62593d7be651bb7d4a2c91e684d49 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 23:11:36 -0500 Subject: [PATCH 18/20] fix SendChatNote anticheat --- Modules/AntiCheat.cs | 9 ++------- Modules/ExtendedPlayerInfo.cs | 6 ------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 2179b55..b458b5a 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -625,15 +625,10 @@ class AntiCheat _ = reader.ReadByte(); var type = reader.ReadByte(); - if (!GameStates.IsMeeting || (ChatNoteTypes)type == ChatNoteTypes.DidVote && player.BetterData().AntiCheatInfo.ChatDidVote) + if (!GameStates.IsMeeting || !Enum.IsDefined(typeof(ChatNoteTypes), type)) { BetterNotificationManager.NotifyCheat(player, string.Format(Translator.GetString("AntiCheat.InvalidActionRPC"), Enum.GetName((RpcCalls)callId))); - Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {!GameStates.IsMeeting} || {(ChatNoteTypes)type == ChatNoteTypes.DidVote} && {player.BetterData().AntiCheatInfo.ChatDidVote}"); - } - - if ((ChatNoteTypes)type == ChatNoteTypes.DidVote) - { - player.BetterData().AntiCheatInfo.ChatDidVote = true; + Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {!GameStates.IsMeeting} || {!Enum.IsDefined(typeof(ChatNoteTypes), type)}"); } } diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs index bd63a22..ba88e8d 100644 --- a/Modules/ExtendedPlayerInfo.cs +++ b/Modules/ExtendedPlayerInfo.cs @@ -28,7 +28,6 @@ public static class PlayerControlDataExtension public class ExtendedAntiCheatInfo { public bool BannedByAntiCheat { get; set; } = false; - public bool ChatDidVote { get; set; } = false; public List AUMChats { get; set; } = []; public int TimesAttemptedKilled { get; set; } = 0; public int OpenSabotageNum { get; set; } = 0; @@ -78,11 +77,6 @@ public static class PlayerControlDataExtension player.BetterData().RoleInfo.DeadDisplayRole = player.Data.RoleType; } - if (!GameStates.IsMeeting) - { - player.BetterData().AntiCheatInfo.ChatDidVote = false; - } - if (string.IsNullOrEmpty(player.BetterData().RealName)) { player.BetterData().RealName = player.Data.PlayerName; From de88ec822e98854599ccec62327f9c8840582d83 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 23:13:12 -0500 Subject: [PATCH 19/20] oops --- Patches/MeetingHudPatch.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 3554784..db93568 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -204,19 +204,6 @@ class MeetingHudUpdatePatch } } -[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.ClearVote))] -class MeetingHud_ClearVotePatch -{ - public static void Postfix() - { - // Clear info for Anti-Cheat - foreach (var player in Main.AllPlayerControls) - { - player.BetterData().AntiCheatInfo.ChatDidVote = false; - } - } -} - [HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.OnDestroy))] class MeetingHud_OnDestroyPatch { From 9ecb3a1dae8ed9bca1bbbb09722604d050a06bbc Mon Sep 17 00:00:00 2001 From: D1GQ Date: Mon, 23 Sep 2024 23:14:36 -0500 Subject: [PATCH 20/20] v1.1.4 Hotfix 3 --- main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cs b/main.cs index 6304602..f2138e3 100644 --- a/main.cs +++ b/main.cs @@ -25,7 +25,7 @@ public class Main : BasePlugin { public static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Release; public const string BetaNum = "0"; - public const string HotfixNum = "2"; + public const string HotfixNum = "3"; public const bool IsHotFix = true; public const string PluginGuid = "com.ten.betteramongus"; public const string PluginVersion = "1.1.4";