Decompiled source of NoPopUpsInMyValheim v1.0.0

NoPopUpsInMyValheim.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.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
{
	[BepInPlugin("IAmOnTheInternetAndItIsScary.NoPopUpsInMyValheim", "NoPopUpsInMyValheim", "1.0.0")]
	public class NoPopUpsInMyValheimPlugin : BaseUnityPlugin
	{
		internal const string ModName = "NoPopUpsInMyValheim";

		internal const string ModGUID = "IAmOnTheInternetAndItIsScary.NoPopUpsInMyValheim";

		internal const string ModVersion = "1.0.0";

		internal static readonly ManualLogSource Log = Logger.CreateLogSource("NoPopUpsInMyValheim");

		public void Awake()
		{
			Silencer.Start();
		}
	}
	internal sealed class Target
	{
		public readonly string TypeName;

		public readonly string MethodName;

		public readonly string Description;

		public Target(string typeName, string methodName, string description)
		{
			TypeName = typeName;
			MethodName = methodName;
			Description = description;
		}
	}
	internal static class Silencer
	{
		private static readonly Target[] Targets = new Target[8]
		{
			new Target("Vapok.Common.Managers.Telemetry.TelemetryManager", "SendEventsAsync", "telemetry and error reports"),
			new Target("Vapok.Common.Managers.Splash.ModSplashManager", "CheckAndQueueStartupSplashes", "startup splash screen"),
			new Target("EpicLoot.WelcomeMessage_FejdStartup_Start_Patch", "ShowWelcomeMessage", "welcome message"),
			new Target("EpicLoot.ConfigUpdatePrompt_FejdStartup_Start_Patch", "ShowConfigMessage", "config update prompt"),
			new Target("TrollTamerMod.TitleMessage", "FejdStartup_Start_TitleMessage", "title screen message"),
			new Target("Artisan_Mastery.ConfigVersionManager", "TryShowPrompt", "config reset prompt"),
			new Target("Hunter_Legacy.ConfigVersionManager", "TryShowPrompt", "config reset prompt"),
			new Target("Magic_Supremacy.ConfigVersionManager", "TryShowPrompt", "config reset prompt")
		};

		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));

		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;
			}
			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)
						{
							NoPopUpsInMyValheimPlugin.Log.LogWarning((object)(assembly.GetName().Name + ": " + target.TypeName + "." + target.MethodName + " not found, the " + target.Description + " may still be active"));
						}
						else
						{
							HarmonyInstance.Patch((MethodBase)methodInfo, SkipPrefix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							NoPopUpsInMyValheimPlugin.Log.LogInfo((object)("✓ " + assembly.GetName().Name + ": " + target.Description + " disabled"));
						}
					}
				}
				catch (Exception ex)
				{
					NoPopUpsInMyValheimPlugin.Log.LogError((object)(assembly.GetName().Name + ": could not disable the " + target.Description + ": " + ex.Message));
				}
			}
		}

		private static bool Skip()
		{
			return false;
		}
	}
}