Decompiled source of Straumr Quiet v0.1.1

StraumrQuiet.dll

Decompiled 14 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("StraumrQuiet")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+b801bdb2fb6e8207acb0a19038ce259b24f9e2fd")]
[assembly: AssemblyProduct("StraumrQuiet")]
[assembly: AssemblyTitle("StraumrQuiet")]
[assembly: AssemblyVersion("0.1.1.0")]
namespace StraumrQuiet;

[BepInPlugin("avesatanas.straumr.quiet", "Straumr Quiet", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "avesatanas.straumr.quiet";

	private void Awake()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		Type type = AccessTools.TypeByName("Straumr.Cofferdams");
		MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Tell", new Type[3]
		{
			typeof(float),
			typeof(float),
			typeof(string)
		}, (Type[])null));
		if (methodInfo == null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Straumr.Cofferdams.Tell(float, float, string) not found; Straumr's cofferdam lines are not silenced.");
			return;
		}
		Harmony val = new Harmony("avesatanas.straumr.quiet");
		val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "Skip", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Straumr's \"cofferdams near\" console lines are silenced.");
		MethodInfo methodInfo2 = AccessTools.Method(AccessTools.TypeByName("Straumr.Status"), "Write", new Type[1] { typeof(string) }, (Type[])null);
		if (methodInfo2 == null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Straumr.Status.Write(string) not found; Straumr's cofferdam lines in the log are not silenced.");
		}
		else
		{
			val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "Filter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}

	private static bool Skip()
	{
		return false;
	}

	private static bool Filter(string message)
	{
		if (message != null)
		{
			if (!message.StartsWith("cofferdams: at (", StringComparison.Ordinal))
			{
				return !message.StartsWith("cofferdams: the server's look took", StringComparison.Ordinal);
			}
			return false;
		}
		return true;
	}
}