Decompiled source of BirdheimVeinMiningCompat v1.0.2

plugins/BirdheimVeinMiningCompat.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BirdheimVeinMiningCompat;

[BepInPlugin("lupsy.valheim.birdheimveinminingcompat", "Birdheim VeinMining Compat", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	private void Awake()
	{
		try
		{
			Type type = AccessTools.TypeByName("Birdheim.LoadingGuard");
			if (type == null)
			{
				type = AccessTools.TypeByName("LoadingGuard");
			}
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find Birdheim's LoadingGuard class.");
				return;
			}
			FieldInfo fieldInfo = AccessTools.Field(type, "Known");
			ICollection<string> collection = ((fieldInfo != null) ? (fieldInfo.GetValue(null) as ICollection<string>) : null);
			if (collection != null)
			{
				if (!collection.Contains("local.valheim.sharedmining"))
				{
					collection.Add("local.valheim.sharedmining");
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully added Vein Mining (local.valheim.sharedmining) to Birdheim's LoadingGuard whitelist.");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not read the 'Known' field in Birdheim's LoadingGuard.");
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Failed to patch Birdheim's LoadingGuard whitelist: " + ex.ToString()));
		}
	}
}