Decompiled source of officerballs StatusManager v1.1.4

BepInEx/plugins/officerballs/officerballs.StatusManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PurrLobby;
using PurrNet;
using StatusMessage.patches;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("officerballs.StatusManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4")]
[assembly: AssemblyProduct("officerballs.StatusManager")]
[assembly: AssemblyTitle("officerballs.StatusManager")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.4.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 StatusMessage
{
	[BepInPlugin("officerballs.StatusManager", "Status Manager", "1.1.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static bool active;

		public const string modGUID = "officerballs.StatusManager";

		public const string modName = "Status Manager";

		public const string modVersion = "1.1.4.0";

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

		public ManualLogSource mls = Logger.CreateLogSource("officerballs.StatusManager");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private void Awake()
		{
			harmony.PatchAll(typeof(AddModdedTag));
			harmony.PatchAll(typeof(StatusPatch));
			harmony.PatchAll(typeof(RevertNamePatch));
			harmony.PatchAll(typeof(CharLimitPatch));
			string text = "";
			configBracketType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "BracketType", "()", "How your status messages are wrapped. Two character limit.");
			configCustomColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomColor", "5ec1c7", "Colorcode to wrap custom status with.");
			configNameBase = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PlayerName", text, "Your player's name.");
			configUseGradient = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Gradient", "UseGradient", false, "Toggle gradient mode on or off.");
			configScrollingGradient = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Gradient", "ScrollingGradient", false, "Toggle gradient auto-scrolling.");
			configScrollStyle = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Gradient", "ScrollStyle", false, "Swap gradient scroll styles.");
			configUseThirdColor = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Gradient", "UseThirdColor", true, "Use three gradient colors.");
			configGradientColor1 = ((BaseUnityPlugin)this).Config.Bind<string>("General.Gradient", "GradientColor1", "ff5277", "First gradient color.");
			configGradientColor2 = ((BaseUnityPlugin)this).Config.Bind<string>("General.Gradient", "GradientColor2", "92e8c0", "Second gradient color.");
			configGradientColor3 = ((BaseUnityPlugin)this).Config.Bind<string>("General.Gradient", "GradientColor3", "3978a8", "Third gradient color.");
			configGradientBuffer = ((BaseUnityPlugin)this).Config.Bind<int>("General.Gradient", "GradientBuffer", 0, "Additional length buffer for gradients. Limited 0-128.");
			configUseBRB = ((BaseUnityPlugin)this).Config.Bind<bool>("General.BRB", "UseBRB", true, "Enables auto-BRB system.");
			configBRBTimer = ((BaseUnityPlugin)this).Config.Bind<int>("General.BRB", "BRBTimer", 2, "Time in minutes before BRB applies. Must be lower than AFK timer if that's enabled.");
			configBRBMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General.BRB", "BRBMessage", "BRB", "Text for the BRB status.");
			configBRBColor = ((BaseUnityPlugin)this).Config.Bind<string>("General.BRB", "BRBColor", "ffd45d", "Colorcode to wrap BRB status with.");
			configUseAFK = ((BaseUnityPlugin)this).Config.Bind<bool>("General.AFK", "UseAFK", true, "Enables auto-AFK system.");
			configAFKTimer = ((BaseUnityPlugin)this).Config.Bind<int>("General.AFK", "AFKTimer", 5, "Time in minutes before AFK applies. Must be higher than BRB timer if that's enabled.");
			configAFKMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General.AFK", "AFKMessage", "AFK", "Text for the AFK status.");
			configAFKColor = ((BaseUnityPlugin)this).Config.Bind<string>("General.AFK", "AFKColor", "e97d45", "Colorcode to wrap AFK status with.");
			mls.LogInfo((object)"Status Management system online.");
		}
	}
}
namespace StatusMessage.patches
{
	[HarmonyPatch(typeof(DataManager))]
	internal class RevertNamePatch
	{
		[HarmonyPatch("LoadPlayerData")]
		[HarmonyPostfix]
		public static void SetUser()
		{
			if (Plugin.configNameBase.Value != "" && MonoSingleton<DataManager>.I.PlayerData.Name != Plugin.configNameBase.Value)
			{
				MonoSingleton<DataManager>.I.PlayerData.Name = Plugin.configNameBase.Value;
			}
			else if (Plugin.configNameBase.Value == "")
			{
				Plugin.configNameBase.Value = MonoSingleton<DataManager>.I.PlayerData.Name;
			}
		}
	}
	[HarmonyPatch(typeof(MultiplayerManager))]
	public class AddModdedTag
	{
		[HarmonyPatch("CreateLobby")]
		[HarmonyPrefix]
		public static void NameChanger(ref List<bool> ___FilterSocialTags)
		{
			int filterPlayerValue = MonoSingleton<MultiplayerManager>.I.FilterPlayerValue;
			string text = MonoSingleton<MainMenuUIController>.I.CreateSessionNameInputField.text;
			___FilterSocialTags[4] = true;
		}
	}
	[HarmonyPatch(typeof(TextChannelManager))]
	public static class StatusPatch
	{
		public static string _ifTeleportString = "";

		public static string statusmsg = "";

		public static float awaytimer = 0f;

		public static float nameTimer = 0f;

		public static bool isAFK = false;

		public static bool isBRB = false;

		public static int nameLen;

		public static int rollingOffset = 0;

		public static float tickRate = 0.0625f;

		public static bool gradientReady = false;

		public static List<string> colorlist = new List<string>();

		public static float UpdateDelayer = 0f;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void TimeChecker()
		{
			if (Input.anyKey)
			{
				bool flag = false;
				awaytimer = 0f;
				if (isBRB)
				{
					isBRB = false;
					flag = true;
				}
				if (isAFK)
				{
					isAFK = false;
					flag = true;
				}
				if (flag)
				{
					if (gradientReady)
					{
						gradientReady = false;
					}
					if (Plugin.configScrollingGradient.Value)
					{
						rollingOffset = 0;
					}
					SendSetName();
					EmitUpdate();
				}
			}
			if (awaytimer >= (float)(Plugin.configAFKTimer.Value * 60) && statusmsg == "" && !isAFK && Plugin.configUseAFK.Value)
			{
				isAFK = true;
				if (gradientReady)
				{
					gradientReady = false;
				}
				SendSetName();
				EmitUpdate();
			}
			else if (awaytimer >= (float)(Plugin.configBRBTimer.Value * 60) && statusmsg == "" && !isBRB && Plugin.configUseBRB.Value)
			{
				isBRB = true;
				if (gradientReady)
				{
					gradientReady = false;
				}
				SendSetName();
				EmitUpdate();
			}
			else if ((Plugin.configUseAFK.Value && !isAFK) || (Plugin.configUseBRB.Value && !isBRB && (!Plugin.configUseAFK.Value || (Plugin.configUseAFK.Value && !isAFK))))
			{
				awaytimer += Time.deltaTime;
			}
			if (UpdateDelayer > 0f)
			{
				UpdateDelayer -= Time.deltaTime;
				if (UpdateDelayer <= 0f)
				{
					EmitUpdate();
				}
			}
		}

		public static void MakeGradient(string name)
		{
			name = StripTags(name);
			nameLen = name.Length;
			nameLen += Plugin.configGradientBuffer.Value;
			int num = Convert.ToInt32(Plugin.configGradientColor1.Value.Substring(0, 2), 16);
			int num2 = Convert.ToInt32(Plugin.configGradientColor2.Value.Substring(0, 2), 16);
			int num3 = Convert.ToInt32(Plugin.configGradientColor3.Value.Substring(0, 2), 16);
			int num4 = Convert.ToInt32(Plugin.configGradientColor1.Value.Substring(2, 2), 16);
			int num5 = Convert.ToInt32(Plugin.configGradientColor2.Value.Substring(2, 2), 16);
			int num6 = Convert.ToInt32(Plugin.configGradientColor3.Value.Substring(2, 2), 16);
			int num7 = Convert.ToInt32(Plugin.configGradientColor1.Value.Substring(4, 2), 16);
			int num8 = Convert.ToInt32(Plugin.configGradientColor2.Value.Substring(4, 2), 16);
			int num9 = Convert.ToInt32(Plugin.configGradientColor3.Value.Substring(4, 2), 16);
			colorlist.Clear();
			if (!Plugin.configScrollingGradient.Value)
			{
				if (!Plugin.configUseThirdColor.Value)
				{
					for (int i = 0; i < nameLen; i++)
					{
						string text = ColorSnap(num + (num2 - num) * i / nameLen).ToString("x2");
						string text2 = ColorSnap(num4 + (num5 - num4) * i / nameLen).ToString("x2");
						string text3 = ColorSnap(num7 + (num8 - num7) * i / nameLen).ToString("x2");
						string item = text + text2 + text3;
						colorlist.Add(item);
					}
				}
				else
				{
					int num10 = (int)Math.Ceiling((double)nameLen / 2.0);
					if (num10 < 1)
					{
						num10 = 1;
					}
					for (int j = 0; j < num10; j++)
					{
						string text4 = ColorSnap(num + (num2 - num) * j / num10).ToString("x2");
						string text5 = ColorSnap(num4 + (num5 - num4) * j / num10).ToString("x2");
						string text6 = ColorSnap(num7 + (num8 - num7) * j / num10).ToString("x2");
						string item2 = text4 + text5 + text6;
						colorlist.Add(item2);
					}
					int num11 = ((nameLen - num10 <= 0) ? 1 : (nameLen - num10));
					for (int k = 0; k < num11; k++)
					{
						string text7 = ColorSnap(num2 + (num3 - num2) * k / num10).ToString("x2");
						string text8 = ColorSnap(num5 + (num6 - num5) * k / num10).ToString("x2");
						string text9 = ColorSnap(num8 + (num9 - num8) * k / num10).ToString("x2");
						string item3 = text7 + text8 + text9;
						colorlist.Add(item3);
					}
				}
			}
			else if (!Plugin.configUseThirdColor.Value)
			{
				int num12 = (int)Math.Ceiling((double)nameLen / 2.0);
				if (num12 < 1)
				{
					num12 = 1;
				}
				for (int l = 0; l < num12; l++)
				{
					string text10 = ColorSnap(num + (num2 - num) * l / num12).ToString("x2");
					string text11 = ColorSnap(num4 + (num5 - num4) * l / num12).ToString("x2");
					string text12 = ColorSnap(num7 + (num8 - num7) * l / num12).ToString("x2");
					string item4 = text10 + text11 + text12;
					colorlist.Add(item4);
				}
				int num13 = ((nameLen - num12 <= 0) ? 1 : (nameLen - num12));
				for (int m = 0; m < num13; m++)
				{
					string text13 = ColorSnap(num2 + (num - num2) * m / num12).ToString("x2");
					string text14 = ColorSnap(num5 + (num4 - num5) * m / num12).ToString("x2");
					string text15 = ColorSnap(num8 + (num7 - num8) * m / num12).ToString("x2");
					string item5 = text13 + text14 + text15;
					colorlist.Add(item5);
				}
			}
			else
			{
				int num14 = (int)Math.Ceiling((double)nameLen / 3.0);
				if (num14 < 1)
				{
					num14 = 1;
				}
				for (int n = 0; n < num14; n++)
				{
					string text16 = ColorSnap(num + (num2 - num) * n / num14).ToString("x2");
					string text17 = ColorSnap(num4 + (num5 - num4) * n / num14).ToString("x2");
					string text18 = ColorSnap(num7 + (num8 - num7) * n / num14).ToString("x2");
					string item6 = text16 + text17 + text18;
					colorlist.Add(item6);
				}
				for (int num15 = 0; num15 < num14; num15++)
				{
					string text19 = ColorSnap(num2 + (num3 - num2) * num15 / num14).ToString("x2");
					string text20 = ColorSnap(num5 + (num6 - num5) * num15 / num14).ToString("x2");
					string text21 = ColorSnap(num8 + (num9 - num8) * num15 / num14).ToString("x2");
					string item7 = text19 + text20 + text21;
					colorlist.Add(item7);
				}
				int num16 = ((nameLen - 2 * num14 <= 0) ? 1 : (nameLen - 2 * num14));
				for (int num17 = 0; num17 < num16; num17++)
				{
					string text22 = ColorSnap(num3 + (num - num3) * num17 / num14).ToString("x2");
					string text23 = ColorSnap(num6 + (num4 - num6) * num17 / num14).ToString("x2");
					string text24 = ColorSnap(num9 + (num7 - num9) * num17 / num14).ToString("x2");
					string item8 = text22 + text23 + text24;
					colorlist.Add(item8);
				}
			}
			if (colorlist.Count > 0)
			{
				gradientReady = true;
				if (statusmsg != "")
				{
					SetName("status");
				}
				else if (isAFK)
				{
					SetName("afk");
				}
				else if (isBRB)
				{
					SetName("brb");
				}
				else
				{
					SetName("basic");
				}
			}
		}

		public static void CheckChangeTickrate()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LobbyManager lobbyManager = MonoSingleton<MultiplayerManager>.I._lobbyManager;
				int count = lobbyManager.CurrentLobby.Members.Count;
				int num = ((count <= 16) ? 1 : ((int)Math.Ceiling((double)count / 6.0)));
				tickRate = 0.0625f * (float)num;
			}
			catch (NullReferenceException)
			{
			}
		}

		public static string ApplyGradient(string name)
		{
			if (!gradientReady)
			{
				return "";
			}
			name = name.Trim();
			string text = "";
			if (Plugin.configScrollStyle.Value)
			{
				int num = rollingOffset;
				if (num >= colorlist.Count())
				{
					num -= colorlist.Count();
				}
				if (num < 0)
				{
					num = 0;
				}
				text = "<#" + colorlist[num] + ">" + name + "</color>";
			}
			else
			{
				int num2 = 0;
				bool flag = false;
				char[] array = name.ToCharArray();
				for (int i = 0; i < array.Count(); i++)
				{
					bool flag2 = false;
					if (array[i] == '<')
					{
						flag = true;
					}
					else if (array[i] == '>')
					{
						flag = false;
						flag2 = true;
					}
					else if (array[i] == ' ')
					{
						flag2 = true;
					}
					if (flag || flag2)
					{
						text += array[i];
						continue;
					}
					int num3 = num2 + rollingOffset;
					if (num3 >= colorlist.Count())
					{
						num3 -= colorlist.Count();
					}
					if (num3 < 0)
					{
						num3 = 0;
					}
					string text2 = "<#" + colorlist[num3] + ">" + array[i] + "</color>";
					text += text2;
					num2++;
				}
			}
			Debug.Log((object)text);
			return text;
		}

		public static int ColorSnap(int input)
		{
			if (input < 0)
			{
				input = 0;
			}
			if (input > 255)
			{
				input = 255;
			}
			return input;
		}

		[HarmonyPatch("OnEnterPressed")]
		[HarmonyPrefix]
		public static bool TextChecker()
		{
			string text = MonoSingleton<UIManager>.I.MessageInput.text;
			if (text == "/help")
			{
				ResetPostMessage(skiptext: true);
				Notify("/help status for StatusManager commands");
				Notify("/help gradient for commands to control gradients");
				return true;
			}
			if (!(text == "/gradientscrollstyle") && false)
			{
				gradientReady = false;
				Plugin.configScrollStyle.Value = !Plugin.configScrollStyle.Value;
				rollingOffset = 0;
				SendSetName();
				Notify("Gradient scroll style swapped.");
				EmitUpdate();
				ResetPostMessage();
				return false;
			}
			if (text.Length >= 15 && text.Substring(0, 15) == "/changebrackets")
			{
				if (text.Length >= 18)
				{
					Plugin.configBracketType.Value = text.Substring(16, 2);
					if (statusmsg != "")
					{
						if (gradientReady)
						{
							gradientReady = false;
						}
						if (Plugin.configScrollingGradient.Value)
						{
							rollingOffset = 0;
						}
						SendSetName();
						EmitUpdate();
					}
					Notify("Brackets changed to " + Plugin.configBracketType.Value);
				}
				else
				{
					Notify("Brackets currently set to " + Plugin.configBracketType.Value);
				}
				ResetPostMessage();
				return false;
			}
			if (!(text == "/gradientscroll") && false)
			{
				gradientReady = false;
				Plugin.configScrollingGradient.Value = !Plugin.configScrollingGradient.Value;
				string text2 = (Plugin.configScrollingGradient.Value ? "on" : "off");
				rollingOffset = 0;
				SendSetName();
				EmitUpdate();
				ResetPostMessage();
				return false;
			}
			if (text.Length >= 16 && text.Substring(0, 16) == "/gradientstretch")
			{
				if (text.Length >= 17)
				{
					if (int.TryParse(text.Substring(17), out var result))
					{
						if (result < 0)
						{
							result = 0;
						}
						else if (result > 128)
						{
							result = 128;
						}
						Plugin.configGradientBuffer.Value = result;
						Notify("Gradient buffer size set to " + result + ".");
						if (Plugin.configScrollingGradient.Value)
						{
							rollingOffset = 0;
						}
						SendSetName();
					}
					else
					{
						Notify("Gradient buffer size currently set to " + Plugin.configGradientBuffer.Value + ".");
					}
				}
				else
				{
					Notify("Gradient buffer size currently set to " + Plugin.configGradientBuffer.Value + ".");
				}
				EmitUpdate();
				ResetPostMessage();
				return false;
			}
			if (text.Length >= 14)
			{
				string text3 = text.Substring(0, 14);
				string text4 = text3;
				string text5 = text4;
				if (text5 == "/gradientcolor")
				{
					if (text.Length >= 16)
					{
						if (int.TryParse(text.Substring(15, 1), out var result2))
						{
							switch (result2)
							{
							case 1:
								if (text.Length >= 23)
								{
									gradientReady = false;
									Plugin.configGradientColor1.Value = text.Substring(17, 6);
									if (Plugin.configScrollingGradient.Value)
									{
										rollingOffset = 0;
									}
									SendSetName();
									Notify("Gradient color 1 set to <color=#" + Plugin.configGradientColor1.Value + ">" + Plugin.configGradientColor1.Value + "</color>.");
								}
								else
								{
									Notify("Gradient color 1 currently set to <color=#" + Plugin.configGradientColor1.Value + ">" + Plugin.configGradientColor1.Value + "</color>.");
								}
								break;
							case 2:
								if (text.Length >= 23)
								{
									gradientReady = false;
									Plugin.configGradientColor2.Value = text.Substring(17, 6);
									if (Plugin.configScrollingGradient.Value)
									{
										rollingOffset = 0;
									}
									SendSetName();
									Notify("Gradient color 2 set to <color=#" + Plugin.configGradientColor2.Value + ">" + Plugin.configGradientColor2.Value + "</color>.");
								}
								else
								{
									Notify("Gradient color 2 currently set to <color=#" + Plugin.configGradientColor2.Value + ">" + Plugin.configGradientColor2.Value + "</color>.");
								}
								break;
							case 3:
								if (text.Length >= 23)
								{
									gradientReady = false;
									Plugin.configGradientColor3.Value = text.Substring(17, 6);
									if (Plugin.configScrollingGradient.Value)
									{
										rollingOffset = 0;
									}
									SendSetName();
									Notify("Gradient color 3 set to <color=#" + Plugin.configGradientColor3.Value + ">" + Plugin.configGradientColor3.Value + "</color>.");
								}
								else
								{
									Notify("Gradient color 3 currently set to <color=#" + Plugin.configGradientColor3.Value + ">" + Plugin.configGradientColor3.Value + "</color>.");
								}
								break;
							default:
								Notify("Must specify a number 1 - 3 and a color.");
								Notify("example: /gradientcolor 1 123456");
								break;
							}
						}
						else
						{
							Notify("Must specify a number 1 - 3 and a color.");
							Notify("example: /gradientcolor 1 123456");
						}
					}
					else
					{
						Notify("Must specify a number 1 - 3 and a color.");
						Notify("example: /gradientcolor 1 123456");
					}
					EmitUpdate();
					ResetPostMessage();
					return false;
				}
				if (text5 == "/gradientthree")
				{
					gradientReady = false;
					Plugin.configUseThirdColor.Value = !Plugin.configUseThirdColor.Value;
					string text6 = (Plugin.configUseThirdColor.Value ? "on" : "off");
					rollingOffset = 0;
					SendSetName();
					Notify("Gradient 3 turned " + text6);
					EmitUpdate();
					ResetPostMessage();
					return false;
				}
			}
			if (text.Length >= 12)
			{
				switch (text.Substring(0, 12))
				{
				case "/usegradient":
				{
					Plugin.configUseGradient.Value = !Plugin.configUseGradient.Value;
					string text7 = (Plugin.configUseGradient.Value ? "on" : "off");
					Notify("Gradients turned " + text7);
					if (Plugin.configScrollingGradient.Value)
					{
						rollingOffset = 0;
					}
					SendSetName();
					EmitUpdate();
					ResetPostMessage();
					return false;
				}
				case "/clearstatus":
					statusmsg = "";
					if (gradientReady)
					{
						gradientReady = false;
					}
					if (Plugin.configScrollingGradient.Value)
					{
						rollingOffset = 0;
					}
					SendSetName();
					EmitUpdate();
					ResetPostMessage();
					Notify("Status message cleared.");
					return false;
				case "/statuscolor":
					if (text.Length >= 19)
					{
						string value = text.Substring(13, 6);
						Plugin.configCustomColor.Value = value;
						if (statusmsg != "")
						{
							if (gradientReady)
							{
								gradientReady = false;
							}
							if (Plugin.configScrollingGradient.Value)
							{
								rollingOffset = 0;
							}
							SendSetName();
							EmitUpdate();
							Notify("Status color changed to <color=#" + Plugin.configCustomColor.Value + ">" + Plugin.configCustomColor.Value + "</color>.");
						}
					}
					else
					{
						Notify("Status color currently set to <color=#" + Plugin.configCustomColor.Value + ">" + Plugin.configCustomColor.Value + "</color>.");
					}
					ResetPostMessage();
					return false;
				}
			}
			if (text.Length >= 9)
			{
				string text8 = text.Substring(0, 9);
				string text9 = "";
				string text10 = text8;
				string text11 = text10;
				if (text11 == "/brbcolor")
				{
					if (text.Length >= 16)
					{
						text9 = text.Substring(10, 6);
						Plugin.configBRBColor.Value = text9;
						ResetPostMessage();
						Notify("BRB color changed to <color=#" + Plugin.configBRBColor.Value + ">" + Plugin.configBRBColor.Value + "</color>.");
						return false;
					}
					ResetPostMessage();
					Notify("BRB color currently set to <color=#" + Plugin.configBRBColor.Value + ">" + Plugin.configBRBColor.Value + "</color>.");
					return false;
				}
				if (text11 == "/afkcolor")
				{
					if (text.Length >= 16)
					{
						text9 = text.Substring(10, 6);
						Plugin.configAFKColor.Value = text9;
						ResetPostMessage();
						Notify("AFK color changed to <color=#" + Plugin.configAFKColor.Value + ">" + Plugin.configAFKColor.Value + "</color>.");
						return false;
					}
					ResetPostMessage();
					Notify("AFK color currently set to <color=#" + Plugin.configAFKColor.Value + ">" + Plugin.configAFKColor.Value + "</color>.");
					return false;
				}
			}
			if (text.Length >= 9)
			{
				string text12 = text.Substring(0, 9);
				string text13 = text12;
				string text14 = text13;
				if (text14 == "/brbtimer")
				{
					if (text.Length > 10)
					{
						if (int.TryParse(text.Substring(10), out var result3))
						{
							Plugin.configBRBTimer.Value = result3;
							Notify("BRB timer changed to " + Plugin.configBRBTimer.Value + " minutes.");
						}
					}
					else
					{
						Notify("BRB timer currently set to " + Plugin.configBRBTimer.Value + " minutes.");
					}
					ResetPostMessage();
					return false;
				}
				if (text14 == "/afktimer")
				{
					if (text.Length > 10)
					{
						if (int.TryParse(text.Substring(10), out var result4))
						{
							Plugin.configAFKTimer.Value = result4;
							Notify("AFK timer changed to " + Plugin.configAFKTimer.Value + " minutes.");
						}
					}
					else
					{
						Notify("AFK timer currently set to " + Plugin.configAFKTimer.Value + " minutes.");
					}
					ResetPostMessage();
					return false;
				}
			}
			if (text.Length >= 8 && text.Substring(0, 8) == "/setname")
			{
				if (text.Length > 9)
				{
					string text15 = text.Substring(9);
					if (gradientReady)
					{
						gradientReady = false;
					}
					Plugin.configNameBase.Value = text15;
					Notify("Name changed to " + text15 + ".");
					ResetPostMessage();
					if (Plugin.configScrollingGradient.Value)
					{
						rollingOffset = 0;
					}
					SendSetName();
					EmitUpdate();
				}
				else
				{
					string text16 = (gradientReady ? ApplyGradient(Plugin.configNameBase.Value) : Plugin.configNameBase.Value);
					Notify("Name currently registered as " + text16 + ".");
					ResetPostMessage();
				}
				return false;
			}
			if (text.Length >= 7)
			{
				switch (text.Substring(0, 7))
				{
				case "/brbmsg":
					if (text.Length > 8)
					{
						Plugin.configBRBMessage.Value = text.Substring(8);
						ResetPostMessage();
						Notify("BRB message changed to " + Plugin.configBRBMessage.Value + ".");
						return false;
					}
					ResetPostMessage();
					Notify("BRB message currently set to " + Plugin.configBRBMessage.Value + ".");
					return false;
				case "/afkmsg":
					if (text.Length > 8)
					{
						Plugin.configAFKMessage.Value = text.Substring(8);
						ResetPostMessage();
						Notify("AFK message changed to " + Plugin.configAFKMessage.Value + ".");
						return false;
					}
					ResetPostMessage();
					Notify("AFK message currently set to " + Plugin.configAFKMessage.Value + ".");
					return false;
				case "/status":
					if (text.Length > 8)
					{
						statusmsg = text.Substring(8);
						if (gradientReady)
						{
							gradientReady = false;
						}
						if (Plugin.configScrollingGradient.Value)
						{
							rollingOffset = 0;
						}
						SendSetName();
						EmitUpdate();
						ResetPostMessage();
						Notify("Status changed to " + statusmsg + ".");
						return false;
					}
					statusmsg = "";
					if (gradientReady)
					{
						gradientReady = false;
					}
					if (Plugin.configScrollingGradient.Value)
					{
						rollingOffset = 0;
					}
					SendSetName();
					EmitUpdate();
					ResetPostMessage();
					Notify("Status message cleared.");
					return false;
				}
			}
			if (text.Length == 7)
			{
				string text17 = text;
				string text18 = text17;
				if (text18 == "/useafk")
				{
					Plugin.configUseAFK.Value = !Plugin.configUseAFK.Value;
					string text19 = (Plugin.configUseAFK.Value ? "on" : "off");
					ResetPostMessage();
					Notify("AFK system turned " + text19 + ".");
					return false;
				}
				if (text18 == "/usebrb")
				{
					Plugin.configUseBRB.Value = !Plugin.configUseBRB.Value;
					string text20 = (Plugin.configUseBRB.Value ? "on" : "off");
					ResetPostMessage();
					Notify("BRB system turned " + text20 + ".");
					return false;
				}
			}
			if (text.ToLower() == "/help statusmanager" || text.ToLower() == "/help status")
			{
				Notify("<b>Available commands:</b>");
				Notify("/setname <color=#4394b0>name</color>");
				Notify("/status <color=#4394b0>anything</color>");
				Notify("/statuscolor <color=#9db143>123456</color>");
				Notify("/clearstatus");
				Notify("/changebrackets <color=#4394b0>()</color>");
				Notify("/useafk, /usebrb (same syntax applies for all below)");
				Notify("/afkmsg <color=#4394b0>AFK</color>");
				Notify("/afktimer <color=#a83131>x</color> (in minutes)");
				Notify("/afkcolor <color=#9db143>123456</color>");
				ResetPostMessage();
				return false;
			}
			if (text.ToLower() == "/help gradient")
			{
				Notify("<b>Available commands:</b>");
				Notify("/usegradient");
				Notify("/gradientcolor <color=#a83131>x</color> <color=#9db143>123456</color>");
				Notify("/gradientstretch <color=#a83131>xx</color> (0-128)");
				Notify("/gradientthree - enable third gradient color");
				ResetPostMessage();
				return false;
			}
			return true;
		}

		public static string StripTags(string text)
		{
			string text2 = "";
			char[] array = text.ToCharArray();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i] == '<')
				{
					bool flag = false;
					if (array.Length > i)
					{
						for (int j = i + 1; j < array.Length; j++)
						{
							if (flag)
							{
								break;
							}
							if (array[j] == '>')
							{
								i = j;
								flag = true;
							}
						}
					}
					if (flag)
					{
						continue;
					}
				}
				else if (array[i] == ' ')
				{
					continue;
				}
				text2 += array[i];
			}
			Debug.Log((object)text2);
			return text2;
		}

		public static void SendSetName()
		{
			if (Plugin.configUseGradient.Value)
			{
				MakeGradient(Plugin.configNameBase.Value);
			}
			else if (statusmsg != "")
			{
				SetName("status");
			}
			else if (isAFK)
			{
				SetName("afk");
			}
			else if (isBRB)
			{
				SetName("brb");
			}
			else
			{
				SetName("basic");
			}
		}

		public static void SetName(string type)
		{
			switch (type)
			{
			case "basic":
			{
				string name = ((Plugin.configUseGradient.Value && gradientReady) ? ApplyGradient(Plugin.configNameBase.Value) : Plugin.configNameBase.Value);
				MonoSingleton<DataManager>.I.PlayerData.Name = name;
				break;
			}
			case "status":
			{
				string text4 = (gradientReady ? ApplyGradient(Plugin.configNameBase.Value) : Plugin.configNameBase.Value);
				string text5 = Plugin.configBracketType.Value.Substring(0, 1);
				string text6 = Plugin.configBracketType.Value.Substring(1);
				string value3 = Plugin.configCustomColor.Value;
				MonoSingleton<DataManager>.I.PlayerData.Name = text4 + " <color=#" + value3 + ">" + text5 + statusmsg + text6 + "</color>";
				break;
			}
			case "brb":
			{
				string text7 = (gradientReady ? ApplyGradient(Plugin.configNameBase.Value) : Plugin.configNameBase.Value);
				string text8 = Plugin.configBracketType.Value.Substring(0, 1);
				string text9 = Plugin.configBracketType.Value.Substring(1);
				string value4 = Plugin.configBRBMessage.Value;
				string value5 = Plugin.configBRBColor.Value;
				MonoSingleton<DataManager>.I.PlayerData.Name = text7 + " <color=#" + value5 + ">" + text8 + value4 + text9 + "</color>";
				break;
			}
			case "afk":
			{
				string text = (gradientReady ? ApplyGradient(Plugin.configNameBase.Value) : Plugin.configNameBase.Value);
				string text2 = Plugin.configBracketType.Value.Substring(0, 1);
				string text3 = Plugin.configBracketType.Value.Substring(1);
				string value = Plugin.configAFKMessage.Value;
				string value2 = Plugin.configAFKColor.Value;
				MonoSingleton<DataManager>.I.PlayerData.Name = text + " <color=#" + value2 + ">" + text2 + value + text3 + "</color>";
				break;
			}
			}
		}

		public static void Notify(string notification)
		{
			NetworkSingleton<TextChannelManager>.I.AddNotification(notification);
		}

		public static void ResetPostMessage(bool skiptext = false)
		{
			MonoSingleton<TaskManager>.I.SetLockState((LockState)(NetworkSingleton<MusicManager>.I.IsActive ? 5 : 0));
			EventSystem.current.SetSelectedGameObject((GameObject)null);
			if (!skiptext)
			{
				MonoSingleton<UIManager>.I.MessageInput.text = "";
			}
		}

		public static void EmitUpdate()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)MonoSingleton<MainSceneManager>.I != (Object)null))
			{
				return;
			}
			try
			{
				if (UpdateDelayer <= 0f)
				{
					NetworkSingleton<TextChannelManager>.I.MainCustomizationController.UpdatePlayerInfo(MonoSingleton<DataManager>.I.PlayerData.GetPlayerIdInfo(), default(RPCInfo));
					TextMeshProUGUI playerText = MonoSingleton<UIManager>.I.PlayerText;
					string text = (NetworkSingleton<TextChannelManager>.I.UserName = MonoSingleton<DataManager>.I.PlayerData.Name);
					string text3 = (((TMP_Text)playerText).text = text);
					string text4 = text3;
					if (_ifTeleportString != "")
					{
						FieldRef<UIManager, TextMeshProUGUI> val = AccessTools.FieldRefAccess<UIManager, TextMeshProUGUI>("_playerText");
						UIManager i = MonoSingleton<UIManager>.I;
						string name2 = MonoSingleton<DataManager>.I.PlayerData.Name;
						((TMP_Text)val.Invoke(i)).text = name2 + _ifTeleportString;
					}
				}
			}
			catch (NullReferenceException)
			{
				UpdateDelayer = 2.5f;
				Debug.Log((object)"StatusManager exception, delaying");
			}
		}

		[HarmonyPatch("SendMessageAsync")]
		[HarmonyPrefix]
		public static bool HelpCloser(byte[] textBytes)
		{
			string @string = Encoding.Unicode.GetString(textBytes);
			if (@string == "/help")
			{
				return false;
			}
			return true;
		}
	}
	public static class SSS
	{
		public static T GetMethodWithoutOverrides<T>(this MethodInfo method, object callFrom) where T : Delegate
		{
			IntPtr functionPointer = method.MethodHandle.GetFunctionPointer();
			return (T)Activator.CreateInstance(typeof(T), callFrom, functionPointer);
		}
	}
	[HarmonyPatch(typeof(UIManager))]
	internal class CharLimitPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void limitLifter(ref TMP_InputField ____messageInputField)
		{
			____messageInputField.characterLimit = 250;
			if (!StatusPatch.gradientReady && Plugin.configUseGradient.Value)
			{
				StatusPatch.MakeGradient(Plugin.configNameBase.Value);
			}
		}
	}
}