Decompiled source of officerballs ChatTweaks v2.0.0

BepInEx/plugins/officerballs/officerballs.ChatTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChatTweaks.patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PurrNet;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using _otAPI;

[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("officerballs.ChatTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("officerballs.ChatTweaks")]
[assembly: AssemblyTitle("officerballs.ChatTweaks")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 ChatTweaks
{
	[BepInPlugin("officerballs.chatTweaks", "Chat Tweaks", "2.0.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string appID = "Chat Tweaks";

		public const string modGUID = "officerballs.chatTweaks";

		public const string modName = "Chat Tweaks";

		public const string modVersion = "2.0.0.0";

		private Harmony harmony = new Harmony("officerballs.chatTweaks");

		internal ManualLogSource mls = Logger.CreateLogSource("officerballs.chatTweaks");

		internal static Depot chatTweaksDepot = otAPI.CreateDepot("Chat Tweaks", "Chat Tweaks", "officer balls", "A group of tools to modify the chatbox.", "/");

		public static ConfigEntry<int> configTextSize { get; private set; }

		public static ConfigEntry<string> configColorWrap { get; private set; }

		public static ConfigEntry<string> configSystemColorWrap { get; private set; }

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

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

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

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

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

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

		public static ConfigEntry<string> configOutlineColor { get; private set; }

		public static ConfigEntry<float> configOutlineWidth { get; private set; }

		public static ConfigEntry<int> configOutlineOpacity { get; private set; }

		internal static void OutlineChanger(string[] args)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			FieldRef<UIManager, TextMeshProUGUI> val = AccessTools.FieldRefAccess<UIManager, TextMeshProUGUI>("_messageTextForFont");
			UIManager i = MonoSingleton<UIManager>.I;
			Material fontSharedMaterial = ((TMP_Text)val.Invoke(i)).fontSharedMaterial;
			string value = configOutlineColor.Value;
			byte b = Convert.ToByte(value.Substring(0, 2), 16);
			byte b2 = Convert.ToByte(value.Substring(2, 2), 16);
			byte b3 = Convert.ToByte(value.Substring(4, 2), 16);
			fontSharedMaterial.EnableKeyword("OUTLINE_ON");
			fontSharedMaterial.SetFloat("_OutlineWidth", configOutlineWidth.Value);
			fontSharedMaterial.SetColor("_OutlineColor", Color32.op_Implicit(new Color32(b, b2, b3, Convert.ToByte(configOutlineOpacity.Value))));
			((TMP_Text)val.Invoke(i)).UpdateMeshPadding();
			TextChannelManager i2 = NetworkSingleton<TextChannelManager>.I;
			if (NetworkSingleton<TextChannelManager>.I.Islocal)
			{
				FieldRef<TextChannelManager, List<GameObject>> val2 = AccessTools.FieldRefAccess<TextChannelManager, List<GameObject>>("_messageObjectsLocal");
				{
					foreach (GameObject item in val2.Invoke(i2))
					{
						TMP_Text component = item.GetComponent<TMP_Text>();
						Material fontSharedMaterial2 = component.fontSharedMaterial;
						fontSharedMaterial2.EnableKeyword("OUTLINE_ON");
						fontSharedMaterial2.SetFloat("_OutlineWidth", configOutlineWidth.Value);
						fontSharedMaterial2.SetColor("_OutlineColor", Color32.op_Implicit(new Color32(b, b2, b3, Convert.ToByte(configOutlineOpacity.Value))));
						component.UpdateMeshPadding();
						component.ForceMeshUpdate(false, false);
						((Behaviour)component).enabled = false;
						((Behaviour)component).enabled = true;
					}
					return;
				}
			}
			FieldRef<TextChannelManager, List<GameObject>> val3 = AccessTools.FieldRefAccess<TextChannelManager, List<GameObject>>("_messageObjectsGlobal");
			foreach (GameObject item2 in val3.Invoke(i2))
			{
				TMP_Text component2 = item2.GetComponent<TMP_Text>();
				Material fontSharedMaterial3 = component2.fontSharedMaterial;
				fontSharedMaterial3.EnableKeyword("OUTLINE_ON");
				fontSharedMaterial3.SetFloat("_OutlineWidth", configOutlineWidth.Value);
				fontSharedMaterial3.SetColor("_OutlineColor", Color32.op_Implicit(new Color32(b, b2, b3, Convert.ToByte(configOutlineOpacity.Value))));
				component2.UpdateMeshPadding();
				component2.ForceMeshUpdate(false, false);
				((Behaviour)component2).enabled = false;
				((Behaviour)component2).enabled = true;
			}
		}

		private void RunPatches()
		{
			harmony.PatchAll(typeof(UIManagerPatch));
			harmony.PatchAll(typeof(TextPatcher));
			harmony.PatchAll(typeof(PlayerPanelPatch));
			harmony.PatchAll(typeof(joinSoundPatch));
		}

		private void RunBinds()
		{
			configLocalNoises = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "PlayLocalNoises", true, "Enable or disable on-message noises in local chat.");
			configGlobalNoises = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "PlayGlobalNoises", true, "Enable or disable on-message noises in global chat.");
			configMuteDuringFocus = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "MuteDuringTimer", false, "Mutes on top of local/global settings during pomodoro timer.");
			configJoinLeaveNoises = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "PlayJoinLeaveNoises", true, "Enable or disable on-leave/join noises.");
			configTextSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "TextSize", 48, "Wraps chat with a size tag.");
			configColorWrap = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TextColor", "ffffff", "Wraps chat with a color tag.");
			configSystemColorWrap = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SystemTextColor", "d5d6db", "Wraps system messages with a color tag.");
			configOutlineColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "OutlineColor", "141414", "Outline's color.");
			configOutlineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OutlineWidth", 0.25f, "Outline's width.");
			configOutlineOpacity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "OutlineOpacity", 205, "Outline's opacity.");
			configUseTimeStamps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseTimestamps", true, "Whether to use timestamps in chat.");
			configCleanUpChat = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableChatTags", true, "Removes all effects from text messages.");
		}

		internal void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Expected O, but got Unknown
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Expected O, but got Unknown
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Expected O, but got Unknown
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected O, but got Unknown
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			RunPatches();
			RunBinds();
			List<Alias> list = new List<Alias>(12);
			list.Add(new Alias("Block Richtext", chatTweaksDepot, "Disable all richtext tags in chat.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)3, true, (object)null, (object)null)
			}, new CfgLink((ArgType)3, configCleanUpChat, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Local Noise", chatTweaksDepot, "Toggles local chat message noises.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)3, true, (object)null, (object)null)
			}, new CfgLink((ArgType)3, configLocalNoises, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Global Noise", chatTweaksDepot, "Toggles global chat message noises.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)3, true, (object)null, (object)null)
			}, new CfgLink((ArgType)3, configGlobalNoises, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Timer Mute", chatTweaksDepot, "Mutes all chat while timer is running.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)3, true, (object)null, (object)null)
			}, new CfgLink((ArgType)3, configMuteDuringFocus, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Join/Leave Noise", chatTweaksDepot, "Toggles join/leave noises.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)3, true, (object)null, (object)null)
			}, new CfgLink((ArgType)3, configJoinLeaveNoises, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Timestamps", chatTweaksDepot, "Enable or disable chat timestamps.", (Arg[])null, new CfgLink((ArgType)3, configUseTimeStamps, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Text Color", chatTweaksDepot, "Sets the override color for chat text.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)1, true, (object)null, (object)null)
			}, new CfgLink((ArgType)1, configColorWrap, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Outline Color", chatTweaksDepot, "Sets the outline color for chat text.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)1, true, (object)null, (object)null)
			}, new CfgLink((ArgType)1, configOutlineColor, "was changed to", "is currently set to", false), (Action<string[]>)OutlineChanger, (AuxTiming)1));
			list.Add(new Alias("Outline Width", chatTweaksDepot, "Sets the outline width for chat text.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)4, true, (object)0f, (object)0.5f)
			}, new CfgLink((ArgType)4, configOutlineWidth, "was changed to", "is currently set to", false), (Action<string[]>)OutlineChanger, (AuxTiming)1));
			list.Add(new Alias("Outline Opacity", chatTweaksDepot, "Sets the outline opacity for chat text.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)2, true, (object)0, (object)255)
			}, new CfgLink((ArgType)2, configOutlineOpacity, "was changed to", "is currently set to", false), (Action<string[]>)OutlineChanger, (AuxTiming)1));
			list.Add(new Alias("System Color", chatTweaksDepot, "Sets the color for system messages.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)1, true, (object)null, (object)null)
			}, new CfgLink((ArgType)1, configSystemColorWrap, "was changed to", "is currently set to", false)));
			list.Add(new Alias("Text Size", chatTweaksDepot, "Sets the size for chat text.", (Arg[])(object)new Arg[1]
			{
				new Arg((ArgType)2, true, (object)0, (object)255)
			}, new CfgLink((ArgType)2, configTextSize, "was changed to", "is currently set to", false)));
			List<Alias> list2 = list;
			foreach (Alias item in list2)
			{
				otAPI.AddCfg(item.name, item.description, item.depot, item.args, item.cfgLink, item.action, item.auxTiming);
			}
			mls.LogInfo((object)"Chat tweaked");
		}
	}
}
namespace ChatTweaks.patches
{
	[HarmonyPatch(typeof(UIManager))]
	internal class UIManagerPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void awakePatch()
		{
			Plugin.OutlineChanger(new string[1] { "" });
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void patchReset(ref float ____messageTimer)
		{
			____messageTimer = 0f;
		}

		[HarmonyPatch("SetMessagePanelActiveness")]
		[HarmonyPrefix]
		public static bool ActivenessTweaker(ref TextMeshProUGUI ____messagePlaceholderText, ref Color ____messagePlaceholderActiveColor, ref float ____uiFadeDuration, ref GameObject ____messagePanel, ref List<Image> ____messagePanelImages, ref List<TextMeshProUGUI> ____messagePanelTexts, ref Image ____globalScrollImage, ref Image ____localScrollImage, UIManager __instance)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			FieldRef<CustomizationUIController, GameObject> val = AccessTools.FieldRefAccess<CustomizationUIController, GameObject>("_customizationPanel");
			CustomizationUIController i = MonoSingleton<CustomizationUIController>.I;
			if (val.Invoke(i).activeSelf)
			{
				return true;
			}
			FieldRef<PlayerPanelController, GameObject> val2 = AccessTools.FieldRefAccess<PlayerPanelController, GameObject>("_reportPanel");
			PlayerPanelController i2 = NetworkSingleton<PlayerPanelController>.I;
			if (val2.Invoke(i2).activeSelf)
			{
				return true;
			}
			((Graphic)____globalScrollImage).raycastTarget = true;
			((Graphic)____localScrollImage).raycastTarget = true;
			__instance.IsMessagePanelActivated = true;
			((Graphic)____messagePlaceholderText).color = ____messagePlaceholderActiveColor;
			____messagePanel.gameObject.SetActive(true);
			float a = 1f;
			for (int j = 0; j < ____messagePanelImages.Count; j++)
			{
				Color color = ((Graphic)____messagePanelImages[j]).color;
				color.a = a;
				((Graphic)____messagePanelImages[j]).color = color;
			}
			for (int k = 0; k < ____messagePanelTexts.Count; k++)
			{
				Color color2 = ((Graphic)____messagePanelTexts[k]).color;
				color2.a = a;
				((Graphic)____messagePanelTexts[k]).color = color2;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerCustomizationController))]
	internal class joinSoundPatch
	{
		[HarmonyPatch("JoinServerNotificationRPC_Original_1")]
		[HarmonyPrefix]
		public static void joinSoundPatcher()
		{
			if (Plugin.configJoinLeaveNoises.Value)
			{
				NetworkSingleton<TextChannelManager>.I.MainSFXController.PlayPetSound((PetType)4);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerPanelController))]
	internal class PlayerPanelPatch
	{
		[HarmonyPatch("DespawnHandle")]
		[HarmonyPrefix]
		public static void PlayerLeftNoti(NetworkTransform netTransform, PlayerPanelController __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < __instance.PlayerSteamIDs.Count; i++)
			{
				if ((Object)(object)__instance.PlayerTransforms[i] == (Object)(object)netTransform)
				{
					byte[] name = __instance.IDInfos[i].Name;
					NetworkSingleton<TextChannelManager>.I.AddNotification(Encoding.Unicode.GetString(name) + " has left the server.");
					if (Plugin.configJoinLeaveNoises.Value)
					{
						NetworkSingleton<TextChannelManager>.I.MainSFXController.PlayPetSound((PetType)6);
					}
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(TextChannelManager))]
	public class TextPatcher
	{
		public static string[] CleanText(string userName, string text)
		{
			string[] array = new string[2] { "", "" };
			char[] array2 = userName.ToCharArray();
			for (int i = 0; i < array2.Length; i++)
			{
				if (array2[i] != '<')
				{
					continue;
				}
				bool flag = false;
				bool flag2 = false;
				int num = 0;
				if (array2.Length > i)
				{
					bool flag3 = false;
					bool flag4 = false;
					if (array2[i + 1] == '#')
					{
						flag3 = true;
					}
					if (array2[i + 1] == '/')
					{
						flag4 = true;
					}
					for (int j = i + 1; j < array2.Length; j++)
					{
						if (flag)
						{
							break;
						}
						if (array2[j] == ' ')
						{
							break;
						}
						if (array2[j] != '>')
						{
							continue;
						}
						if (!flag3 && !flag4)
						{
							string text2 = userName.Substring(i, j - i + 1);
							string text3 = "";
							char[] array3 = text2.ToCharArray();
							for (int k = 0; k < array3.Length; k++)
							{
								if (array3[k] == '=')
								{
									text3 += ">";
									break;
								}
								text3 += text2[k];
							}
							if (text3 == "<space>" || text3 == "<page>")
							{
								num = j;
								continue;
							}
							if (text3.Length <= 6 || !(text3.Substring(0, 7) == "<sprite"))
							{
								text3 = text3.Insert(1, "/");
								if (userName.Substring(j).Contains(text3))
								{
									flag = true;
								}
								if (!flag)
								{
									flag2 = true;
									num = j;
									array[0] += text3;
								}
								break;
							}
							num = j;
						}
						else
						{
							if (flag3)
							{
								flag2 = true;
								num = j;
								break;
							}
							if (flag4)
							{
								flag2 = true;
								num = j;
								break;
							}
						}
					}
				}
				if (flag2)
				{
					i = num;
				}
			}
			for (int l = 0; l < text.Length; l++)
			{
				if (text[l] == '<')
				{
					bool flag5 = false;
					bool flag6 = false;
					int num2 = 0;
					if (text.Length > l)
					{
						for (int m = l + 1; m < text.Length; m++)
						{
							if (flag5)
							{
								break;
							}
							if (text[m] == ' ')
							{
								break;
							}
							if (text[m] == '>')
							{
								flag6 = true;
								num2 = m;
								break;
							}
						}
					}
					if (flag6)
					{
						l = num2;
						continue;
					}
				}
				array[1] += text[l];
			}
			return array;
		}

		[HarmonyPatch("AddMessageUI")]
		[HarmonyPrefix]
		public static bool MsgUIFix(string userName, string text, bool isLocal, int senderIndex, ref List<GameObject> ____messageObjectsLocal, ref List<GameObject> ____messageObjectsGlobal, ref TMP_Text ____textPrefab)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			string text2 = text ?? "";
			TMP_Text val = UnityProxy.Instantiate<TMP_Text>(____textPrefab, isLocal ? MonoSingleton<UIManager>.I.TextContentLocalTransform : MonoSingleton<UIManager>.I.TextContentGlobalTransform);
			string text3 = (Plugin.configUseTimeStamps.Value ? ("[" + DateTime.Now.ToString("h:mm tt") + "] ") : "");
			if (((Plugin.configLocalNoises.Value && isLocal) || Plugin.configGlobalNoises.Value) && ((Plugin.configMuteDuringFocus.Value && ((int)MonoSingleton<PomodoroController>.I.PomodoroType != 1 || MonoSingleton<PomodoroController>.I.IsPaused)) || !Plugin.configMuteDuringFocus.Value))
			{
				MonoSingleton<SFXManager>.I.PlayRodAppear();
			}
			string[] array = new string[2] { "", "" };
			if (Plugin.configCleanUpChat.Value)
			{
				array = CleanText(userName, text);
				text2 = array[1];
			}
			List<string> messageOthersColors = ScriptableSingleton<GameSettings>.I.MessageOthersColors;
			string text4 = Plugin.configTextSize.Value.ToString();
			string text5 = "";
			if (senderIndex >= 0 && senderIndex < messageOthersColors.Count)
			{
				Color val2 = default(Color);
				text5 = ((!ColorUtility.TryParseHtmlString(messageOthersColors[senderIndex], ref val2)) ? "ffffff" : ScriptableSingleton<GameSettings>.I.MessageOthersColors[senderIndex]);
			}
			val.text = "<size=" + text4 + "><color=#" + text5 + ">" + text3 + userName + "</color>:" + array[0] + "<color=#" + Plugin.configColorWrap.Value + "> " + text2;
			if (isLocal)
			{
				____messageObjectsLocal.Add(((Component)val).gameObject);
				if (____messageObjectsLocal.Count > ScriptableSingleton<GameSettings>.I.LocalMessageLimitCount)
				{
					GameObject val3 = ____messageObjectsLocal[0];
					____messageObjectsLocal.RemoveAt(0);
					UnityProxy.Destroy((Object)(object)val3);
				}
			}
			else
			{
				____messageObjectsGlobal.Add(((Component)val).gameObject);
				if (____messageObjectsGlobal.Count > ScriptableSingleton<GameSettings>.I.GlobalMessageLimitCount)
				{
					GameObject val4 = ____messageObjectsGlobal[0];
					____messageObjectsGlobal.RemoveAt(0);
					UnityProxy.Destroy((Object)(object)val4);
				}
			}
			return false;
		}

		[HarmonyPatch("AddNotification")]
		[HarmonyPrefix]
		public static void NotifTextPatch(ref string text)
		{
			string text2 = Plugin.configTextSize.Value.ToString();
			text = "<size=" + text2 + "><color=#" + Plugin.configSystemColorWrap.Value + ">" + text;
		}

		public static void ShowCommands(string[] args)
		{
			otAPI.Notify("Available commands:", (UINotificationTray)null);
			otAPI.Notify("/togglelocalnoise", (UINotificationTray)null);
			otAPI.Notify("/toggleglobalnoise", (UINotificationTray)null);
			otAPI.Notify("/toggletimermute", (UINotificationTray)null);
			otAPI.Notify("/mutejoinleave", (UINotificationTray)null);
			otAPI.Notify("/usetimestamps", (UINotificationTray)null);
			otAPI.Notify("/togglechattags", (UINotificationTray)null);
		}
	}
}