Decompiled source of CentralConfigCrashFix v1.0.1

BepInEx/Plugins/CentralConfigCrashFixOnQuit.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CentralConfigCrashFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CentralConfigCrashFix")]
[assembly: AssemblyTitle("CentralConfigCrashFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("fix.centralconfig.crashonquit", "CentralConfig Crash Fix", "1.0.0")]
public class CentralConfigCrashFixOnQuit : BaseUnityPlugin
{
	[HarmonyPatch]
	public static class SafeDisconnectPatch
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("CentralConfig.ResetChanger+ResetOnDisconnect");
			if (type != null)
			{
				return AccessTools.Method(type, "Prefix", (Type[])null, (Type[])null);
			}
			return null;
		}

		private static bool Prefix()
		{
			try
			{
				Type type = AccessTools.TypeByName("CentralConfig.ResetChanger");
				if (type == null)
				{
					Debug.LogWarning((object)"CentralConfig.ResetChanger not found.");
					return true;
				}
				return true;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[CentralConfigCrashFix] Exception in Prefix: " + ex));
				return false;
			}
		}
	}

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("fix.centralconfig.crashonquit");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"CentralConfig crash fix loaded.");
	}
}