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 PhotonServerSettings REPO v1.0.4
BepInEx/plugins/PhotonServerSettings/uk.1a3.photonserversettings.dll
Decompiled 4 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("uk.1a3.photonserversettings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+430c686002e3531f21cb28f71905988aaa979902")] [assembly: AssemblyProduct("PhotonServerSettings")] [assembly: AssemblyTitle("uk.1a3.photonserversettings")] [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 PhotonServerSettings { [BepInPlugin("uk.1a3.photonserversettings", "PhotonServerSettings", "1.0.4")] internal class PluginLoader : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("uk.1a3.photonserversettings"); private static bool initialized; internal static ConfigEntry<string> PhotonAppIdRealtime; internal static ConfigEntry<string> PhotonAppIdVoice; internal static ConfigEntry<string> PhotonServerAddress; internal static ConfigEntry<int> PhotonServerPort; internal static ConfigEntry<int> PhotonServerVersion; internal static ConfigEntry<string> PhotonConnectionProtocol; internal static ConfigEntry<bool> PhotonAlternativeUdpPorts; internal static ConfigEntry<int> PhotonObjectsInOneUpdate; internal static ConfigEntry<int> PhotonSendRate; internal static ManualLogSource StaticLogger { get; private set; } internal static ConfigFile StaticConfig { get; private set; } private void Awake() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown if (!initialized) { initialized = true; StaticLogger = ((BaseUnityPlugin)this).Logger; StaticConfig = ((BaseUnityPlugin)this).Config; PhotonAppIdRealtime = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "AppId Realtime", "", new ConfigDescription("Photon Realtime App ID", (AcceptableValueBase)null, Array.Empty<object>())); PhotonAppIdVoice = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "AppId Voice", "", new ConfigDescription("Photon Voice App ID", (AcceptableValueBase)null, Array.Empty<object>())); PhotonServerAddress = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "Server", "", new ConfigDescription("Photon Server Address", (AcceptableValueBase)null, Array.Empty<object>())); PhotonServerPort = ((BaseUnityPlugin)this).Config.Bind<int>("Photon", "Server Port", 0, new ConfigDescription("Photon Server Port", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 65535), Array.Empty<object>())); PhotonServerVersion = ((BaseUnityPlugin)this).Config.Bind<int>("Photon", "Server Version", 5, new ConfigDescription("Photon Server Version", (AcceptableValueBase)(object)new AcceptableValueRange<int>(4, 5), Array.Empty<object>())); PhotonConnectionProtocol = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "Protocol", "Udp", new ConfigDescription("Photon Protocol", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(ConnectionProtocol))), Array.Empty<object>())); PhotonAlternativeUdpPorts = ((BaseUnityPlugin)this).Config.Bind<bool>("Photon", "Alternative Udp Ports", true, new ConfigDescription("Photon Alternative Ports (Udp)", (AcceptableValueBase)null, Array.Empty<object>())); PhotonObjectsInOneUpdate = ((BaseUnityPlugin)this).Config.Bind<int>("Photon Networking", "Objects In One Update", 0, new ConfigDescription("Do not change this unless you know what you are doing. 0 = Vanilla", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); PhotonSendRate = ((BaseUnityPlugin)this).Config.Bind<int>("Photon Networking", "Send Rate", 0, new ConfigDescription("Do not change this unless you know what you are doing. 0 = Vanilla", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); harmony.PatchAll(typeof(GeneralPatches)); StaticLogger.LogInfo((object)"Patches Loaded"); } } } [HarmonyPatch] internal static class GeneralPatches { [HarmonyPatch(typeof(NetworkManager), "Start")] [HarmonyPostfix] [HarmonyWrapSafe] public static void NetworkManager_Start() { if (PluginLoader.PhotonSendRate.Value > 0) { PhotonNetwork.SendRate = PluginLoader.PhotonSendRate.Value; PhotonNetwork.SerializationRate = PluginLoader.PhotonSendRate.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed SendRate and SerializationRate"); } } [HarmonyPatch(typeof(DataDirector), "PhotonSetAppId")] [HarmonyPostfix] [HarmonyWrapSafe] public static void DataDirector_PhotonSetAppId_Postfix() { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) PhotonNetwork.PhotonServerSettings.AppSettings.Port = 0; PhotonNetwork.PhotonServerSettings.AppSettings.UseNameServer = true; PhotonNetwork.NetworkingClient.SerializationProtocol = (SerializationProtocol)1; if (PluginLoader.PhotonObjectsInOneUpdate.Value > 0) { PhotonNetwork.ObjectsInOneUpdate = PluginLoader.PhotonObjectsInOneUpdate.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed ObjectsInOneUpdate"); } if (!string.IsNullOrEmpty(PluginLoader.PhotonServerAddress.Value)) { PhotonNetwork.PhotonServerSettings.AppSettings.Server = PluginLoader.PhotonServerAddress.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed Server Address"); if (PluginLoader.PhotonServerVersion.Value == 4) { PhotonNetwork.PhotonServerSettings.AppSettings.UseNameServer = false; PhotonNetwork.NetworkingClient.SerializationProtocol = (SerializationProtocol)0; } if (PluginLoader.PhotonServerPort.Value > 0) { PhotonNetwork.PhotonServerSettings.AppSettings.Port = PluginLoader.PhotonServerPort.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed Server Port"); } } if (Enum.TryParse<ConnectionProtocol>(PluginLoader.PhotonConnectionProtocol.Value, out ConnectionProtocol result)) { PhotonNetwork.PhotonServerSettings.AppSettings.Protocol = result; PluginLoader.StaticLogger.LogInfo((object)$"Photon: Changed Protocol ({result})"); } else { PhotonNetwork.PhotonServerSettings.AppSettings.Protocol = (ConnectionProtocol)0; } if (PluginLoader.PhotonAlternativeUdpPorts.Value && (int)PhotonNetwork.PhotonServerSettings.AppSettings.Protocol == 0) { PhotonNetwork.ServerPortOverrides = PhotonPortDefinition.AlternativeUdpPorts; } else { PhotonNetwork.ServerPortOverrides = default(PhotonPortDefinition); } if (!string.IsNullOrEmpty(PluginLoader.PhotonAppIdRealtime.Value)) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime = PluginLoader.PhotonAppIdRealtime.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed AppIdRealtime"); } if (!string.IsNullOrEmpty(PluginLoader.PhotonAppIdVoice.Value)) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice = PluginLoader.PhotonAppIdVoice.Value; PluginLoader.StaticLogger.LogInfo((object)"Photon: Changed AppIdVoice"); } } [HarmonyPatch(typeof(DataDirector), "PhotonSetRegion")] [HarmonyPostfix] [HarmonyWrapSafe] public static void DataDirector_PhotonSetRegion_Postfix() { if (!string.IsNullOrEmpty(PluginLoader.PhotonServerAddress.Value) && PluginLoader.PhotonServerVersion.Value == 4) { PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = ""; PluginLoader.StaticLogger.LogInfo((object)"Photon: Cleared Region"); } } [HarmonyPatch(typeof(SteamManager), "SendSteamAuthTicket")] [HarmonyPostfix] [HarmonyWrapSafe] public static void SteamManager_SendSteamAuthTicket_Postfix() { if (!string.IsNullOrEmpty(PluginLoader.PhotonServerAddress.Value) || !string.IsNullOrEmpty(PluginLoader.PhotonAppIdRealtime.Value) || !string.IsNullOrEmpty(PluginLoader.PhotonAppIdVoice.Value)) { PhotonNetwork.AuthValues.AuthType = (CustomAuthenticationType)255; PluginLoader.StaticLogger.LogInfo((object)"Photon: Cleared Auth Type"); } } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "uk.1a3.photonserversettings"; public const string PLUGIN_NAME = "PhotonServerSettings"; public const string PLUGIN_VERSION = "1.0.4"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }