using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GUIFramework; using HarmonyLib; using Landoria.SharedLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Landoria.NoServerPassword")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Landoria.NoServerPassword")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("C424AE43-8596-4E8C-9517-0B4BF2927364")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.17312")] namespace Landoria.NoServerPassword { [HarmonyPatch(typeof(FejdStartup), "GetPublicPasswordError")] internal static class PublicPasswordErrorPatch { private static bool Prefix(string password, ref string __result) { if (!string.IsNullOrEmpty(password)) { return true; } __result = string.Empty; return false; } } [HarmonyPatch(typeof(FejdStartup), "IsPublicPasswordValid")] internal static class PublicPasswordValidationPatch { private static bool Prefix(string password, ref bool __result) { if (!string.IsNullOrEmpty(password)) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(FejdStartup), "CanStartServer")] internal static class CanStartServerPatch { private static void Postfix(GuiInputField ___m_serverPassword, World ___m_world, ref bool __result) { if (!__result && IsEmpty(___m_serverPassword) && CanStartWorld(___m_world)) { __result = true; } } private static bool IsEmpty(GuiInputField passwordField) { return string.IsNullOrEmpty((passwordField != null) ? ((TMP_InputField)passwordField).text : null); } private static bool CanStartWorld(World world) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (world != null) { return (int)world.m_dataError == 0; } return false; } } [HarmonyPatch(typeof(FejdStartup), "UpdatePasswordError")] internal static class PasswordErrorDisplayPatch { private static void Postfix(GuiInputField ___m_serverPassword, TMP_Text ___m_passwordError) { if (string.IsNullOrEmpty((___m_serverPassword != null) ? ((TMP_InputField)___m_serverPassword).text : null) && (Object)(object)___m_passwordError != (Object)null) { ___m_passwordError.text = string.Empty; } } } [BepInPlugin("Landoria.NoServerPassword", "Landoria.NoServerPassword", "1.0.0")] public sealed class NoServerPasswordPlugin : LandoriaPlugin { private const string PluginGuid = "Landoria.NoServerPassword"; private const string PluginName = "Landoria.NoServerPassword"; private const string PluginVersion = "1.0.0"; internal static ModLog Log { get; private set; } private void Awake() { Log = InitializePlugin("Landoria.NoServerPassword"); Log.LogInfo("Landoria.NoServerPassword 1.0.0 is loaded."); } private void OnDestroy() { ShutdownPlugin(); Log = null; } } } namespace Landoria.SharedLib { public abstract class LandoriaPlugin : BaseUnityPlugin { private Harmony _harmony; private bool _patchesApplied; protected ModLog InitializePlugin(string pluginGuid) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown ModLog modLog = new ModLog(((BaseUnityPlugin)this).Logger); Version version = ((object)this).GetType().Assembly.GetName().Version; modLog.LogInfo($"AssemblyVersion: {version}."); _harmony = new Harmony(pluginGuid); PatchOwnNamespace(modLog); return modLog; } protected void PatchOwnNamespace(ModLog log) { if (_patchesApplied) { log.LogDebug("Harmony patches are already active; skipping registration."); return; } string text = ((object)this).GetType().Namespace; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.Namespace == text) { _harmony.CreateClassProcessor(type).Patch(); } } _patchesApplied = true; log.LogDebug("Harmony patches were applied for the plugin namespace."); } protected void ShutdownPlugin() { if (_patchesApplied) { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _patchesApplied = false; } } } public sealed class ModLog { private readonly ManualLogSource _logger; public ModLog(ManualLogSource logger) { _logger = logger; } public void LogFatal(object message) { Write((LogLevel)1, message); } public void LogError(object message) { Write((LogLevel)2, message); } public void LogWarning(object message) { Write((LogLevel)4, message); } public void LogMessage(object message) { Write((LogLevel)8, message); } public void LogInfo(object message) { Write((LogLevel)16, message); } public void LogDebug(object message) { Write((LogLevel)32, message); } public void Log(LogLevel level, object message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Write(level, message); } private void Write(LogLevel level, object message) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string arg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.Log(level, (object)$"[{arg}] {message}"); } } }