Decompiled source of ButteredLillysAsciicharprotector v3.0.8

Ascii_char_protector.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using Ascii_char_protector;
using BepInEx;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MelonLoad), "Ascii char protector", "1.0.0", "Lilly", null)]
[assembly: MelonOptionalDependencies(new string[] { "BepInEx" })]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Ascii_char_protector")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d8c900694d3acaa7037495e5dae0bb3462820d01")]
[assembly: AssemblyProduct("Ascii_char_protector")]
[assembly: AssemblyTitle("Ascii_char_protector")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 Ascii_char_protector
{
	[BepInPlugin("0a26c5bd-f173-47f8-8f50-006dd6806ce6", "Ascii char protector", "1.0.0")]
	public class Bepin : BaseUnityPlugin
	{
		private Ascii_char_protector_Core charPro;

		private void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			if (!((Object)(object)Ascii_char_protector_Core.charProinstance != (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(GameObject.CreatePrimitive((PrimitiveType)3));
				((Object)val).hideFlags = (HideFlags)61;
				charPro = val.AddComponent<Ascii_char_protector_Core>();
				charPro.Logger = logger;
				Harmony val2 = new Harmony("Ascii char protector");
				val2.PatchAll();
			}
		}

		public bool logger(string mesg)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)(mesg ?? ""));
			return true;
		}
	}
	public class Ascii_char_protector_Core : MonoBehaviour
	{
		[HarmonyPatch(typeof(ChatBehaviour), "New_ChatMessage")]
		public static class ServerSidePro
		{
			private static void Prefix(ref string _message)
			{
				try
				{
					_message = charProinstance.filter.Replace(_message, "");
				}
				catch (Exception ex)
				{
					charProinstance.Logger(ex.Message);
				}
			}
		}

		[HarmonyPatch(typeof(ChatBehaviour), "Rpc_RecieveChatMessage")]
		public static class LocalPro
		{
			private static void Prefix(ref string message)
			{
				try
				{
					message = charProinstance.filter.Replace(message, "");
				}
				catch (Exception ex)
				{
					charProinstance.Logger(ex.Message);
				}
			}
		}

		[HarmonyPatch(typeof(ChatBehaviour), "Cmd_SendChatMessage")]
		public static class LocalPro2
		{
			private static void Prefix(ref string _message)
			{
				try
				{
					_message = charProinstance.filter.Replace(_message, "");
				}
				catch (Exception ex)
				{
					charProinstance.Logger(ex.Message);
				}
			}
		}

		[HarmonyPatch(typeof(ProfileDataSender), "OnRecieve_PlayerProfileData")]
		public static class LocalPro3
		{
			private static void Prefix(ref PlayerProfileDataMessage _message)
			{
				try
				{
					_message._nickName = charProinstance.filter.Replace(_message._nickName, "");
				}
				catch (Exception ex)
				{
					charProinstance.Logger(ex.Message);
				}
			}
		}

		public static Ascii_char_protector_Core charProinstance;

		public Func<string, bool> Logger;

		public Regex filter = new Regex("[^ -~]");

		public void Start()
		{
			charProinstance = this;
		}
	}
	public class MelonLoad : MelonMod
	{
		private Ascii_char_protector_Core charPro;

		public override void OnInitializeMelon()
		{
			if (!((Object)(object)charPro != (Object)null))
			{
				charPro = Object.Instantiate<GameObject>(GameObject.CreatePrimitive((PrimitiveType)3)).AddComponent<Ascii_char_protector_Core>();
				((Object)((Component)charPro).gameObject).hideFlags = (HideFlags)61;
				charPro.Logger = logger;
			}
		}

		public bool logger(string mesg)
		{
			MelonLogger.Msg(mesg);
			return true;
		}
	}
}