Decompiled source of HealthyChat v1.0.0

plugins/HealthyChat.dll

Decompiled 21 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HealthyChat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HealthyChat")]
[assembly: AssemblyTitle("HealthyChat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 HealthyChat
{
	[BepInPlugin("com.healthychat.mod", "HealthyChat", "1.0.0")]
	public class HealthyChatPlugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> hideTemporary;

		private ConfigEntry<bool> hideEthereal;

		private void Awake()
		{
			hideTemporary = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Messages", "HideTemporary", true, "Hide temporary item pickup messages.");
			hideEthereal = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Messages", "HideEthereal", true, "Hide ethereal item pickup messages.");
		}

		private void OnEnable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Chat.AddMessage_ChatMessageBase += new hook_AddMessage_ChatMessageBase(OnChatMessage);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"HealthyChat Loaded.");
		}

		private void OnDisable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Chat.AddMessage_ChatMessageBase -= new hook_AddMessage_ChatMessageBase(OnChatMessage);
		}

		private void OnChatMessage(orig_AddMessage_ChatMessageBase orig, ChatMessageBase msg)
		{
			if (msg != null && ((object)msg).GetType().Name == "PlayerPickupChatMessage")
			{
				FieldInfo field = ((object)msg).GetType().GetField("pickupFormat", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				string text = "";
				if (field != null)
				{
					object value = field.GetValue(msg);
					text = Convert.ToString(value);
				}
				if (text == "ITEM_MODIFIER_TEMP" && hideTemporary.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[HealthyChat] Temporary item message filtered.");
					return;
				}
				if (text == "ITEM_MODIFIER_RENTAL" && hideEthereal.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[HealthyChat] Ethereal item message filtered.");
					return;
				}
			}
			orig.Invoke(msg);
		}
	}
}