Decompiled source of ControlCompany LobbyFix v1.0.2

ControlCompanySpoof.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ControlCompanySpoof")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ControlCompanySpoof")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5087b0e7-5dbe-40bb-850b-e904318413c6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ControlCompanySpoof;

[BepInPlugin("ControlCompanySpoof", "ControlCompanySpoof", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CCSPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(MenuManager))]
	internal class LobbyListPatchPatch
	{
		internal static readonly ManualLogSource CCSPatchesConsole = Logger.CreateLogSource("ControlCompanySpoof.Patches");

		private static readonly char SERVER_NAME_FILTER = '\u200b';

		[HarmonyPatch("ConfirmHostButton")]
		[HarmonyPrefix]
		private static void RemoveServerNameCharacter(MenuManager __instance)
		{
			if (Enumerable.Contains(__instance.lobbyNameInputField.text, SERVER_NAME_FILTER))
			{
				CCSPatchesConsole.LogInfo((object)"Detected zero-width character in the lobby name, removing the character...");
				__instance.lobbyNameInputField.text = __instance.lobbyNameInputField.text.Remove(__instance.lobbyNameInputField.text.IndexOf(SERVER_NAME_FILTER), 1);
				CCSPatchesConsole.LogInfo((object)"Zero-width removed from the lobby name, enjoy increased player volume!");
			}
			else
			{
				CCSPatchesConsole.LogInfo((object)"No zero-width character was detected in the lobby name.");
			}
		}
	}

	public const string PLUGIN_GUID = "ControlCompanySpoof";

	public const string PLUGIN_NAME = "ControlCompanySpoof";

	public const string PLUGIN_VERSION = "1.0.0";

	private readonly Harmony CCSHarmony = new Harmony("ControlCompanySpoof");

	private static CCSPlugin Instance;

	internal readonly ManualLogSource CCSConsole = Logger.CreateLogSource("ControlCompanySpoof");

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		CCSConsole.LogInfo((object)"Patching CCSPlugin...");
		Instance.CCSHarmony.PatchAll(typeof(CCSPlugin));
		CCSConsole.LogInfo((object)"Patching MenuManagerPatch...");
		Instance.CCSHarmony.PatchAll(typeof(LobbyListPatchPatch));
		CCSConsole.LogInfo((object)"All patches have been applied successfully!");
	}
}