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 MorePlayersImproved v1.0.2
MorePlayers.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using Steamworks; using Steamworks.Data; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace MorePlayers; [BepInPlugin("spindles.MorePlayersImproved", "MorePlayersImproved", "1.0.2")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(NetworkConnect), "TryJoiningRoom")] public class TryJoiningRoomPatch { private static bool Prefix(ref string ___RoomName) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown string value = Traverse.Create((object)DataDirector.instance).Field("networkPassword").GetValue() as string; if (string.IsNullOrEmpty(___RoomName)) { mls.LogError((object)"RoomName is null or empty, using previous method!"); return true; } if (configMaxPlayers.Value == 0) { mls.LogError((object)"The MaxPlayers config is null or empty, using previous method!"); return true; } Debug.Log((object)("Trying to join room: " + ___RoomName)); Hashtable val = new Hashtable(); ((Dictionary<object, object>)(object)val).Add((object)"PASSWORD", (object)value); PhotonNetwork.LocalPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); RoomOptions val2 = new RoomOptions { MaxPlayers = configMaxPlayers.Value, IsVisible = false }; Hashtable val3 = new Hashtable(); ((Dictionary<object, object>)(object)val3).Add((object)"PASSWORD", (object)value); val2.CustomRoomProperties = val3; PhotonNetwork.JoinOrCreateRoom(___RoomName, val2, TypedLobby.Default, (string[])null); return false; } } [HarmonyPatch(typeof(NetworkConnect), "OnConnectedToMaster")] public class OnConnectedToMasterPatch { private static bool Prefix() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0142: Expected O, but got Unknown if (!configPublicLobbySupport.Value) { return true; } _ = (Lobby)Traverse.Create((object)SteamManager.instance).Field("currentLobby").GetValue(); bool flag = (bool)Traverse.Create((object)GameManager.instance).Field("connectRandom").GetValue(); _ = (string)Traverse.Create((object)DataDirector.instance).Field("networkPassword").GetValue(); string text = (string)Traverse.Create((object)DataDirector.instance).Field("networkServerName").GetValue(); _ = (string)Traverse.Create((object)DataDirector.instance).Field("networkJoinServerName").GetValue(); if (string.IsNullOrEmpty(text)) { mls.LogError((object)"RoomName is null or empty, using previous method!"); return true; } if (configMaxPlayers.Value == 0) { mls.LogError((object)"The MaxPlayers config is null or empty, using previous method!"); return true; } Debug.Log((object)"Connected to Master Server"); if (flag) { if (!string.IsNullOrEmpty(text)) { Debug.Log((object)("I am creating a custom open lobby named: " + text)); RoomOptions val = new RoomOptions(); val.CustomRoomPropertiesForLobby = new string[1] { "server_name" }; Hashtable val2 = new Hashtable(); ((Dictionary<object, object>)val2).Add((object)"server_name", (object)("[Modded] " + text)); val.CustomRoomProperties = val2; val.MaxPlayers = configMaxPlayers.Value; val.IsVisible = true; PhotonNetwork.CreateRoom((string)null, val, DataDirector.instance.customLobby, (string[])null); return false; } return true; } return true; } } [HarmonyPatch(typeof(SteamManager), "HostLobby")] public class HostLobbyPatch { private static bool Prefix() { HostLobbyAsync(); return false; } private static async void HostLobbyAsync() { Debug.Log((object)"Steam: Hosting lobby..."); Lobby? val = await SteamMatchmaking.CreateLobbyAsync(configMaxPlayers.Value); if (!val.HasValue) { Debug.LogError((object)"Lobby created but not correctly instantiated."); return; } Lobby value = val.Value; ((Lobby)(ref value)).SetPublic(); value = val.Value; ((Lobby)(ref value)).SetJoinable(false); } } public const string modGUID = "spindles.MorePlayersImproved"; public const string modName = "MorePlayersImproved"; public const string modVersion = "1.0.2"; private readonly Harmony harmony = new Harmony("spindles.MorePlayersImproved"); public static ConfigEntry<int> configMaxPlayers; public static ConfigEntry<bool> configPublicLobbySupport; public static ManualLogSource mls; private void Awake() { mls = Logger.CreateLogSource("spindles.MorePlayersImproved"); mls.LogInfo((object)"spindles.MorePlayersImproved has awoken!"); configMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, "The max amount of players allowed in a server"); configPublicLobbySupport = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PublicLobbySupport", true, "Toggles if public lobby support is enabled"); harmony.PatchAll(typeof(TryJoiningRoomPatch)); harmony.PatchAll(typeof(HostLobbyPatch)); mls.LogInfo((object)"spindles.MorePlayersImproved loaded main patches!"); if (typeof(SteamManager).GetRuntimeMethod("UnlockLobby", new Type[1] { typeof(bool) }) != null) { harmony.PatchAll(typeof(OnConnectedToMasterPatch)); mls.LogInfo((object)"spindles.MorePlayersImproved enabled PublicLobbySupport!"); } mls.LogInfo((object)"spindles.MorePlayersImproved is ready now!"); } }