Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MenuServerName v1.0.1
BepInEx/plugins/asm.MenuServerName/MenuServerName.dll
Decompiled 9 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("MenuServerName")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MenuServerName")] [assembly: AssemblyTitle("MenuServerName")] [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 MenuServerName { [BepInPlugin("MenuServerName", "MenuServerName", "1.0.0")] [HarmonyPatch] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static Harmony Harmony = new Harmony("MenuServerName"); private static string currentLobbyName = ""; private static TextMeshProUGUI currentLobbyText = null; private const string _quickMenuPath = "Systems/UI/Canvas/QuickMenu"; private const string _exampleTextPath = "Systems/UI/Canvas/QuickMenu/PlayerList/Image/PlayerListSlot/PlayerNameButton/PName"; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin MenuServerName is loaded!"); Harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; } [HarmonyPatch(typeof(LobbySlot), "JoinLobbyAfterVerifying")] [HarmonyPrefix] private static void JoinLobbyAfterVerifying(Lobby lobby, SteamId lobbyId) { currentLobbyName = ((Lobby)(ref lobby)).GetData("name"); } [HarmonyPatch(typeof(Lobby), "Join")] [HarmonyPrefix] private static void Join(Lobby __instance) { currentLobbyName = ((Lobby)(ref __instance)).GetData("name"); } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] [HarmonyPostfix] private static void CreateLobbyAsync(ref Task<Lobby?> __result, int maxMembers) { if (__result == null) { return; } __result.ContinueWith(delegate(Task<Lobby?> task) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!task.IsFaulted) { Lobby? result = task.Result; if (result.HasValue) { Lobby value = result.Value; currentLobbyName = ((Lobby)(ref value)).GetData("name"); ((TMP_Text)currentLobbyText).text = currentLobbyName; } } }); } private void OnSceneLoaded(Scene scene, LoadSceneMode lsm) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!(((Scene)(ref scene)).name == "SampleSceneRelay")) { return; } GameObject val = GameObject.Find("Systems/UI/Canvas/QuickMenu"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Could not find the original button to clone."); return; } GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/PlayerList/Image/PlayerListSlot/PlayerNameButton/PName"); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)"Could not find the original text to clone."); return; } GameObject obj = Object.Instantiate<GameObject>(val2, val.transform); obj.transform.localPosition = new Vector3(0f, 220f, 0f); ((Object)obj).name = "ServerName"; currentLobbyText = obj.GetComponent<TextMeshProUGUI>(); if ((Object)(object)currentLobbyText != (Object)null) { ((Graphic)currentLobbyText).raycastTarget = false; ((TMP_Text)currentLobbyText).text = "Server: " + currentLobbyName; ((TMP_Text)currentLobbyText).alignment = (TextAlignmentOptions)514; } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MenuServerName"; public const string PLUGIN_NAME = "MenuServerName"; public const string PLUGIN_VERSION = "1.0.0"; } }