using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using Zen;
using Zen.Lib;
using Zen.Lib.Config;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ZenLogin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZenLogin")]
[assembly: AssemblyCopyright("Copyright \ufffd 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 ZenLogin
{
internal static class Configs
{
public static readonly ConfigEntry<bool> Enabled;
public static readonly ConfigEntry<string> ServerAddress;
public static readonly ConfigEntry<string> ServerPassword;
static Configs()
{
Enabled = Config.Define<bool>(false, "General", "Enabled", true, "When enabled, automatically connect to the dedicated server after character selection.\r\nNOTE: You can temporarily disable this by holding the Alt key before clicking \"Connect\"");
ServerAddress = Config.Define<string>(false, "General", "Server Address", string.Empty, "Host or IP address and port of the dedicated server. (Example: 127.0.0.1:2457)");
ServerPassword = Config.Define<string>(false, "General", "Server Password", string.Empty, "If left blank and the server requires a password it will prompt the user for the password.");
}
}
[HarmonyPatch]
internal static class Login
{
private static bool _disableAddToRecentServersList;
private static bool IsAltKeyPressed
{
get
{
if (!ZInput.GetKey((KeyCode)308, true))
{
return ZInput.GetKey((KeyCode)307, true);
}
return true;
}
}
private static bool IsValid
{
get
{
if (Configs.Enabled.Value && !IsAltKeyPressed)
{
return !Utility.IsNullOrWhiteSpace(Configs.ServerAddress.Value);
}
return false;
}
}
private static void InitConnection()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
bool flag = !Utility.IsNullOrWhiteSpace(Configs.ServerPassword.Value);
Logging<Plugin>.Info((object)$"Connecting to server {Configs.ServerAddress.Value}, with password? {flag}", 0);
FejdStartup.ServerPassword = (flag ? Configs.ServerPassword.Value : null);
FejdStartup.instance.m_queuedJoinServer = new ServerJoinData(new ServerJoinDataDedicated(Configs.ServerAddress.Value));
_disableAddToRecentServersList = true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FejdStartup), "OnCharacterStart")]
private static void FejdStartup_OnCharacterStart(FejdStartup __instance)
{
if (IsValid)
{
InitConnection();
}
else
{
Logging<Plugin>.Info((object)"Auto connect disabled", 0);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FejdStartup), "Update")]
private static void FejdStartup_Update(FejdStartup __instance)
{
string text = (IsValid ? "$menu_connect" : "$menu_start");
((Component)((Component)__instance.m_csStartButton).transform.Find("Text")).GetComponent<TMP_Text>().text = StringExt.Localize(text);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ServerListGui), "AddToRecentServersList")]
private static void ServerListGui_AddToRecentServersList(ref bool __runOriginal)
{
__runOriginal = !_disableAddToRecentServersList;
_disableAddToRecentServersList = false;
}
}
[BepInPlugin("ZenDragon.ZenLogin", "ZenLogin", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class Plugin : ZenMod<Plugin>
{
public const string PluginName = "ZenLogin";
public const string PluginVersion = "1.0.0";
public const string PluginGUID = "ZenDragon.ZenLogin";
protected override void Setup()
{
}
protected override void TitleScene(bool isFirstBoot)
{
}
protected override void WorldStart()
{
}
protected override void Shutdown()
{
}
}
}