using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.NoUnlockSpam")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.NoUnlockSpam")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2F78A585-A698-4151-A709-544F43B518D8")] [assembly: AssemblyFileVersion("0.1.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VentureValheim.NoUnlockSpam { [BepInPlugin("com.orianaventure.mod.NoUnlockSpam", "NoUnlockSpam", "0.1.1")] public class NoUnlockSpamPlugin : BaseUnityPlugin { private const string ModName = "NoUnlockSpam"; private const string ModVersion = "0.1.1"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.NoUnlockSpam"; private static string ConfigFileName = "com.orianaventure.mod.NoUnlockSpam.cfg"; private static string ConfigFileFullPath; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.NoUnlockSpam"); public static readonly ManualLogSource NoUnlockSpamLogger; public static ConfigEntry CE_NotificationsEnabled; private static ConfigEntry CE_ToggleKey; private DateTime _lastReloadTime; private const long RELOAD_DELAY = 10000000L; public static bool GetNotificationsEnabled() { return CE_NotificationsEnabled.Value; } public static KeyCode GetToggleKey() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return CE_ToggleKey.Value; } private void AddConfig(string key, string section, string description, bool synced, T value, ref ConfigEntry configEntry) { string extendedDescription = GetExtendedDescription(description, synced); configEntry = ((BaseUnityPlugin)this).Config.Bind(section, key, value, extendedDescription); } public string GetExtendedDescription(string description, bool synchronizedSetting) { return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); } private void Awake() { NoUnlockSpamLogger.LogInfo((object)"Okay, we get it."); AddConfig("NotificationsEnabled", "General", "False to disable all unlock notifications (boolean).", synced: false, value: true, ref CE_NotificationsEnabled); AddConfig("ToggleKey", "General", "Keycode to dismiss the queued unlock notifications (Unity.KeyCode).", synced: false, (KeyCode)117, ref CE_ToggleKey); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { _lastReloadTime = DateTime.Now; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { DateTime now = DateTime.Now; long num = now.Ticks - _lastReloadTime.Ticks; if (File.Exists(ConfigFileFullPath) && num >= 10000000) { try { NoUnlockSpamLogger.LogInfo((object)"Attempting to reload configuration..."); ((BaseUnityPlugin)this).Config.Reload(); } catch { NoUnlockSpamLogger.LogError((object)("There was an issue loading " + ConfigFileName)); return; } _lastReloadTime = now; } } static NoUnlockSpamPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; NoUnlockSpamLogger = Logger.CreateLogSource("NoUnlockSpam"); CE_NotificationsEnabled = null; CE_ToggleKey = null; } } public class NoUnlockSpam { [HarmonyPatch(typeof(MessageHud), "UpdateUnlockMsg")] public static class Patch_MessageHud_UpdateUnlockMsg { private static void Prefix(MessageHud __instance) { if (__instance.m_unlockMsgQueue.Count > 0 && (HotkeyPressed || !NoUnlockSpamPlugin.GetNotificationsEnabled())) { __instance.m_unlockMsgQueue.Clear(); NoUnlockSpamPlugin.NoUnlockSpamLogger.LogDebug((object)"Clearing messages!"); } HotkeyPressed = false; } } [HarmonyPatch(typeof(Player))] private static class PlayerPatch { [HarmonyTranspiler] [HarmonyPatch(typeof(Player), "Update")] private static IEnumerable UpdateTranspiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Player), "UpdateHover", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Player.Update()!") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "UpdateInputDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void UpdateInputDelegate(Player player, bool takeInput) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (takeInput && ZInput.GetKeyDown(NoUnlockSpamPlugin.GetToggleKey(), true)) { HotkeyPressed = true; } } } public static bool HotkeyPressed; } }