Decompiled source of MorePlayersSimple v1.0.1

plugins/MorePlayersSimple.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Realtime;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MorePlayersSimple")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorePlayersSimple")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e414bffa-f261-43ba-b6c5-3c2f5941d3af")]
[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 MorePlayersSimple;

[BepInPlugin("dyxc666.MorePlayersSimple", "More Players Simple", "1.0.1")]
public class MorePlayersSimplePlugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	public static ConfigEntry<int> MaxPlayers;

	private readonly Harmony harmony = new Harmony("dyxc666.MorePlayersSimple");

	private void Awake()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		MaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, new ConfigDescription("Maximum number of players allowed in a room.\n修改后需重新开房生效。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		harmony.PatchAll();
		Log.LogInfo((object)$"More Players Simple loaded! MaxPlayers = {MaxPlayers.Value}");
	}
}
[HarmonyPatch(typeof(LoadBalancingClient), "OpCreateRoom")]
internal static class OpCreateRoomPatch
{
	[HarmonyPrefix]
	public static bool Prefix(EnterRoomParams enterRoomParams)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		if (enterRoomParams.RoomOptions == null)
		{
			enterRoomParams.RoomOptions = new RoomOptions();
		}
		int value = MorePlayersSimplePlugin.MaxPlayers.Value;
		enterRoomParams.RoomOptions.MaxPlayers = value;
		enterRoomParams.RoomOptions.PlayerTtl = 0;
		enterRoomParams.RoomOptions.EmptyRoomTtl = 0;
		MorePlayersSimplePlugin.Log.LogInfo((object)$"RoomOptions.MaxPlayers set to {value}");
		return true;
	}
}
[HarmonyPatch(typeof(LoadBalancingClient), "OpJoinOrCreateRoom")]
internal static class OpJoinOrCreateRoomPatch
{
	[HarmonyPrefix]
	public static bool Prefix(EnterRoomParams enterRoomParams)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		if (enterRoomParams.RoomOptions == null)
		{
			enterRoomParams.RoomOptions = new RoomOptions();
		}
		int value = MorePlayersSimplePlugin.MaxPlayers.Value;
		enterRoomParams.RoomOptions.MaxPlayers = value;
		enterRoomParams.RoomOptions.PlayerTtl = 0;
		enterRoomParams.RoomOptions.EmptyRoomTtl = 0;
		MorePlayersSimplePlugin.Log.LogInfo((object)$"[JoinOrCreate] RoomOptions.MaxPlayers set to {value}");
		return true;
	}
}