From 016ad4ba068345b306d3c3dc65fbeefa8371e50a Mon Sep 17 00:00:00 2001 From: Ape <155788660+ApeMV@users.noreply.github.com> Date: Tue, 13 Jan 2026 16:26:43 +0100 Subject: [PATCH] DenyName, Many SnS fixes, Gamemode behavior change --- AmongUsRevamped.cs | 2 +- Modules/BanManager.cs | 6 ++++ Modules/CustomOptionsHolder.cs | 4 ++- Modules/Utils.cs | 51 +++++++++++++++++++++++++++++++++ Patches/CredentialsPatch.cs | 7 +---- Patches/EndGamePatches.cs | 9 ++---- Patches/JoinAndLeavePatches.cs | 2 ++ Patches/PlayerControlPatches.cs | 11 ++++--- 8 files changed, 73 insertions(+), 19 deletions(-) diff --git a/AmongUsRevamped.cs b/AmongUsRevamped.cs index b632346..04a190b 100644 --- a/AmongUsRevamped.cs +++ b/AmongUsRevamped.cs @@ -29,7 +29,7 @@ public partial class Main : BasePlugin public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null; public static bool HasArgumentException; public static string CredentialsText; - public const string ModVersion = "v1.1.0"; + public const string ModVersion = "v1.1.1"; public static float GameTimer; diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs index 1f69990..65943ee 100644 --- a/Modules/BanManager.cs +++ b/Modules/BanManager.cs @@ -12,6 +12,7 @@ namespace AmongUsRevamped; public static class BanManager { public static string RemoveHtmlTags(this string str) => Regex.Replace(str, "<[^>]*?>", ""); + private static readonly string DenyNameListPath = "./AUR-DATA/DenyNameList.txt"; private static string BanListPath = "./AUR-DATA/BanList.txt"; private static string ModeratorListPath = "./AUR-DATA/ModeratorList.txt"; public static List TempBanWhiteList = []; @@ -21,6 +22,11 @@ public static class BanManager { Directory.CreateDirectory("AUR-DATA"); + if (!File.Exists(DenyNameListPath)) + { + Logger.Warn("Creating a new DenyNameList.txt file", "BanManager"); + File.Create(DenyNameListPath).Close(); + } if (!File.Exists(BanListPath)) { Logger.Warn("Creating a new BanList.txt file", "BanManager"); diff --git a/Modules/CustomOptionsHolder.cs b/Modules/CustomOptionsHolder.cs index eaf7fb0..77334e6 100644 --- a/Modules/CustomOptionsHolder.cs +++ b/Modules/CustomOptionsHolder.cs @@ -38,6 +38,7 @@ namespace AmongUsRevamped public static OptionItem TempBanInvalidFriendCodes; public static OptionItem ApplyBanList; + public static OptionItem ApplyDenyNameList; public static OptionItem ApplyModeratorList; public static OptionItem AutoRejoinLobby; @@ -202,7 +203,8 @@ namespace AmongUsRevamped .SetParent(KickInvalidFriendCodes); ApplyBanList = BooleanOptionItem.Create(60110, "Apply BanList", true, TabGroup.SystemSettings, true); - ApplyModeratorList = BooleanOptionItem.Create(60120, "Apply ModeratorList", true, TabGroup.SystemSettings, false); + ApplyDenyNameList = BooleanOptionItem.Create(60120, "Apply DenyName List", true, TabGroup.SystemSettings, false); + ApplyModeratorList = BooleanOptionItem.Create(60121, "Apply Moderator List", true, TabGroup.SystemSettings, false); AutoRejoinLobby = BooleanOptionItem.Create(60210, "Auto Rejoin Lobby", false, TabGroup.SystemSettings, false); AutoStartTimer = IntegerOptionItem.Create(44420, "Countdown For Auto Start", new(1, 600, 1), 5, TabGroup.SystemSettings, false) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 69de414..75d073d 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -25,6 +25,8 @@ public static class Utils public static long TimeStamp => EpochStartSeconds + (long)Stopwatch.Elapsed.TotalSeconds; + public static int allAlivePlayersCount => AllAlivePlayerControls.Count(); + public static bool IsLobby => AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Joined; public static bool InGame => AmongUsClient.Instance && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started; public static bool isHideNSeek => GameOptionsManager.Instance.CurrentGameOptions.GameMode == GameModes.HideNSeek; @@ -50,6 +52,23 @@ public static class Utils return friendCodes.Any(code => code.Contains(friendCode)); } + public static bool IsPlayerInDenyName(ClientData client, string name) + { + if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false; + + var denyNameFilePath = @"./AUR-DATA/DenyNameList.txt"; + var deniedNames = File.ReadAllLines(denyNameFilePath); + + if (deniedNames.Where(code => !string.IsNullOrWhiteSpace(code)).Any(code => name.Contains(code, StringComparison.OrdinalIgnoreCase))) + { + AmongUsClient.Instance.KickPlayer(client.Id, false); + Logger.Info($" {name} was kicked because their name was in DenyNameList.txt", "Kick"); + Logger.SendInGame($" {name} was kicked because their name was in DenyNameList.txt"); + return true; + } + else return false; + } + public static string GetTabName(TabGroup tab) { switch (tab) @@ -171,4 +190,36 @@ public static class Utils try { return AmongUsClient.Instance.allClients.ToArray().FirstOrDefault(cd => cd.Id == id); } catch { return null; } } + + public static void ClearLeftoverData() + { + RpcSetTasksPatch.GlobalTaskIds = null; + HandlingGameEnd = false; + OnGameJoinedPatch.AutoStartCheck = false; + Main.GameTimer = 0f; + MurderPlayerPatch.misfireCount.Clear(); + LateTask.Tasks.Clear(); + } + + public static PlayerControl[] AllAlivePlayerControls + { + get + { + int count = PlayerControl.AllPlayerControls.Count; + var result = new PlayerControl[count]; + var i = 0; + + foreach (PlayerControl pc in PlayerControl.AllPlayerControls) + { + if (pc == null || pc.Data == null || pc.PlayerId >= 254 || pc.Data.IsDead || (pc.Data.Disconnected)) continue; + + result[i++] = pc; + } + + if (i == 0) return []; + + Array.Resize(ref result, i); + return result; + } + } } \ No newline at end of file diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index dc908fd..9faa989 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -51,12 +51,7 @@ namespace AmongUsRevamped { private static void Postfix(VersionShower __instance) { - RpcSetTasksPatch.GlobalTaskIds = null; - Utils.HandlingGameEnd = false; - OnGameJoinedPatch.AutoStartCheck = false; - Main.GameTimer = 0f; - MurderPlayerPatch.misfireCount.Clear(); - LateTask.Tasks.Clear(); + Utils.ClearLeftoverData(); Main.CredentialsText = $"Among Us Revamped {Main.ModVersion}"; diff --git a/Patches/EndGamePatches.cs b/Patches/EndGamePatches.cs index 3482f7f..9a24af6 100644 --- a/Patches/EndGamePatches.cs +++ b/Patches/EndGamePatches.cs @@ -10,12 +10,7 @@ public static class EndGameManagerPatch { public static void Postfix(EndGameManager __instance) { - RpcSetTasksPatch.GlobalTaskIds = null; - Utils.HandlingGameEnd = false; - OnGameJoinedPatch.AutoStartCheck = false; - Main.GameTimer = 0f; - MurderPlayerPatch.misfireCount.Clear(); - LateTask.Tasks.Clear(); + Utils.ClearLeftoverData(); EndGameNavigation navigation = __instance.Navigation; if (!AmongUsClient.Instance.AmHost || __instance == null || navigation == null || !Options.AutoRejoinLobby.GetBool()) return; @@ -28,7 +23,7 @@ class NormalGameEndChecker { public static bool Prefix() { - if (Options.NoGameEnd.GetBool() || Options.Gamemode.GetValue() == 3) return false; + if (Options.NoGameEnd.GetBool() || Options.Gamemode.GetValue() == 3 || Options.Gamemode.GetValue() == 2 && Main.NormalOptions.NumImpostors*2 < Utils.allAlivePlayersCount ) return false; else return true; } } diff --git a/Patches/JoinAndLeavePatches.cs b/Patches/JoinAndLeavePatches.cs index f76d6ea..2a0ee0e 100644 --- a/Patches/JoinAndLeavePatches.cs +++ b/Patches/JoinAndLeavePatches.cs @@ -56,6 +56,8 @@ class OnPlayerJoinedPatch { BanManager.CheckBanPlayer(Client); + Utils.IsPlayerInDenyName(Client, Client.PlayerName); + if (Utils.IsPlayerModerator(Client.FriendCode) && Options.ApplyModeratorList.GetBool()) { Logger.Info($" {Client.PlayerName} is moderator", "ModeratorCheck"); diff --git a/Patches/PlayerControlPatches.cs b/Patches/PlayerControlPatches.cs index 154148e..e1ca819 100644 --- a/Patches/PlayerControlPatches.cs +++ b/Patches/PlayerControlPatches.cs @@ -3,6 +3,7 @@ using AmongUs.GameOptions; using Hazel; using InnerNet; using System; +using UnityEngine; namespace AmongUsRevamped; [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))] @@ -12,12 +13,14 @@ class FixedUpdateInGamePatch { if (__instance == null || __instance.PlayerId == 255) return; + GameObject g = GameObject.Find("GameSettingsLabel"); + // 0Kc if (Options.Gamemode.GetValue() == 1 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 0.01f) { Main.NormalOptions.KillCooldown = 0.01f; - if (Options.NoKcdSettingsOverride.GetBool()) + if (Options.NoKcdSettingsOverride.GetBool() && g == null) { Main.NormalOptions.EmergencyCooldown = 0; Main.NormalOptions.DiscussionTime = 0; @@ -35,7 +38,7 @@ class FixedUpdateInGamePatch { Main.NormalOptions.KillCooldown = 2.5f; - if (Options.SNSSettingsOverride.GetBool()) + if (Options.SNSSettingsOverride.GetBool() && g == null) { Main.NormalOptions.NumEmergencyMeetings = 0; @@ -48,7 +51,7 @@ class FixedUpdateInGamePatch } // Speedrun - if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek) + if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek && g == null) { Main.NormalOptions.NumEmergencyMeetings = 0; @@ -149,7 +152,7 @@ internal static class MurderPlayerPatch if (!__instance.Data.IsDead) {__instance.RpcSetRole(RoleTypes.Shapeshifter, false);} }, Options.CantKillTime.GetInt(), "SNSResetRole"); - if (misfireCount[__instance.Data.PlayerId] >= Options.MisfiresToSuicide.GetValue()) + if (misfireCount[__instance.Data.PlayerId] >= Options.MisfiresToSuicide.GetFloat()) { __instance.RpcSetRole(RoleTypes.ImpostorGhost); Logger.Info($" {__instance.Data.PlayerName} misfired {misfireCount[playerId]} times and suicided", "SNSKillManager");