using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NoPopUpsInMyValheim")] [assembly: AssemblyDescription("Disables mod telemetry and error reporting, and the popups mods show on the main menu")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NoPopUpsInMyValheim")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("907927bb-eac7-405e-878f-82ebf80d4673")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NoPopUpsInMyValheim { public static class Patcher { internal const string ModName = "NoPopUpsInMyValheim"; internal const string ModGUID = "IAmOnTheInternetAndItIsScary.NoPopUpsInMyValheim"; internal static readonly ManualLogSource Log = Logger.CreateLogSource("NoPopUpsInMyValheim"); public static IEnumerable TargetDLLs { get; } = Array.Empty(); public static void Patch(AssemblyDefinition assembly) { } public static void Finish() { Silencer.Start(); } } internal sealed class Target { public readonly string TypeName; public readonly string MethodName; public readonly string Description; public readonly HarmonyMethod Prefix; public Target(string typeName, string methodName, string description, HarmonyMethod prefix) { TypeName = typeName; MethodName = methodName; Description = description; Prefix = prefix; } } internal static class Silencer { private static readonly Harmony HarmonyInstance = new Harmony("IAmOnTheInternetAndItIsScary.NoPopUpsInMyValheim"); private static readonly HarmonyMethod SkipPrefix = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Silencer), "Skip", (Type[])null, (Type[])null)); private static readonly HarmonyMethod SkipDifficultyWindowPrefix = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Silencer), "SkipDifficultyWindow", (Type[])null, (Type[])null)); private static readonly HashSet Silenced = new HashSet(); private static readonly Target[] Targets = new Target[10] { new Target("Vapok.Common.Tools.DynamicPatches", "Patch", "patch remover", SkipPrefix), new Target("Vapok.Common.Managers.Telemetry.TelemetryManager", "SendEventsAsync", "telemetry and error reports", SkipPrefix), new Target("Vapok.Common.Managers.Splash.ModSplashManager", "CheckAndQueueStartupSplashes", "startup splash screen", SkipPrefix), new Target("EpicLoot.WelcomeMessage_FejdStartup_Start_Patch", "ShowWelcomeMessage", "welcome message", SkipPrefix), new Target("EpicLoot.ConfigUpdatePrompt_FejdStartup_Start_Patch", "ShowConfigMessage", "config update prompt", SkipPrefix), new Target("TrollTamerMod.TitleMessage", "FejdStartup_Start_TitleMessage", "title screen message", SkipPrefix), new Target("Artisan_Mastery.ConfigVersionManager", "TryShowPrompt", "config reset prompt", SkipPrefix), new Target("Hunter_Legacy.ConfigVersionManager", "TryShowPrompt", "config reset prompt", SkipPrefix), new Target("Magic_Supremacy.ConfigVersionManager", "TryShowPrompt", "config reset prompt", SkipPrefix), new Target("CaptainSkillTree.Plugin+FejdStartup_DifficultyPatch", "ShowDifficultyUI", "difficulty selection window", SkipDifficultyWindowPrefix) }; public static void Start() { AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Silence(assemblies[i]); } } private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args) { Silence(args.LoadedAssembly); } private static void Silence(Assembly assembly) { if (assembly.IsDynamic) { return; } lock (Silenced) { if (!Silenced.Add(assembly)) { return; } } Target[] targets = Targets; foreach (Target target in targets) { try { Type type = assembly.GetType(target.TypeName, throwOnError: false); if (!(type == null)) { MethodInfo methodInfo = AccessTools.DeclaredMethod(type, target.MethodName, (Type[])null, (Type[])null); if (methodInfo == null) { Patcher.Log.LogWarning((object)(assembly.GetName().Name + ": " + target.TypeName + "." + target.MethodName + " not found, the " + target.Description + " may still be active")); } else { HarmonyInstance.Patch((MethodBase)methodInfo, target.Prefix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Patcher.Log.LogInfo((object)("✓ " + assembly.GetName().Name + ": " + target.Description + " disabled")); } } } catch (Exception ex) { Patcher.Log.LogError((object)(assembly.GetName().Name + ": could not disable the " + target.Description + ": " + ex.Message)); } } } private static bool Skip() { return false; } private static bool SkipDifficultyWindow(MethodBase __originalMethod) { AccessTools.DeclaredMethod(__originalMethod.DeclaringType?.Assembly.GetType("CaptainSkillTree.DifficultyManager", throwOnError: false), "ApplyFallbackDefault", (Type[])null, (Type[])null)?.Invoke(null, null); return false; } } }