Decompiled source of BetterZeeLog v1.11.0

BetterZeeLog.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 ComfyLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterZeeLog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterZeeLog")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d1094b63-ab04-4330-b85e-d68e855e2e04")]
[assembly: AssemblyFileVersion("1.11.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.11.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ComfyLib
{
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public bool? HideSettingName;

			public bool? IsAdvanced;

			public int? Order;

			public bool? ReadOnly;
		}

		private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();

		private static int GetSettingOrder(string section)
		{
			if (!_sectionToSettingOrder.TryGetValue(section, out var value))
			{
				value = 0;
			}
			_sectionToSettingOrder[section] = value - 1;
			return value;
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = null,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = customDrawer,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
		{
			configEntry.SettingChanged += delegate
			{
				settingChangedHandler();
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
}
namespace BetterZeeLog
{
	[BepInPlugin("redseiko.valheim.betterzeelog", "BetterZeeLog", "1.11.0")]
	public sealed class BetterZeeLog : BaseUnityPlugin
	{
		public const string PluginGUID = "redseiko.valheim.betterzeelog";

		public const string PluginName = "BetterZeeLog";

		public const string PluginVersion = "1.11.0";

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			if (PluginConfig.IsModEnabled.Value)
			{
				Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.betterzeelog");
				if (PluginConfig.RemoveStackTraceForNonErrorLogType.Value)
				{
					Application.SetStackTraceLogType((LogType)3, (StackTraceLogType)0);
					Application.SetStackTraceLogType((LogType)2, (StackTraceLogType)0);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Container))]
	internal static class ContainerPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch("RPC_RequestOpen")]
		private static IEnumerable<CodeInstruction> RPC_RequestOpenTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			Label label = default(Label);
			if (PluginConfig.RemoveContainerRequestOpenLogging.Value)
			{
				return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Container), "m_nview"), (string)null)
				}).ThrowIfInvalid("Could not patch Container.RPC_RequestOpen()! (is-owner)")
					.CreateLabel(ref label)
					.Start()
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Br, (object)label)
					})
					.MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
					{
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)"  but im not the owner")),
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null)))
					})
					.ThrowIfInvalid("Could not patch Container.RPC_RequestOpen()! (not-owner-log)")
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
					{
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)"  in use")),
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null)))
					})
					.ThrowIfInvalid("Could not patch Container.RPC_RequestOpen()! (in-use-log)")
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
					{
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)"  not yours")),
						CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null)))
					})
					.ThrowIfInvalid("Could not patch Container.RPC_RequestOpen()! (not-yours-log)")
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null))
					.InstructionEnumeration();
			}
			return instructions;
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	internal static class ProjectilePatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch("FixedUpdate")]
		private static IEnumerable<CodeInstruction> FixedUpdateTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			if (PluginConfig.CheckProjectFixedUpdateZeroVelocity.Value)
			{
				return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Projectile), "m_vel"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Quaternion), "LookRotation", new Type[1] { typeof(Vector3) }, (Type[])null), (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Transform), "rotation"), (string)null)
				}).ThrowIfInvalid("Could not patch Projectile.FixedUpdate()! (LookRotation)")
					.Advance(1)
					.SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<Vector3, Quaternion>>((Func<Vector3, Quaternion>)LookRotationDelegate))
					.InstructionEnumeration();
			}
			return instructions;
		}

		private static Quaternion LookRotationDelegate(Vector3 velocity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (velocity == Vector3.zero)
			{
				return Quaternion.identity;
			}
			return Quaternion.LookRotation(velocity);
		}
	}
	[HarmonyPatch(typeof(UIGroupHandler))]
	internal static class UIGroupHandlerPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			Label label = default(Label);
			Label label2 = default(Label);
			return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null)
			}).ThrowIfInvalid("Could not patch UIGroupHandler.Update()! (Log-Right-Stick)")
				.Advance(1)
				.CreateLabel(ref label)
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null)
				})
				.ThrowIfInvalid("Could not patch UIGroupHandler.Update()! (Log-Default)")
				.Advance(1)
				.CreateLabel(ref label2)
				.Start()
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Activating right stick element ", (string)null)
				})
				.ThrowIfInvalid("Could not patch UIGroupHandler.Update()! (Ldstr-Right-Stick)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					Transpilers.EmitDelegate<Func<bool>>((Func<bool>)ShouldLogDelegate),
					new CodeInstruction(OpCodes.Brfalse, (object)label)
				})
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Activating default element ", (string)null)
				})
				.ThrowIfInvalid("Could not patch UIGroupHandler.Update()! (Ldstr-Default)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					Transpilers.EmitDelegate<Func<bool>>((Func<bool>)ShouldLogDelegate),
					new CodeInstruction(OpCodes.Brfalse, (object)label2)
				})
				.InstructionEnumeration();
		}

		private static bool ShouldLogDelegate()
		{
			return !PluginConfig.IsModEnabled.Value;
		}
	}
	[HarmonyPatch(typeof(ZLog))]
	internal static class ZLogPatch
	{
		private static string DateTimeNowDelegate(string dateTimeNow)
		{
			return "[" + dateTimeNow + "] ";
		}

		[HarmonyPrefix]
		[HarmonyPatch("Log")]
		private static bool LogPrefix(ref object o)
		{
			if (o is string text && text.StartsWith("Console: ", StringComparison.Ordinal))
			{
				return false;
			}
			return true;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Log")]
		private static IEnumerable<CodeInstruction> LogTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null)
			}).ThrowIfInvalid("Could not patch ZLog.Log()! (colon)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) })
				.SetOperandAndAdvance((object)string.Empty)
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null)
				})
				.ThrowIfInvalid("Could not patch ZLog.Log()! (newline)")
				.SetOperandAndAdvance((object)string.Empty)
				.InstructionEnumeration();
		}

		[HarmonyTranspiler]
		[HarmonyPatch("LogWarning")]
		private static IEnumerable<CodeInstruction> LogWarningTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null)
			}).ThrowIfInvalid("Could not patch ZLog.LogWarning()! (colon)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) })
				.SetOperandAndAdvance((object)string.Empty)
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null)
				})
				.ThrowIfInvalid("Could not patch ZLog.LogWarning()! (newline)")
				.SetOperandAndAdvance((object)string.Empty)
				.InstructionEnumeration();
		}

		[HarmonyTranspiler]
		[HarmonyPatch("LogError")]
		private static IEnumerable<CodeInstruction> LogErrorTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null)
			}).ThrowIfInvalid("Could not patch ZLog.LogError()! (colon)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) })
				.SetOperandAndAdvance((object)string.Empty)
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null)
				})
				.ThrowIfInvalid("Could not patch ZLog.LogError()! (newline)")
				.SetOperandAndAdvance((object)string.Empty)
				.InstructionEnumeration();
		}

		[HarmonyTranspiler]
		[HarmonyPatch("DevLog")]
		private static IEnumerable<CodeInstruction> DevLogTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null)
			}).ThrowIfInvalid("Could not patch ZLog.DevLog()! (colon)")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) })
				.SetOperandAndAdvance((object)string.Empty)
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null)
				})
				.ThrowIfInvalid("Could not patch ZLog.DevLog()! (newline)")
				.SetOperandAndAdvance((object)string.Empty)
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(ZSteamSocket))]
	internal static class ZSteamSocketPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch("SendQueuedPackages")]
		private static IEnumerable<CodeInstruction> SendQueuedPackagesTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			List<Label> labels;
			if (PluginConfig.RemoveFailedToSendDataLogging.Value)
			{
				return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Failed to send data ", (string)null)
				}).ThrowIfInvalid("Could not patch ZSteamSocket.SendQueuedPackages()! (Ldstr-Log)")
					.ExtractLabels(out labels)
					.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
					{
						new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null)
					})
					.ThrowIfInvalid("Could not patch ZSteamSocket.SendQueuedPackages()! (ZLog-Log)")
					.Advance(1)
					.AddLabels((IEnumerable<Label>)labels)
					.InstructionEnumeration();
			}
			return instructions;
		}

		public static CodeMatcher ExtractLabels(this CodeMatcher matcher, out List<Label> labels)
		{
			labels = new List<Label>(matcher.Labels);
			matcher.Labels.Clear();
			return matcher;
		}
	}
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<bool> RemoveStackTraceForNonErrorLogType { get; private set; }

		public static ConfigEntry<bool> RemoveFailedToSendDataLogging { get; private set; }

		public static ConfigEntry<bool> RemoveContainerRequestOpenLogging { get; private set; }

		public static ConfigEntry<bool> CheckProjectFixedUpdateZeroVelocity { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod (restart required).");
			RemoveStackTraceForNonErrorLogType = config.BindInOrder("Logging", "removeStackTraceForNonErrorLogType", defaultValue: true, "Disables the stack track for 'Info' and 'Warning' log types.");
			RemoveFailedToSendDataLogging = config.BindInOrder("Logging", "removeFailedToSendDataLogging", defaultValue: true, "Removes (NOPs out) 'Failed to send data' logging in ZSteamSocket.");
			RemoveContainerRequestOpenLogging = config.BindInOrder("Logging", "removeContainerRequestOpenLogging", defaultValue: true, "Removes (NOPs out) 'Players wants to open/but im not the owner' logging in Container.RPC_RequestOpen().");
			CheckProjectFixedUpdateZeroVelocity = config.BindInOrder("Quaternion.LookRotation", "checkProjectFixedUpdatedZeroVelocity", defaultValue: true, "Checks for zero `m_vel` in `Projectile.FixedUpdate()`.");
		}
	}
}