using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib.BoneMenu;
using LabFusion.Data;
using LabFusion.Network;
using LabFusion.SDK.Lobbies;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using QuickServerHide;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(QuickServerHideMod), "QuickServerHide", "1.0.0", "nontendo", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuickServerHide")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuickServerHide")]
[assembly: AssemblyTitle("QuickServerHide")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
}
namespace QuickServerHide
{
public class QuickServerHideMod : MelonMod
{
public override void OnInitializeMelon()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
ServerHideSettings.Initialize();
ServerHideFilter.Initialize();
ServerHideMenu.Build(Page.Root.CreatePage("QuickServerHide", new Color(0.6f, 0.2f, 0.8f), 0, true));
((MelonBase)this).LoggerInstance.Msg("QuickServerHide loaded!");
}
}
public static class ServerHideFilter
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static GenericLobbyDelegate <>9__1_0;
internal bool <Initialize>b__1_0(INetworkLobby lobby, LobbyMetadataInfo info)
{
LobbyInfo lobbyInfo = ((LobbyMetadataInfo)(ref info)).LobbyInfo;
return !ContainsBlockedKeyword((lobbyInfo != null) ? lobbyInfo.LobbyName : null);
}
}
private static GenericLobbyFilter? _filter;
public static void Initialize()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
object obj = <>c.<>9__1_0;
if (obj == null)
{
GenericLobbyDelegate val = delegate(INetworkLobby lobby, LobbyMetadataInfo info)
{
LobbyInfo lobbyInfo = ((LobbyMetadataInfo)(ref info)).LobbyInfo;
return !ContainsBlockedKeyword((lobbyInfo != null) ? lobbyInfo.LobbyName : null);
};
<>c.<>9__1_0 = val;
obj = (object)val;
}
_filter = new GenericLobbyFilter("Hide Keyword Servers", (GenericLobbyDelegate)obj);
_filter.SetActive(ServerHideSettings.Enabled);
LobbyFilterManager.AddLobbyFilter((ILobbyFilter)(object)_filter);
}
public static void SetActive(bool active)
{
GenericLobbyFilter? filter = _filter;
if (filter != null)
{
filter.SetActive(active);
}
}
private static bool ContainsBlockedKeyword(string? name)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
try
{
foreach (string keyword in ServerHideSettings.Keywords)
{
if (keyword.Length != 0 && name.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
}
catch (Exception ex)
{
MelonLogger.Warning("[QuickServerHide] Keyword check failed, showing server: " + ex.Message);
return false;
}
return false;
}
}
public static class ServerHideMenu
{
private static Page? _managePage;
private static readonly List<Element> _manageElements = new List<Element>();
public static void Build(Page root)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
root.CreateBool("Enabled", Color.white, ServerHideSettings.Enabled, (Action<bool>)delegate(bool v)
{
ServerHideSettings.Enabled = v;
});
root.CreateString("Add Keyword", Color.white, "", (Action<string>)OnAddKeyword);
_managePage = root.CreatePage("Manage Keywords", new Color(0.9f, 0.35f, 0.15f), 0, true);
RefreshManagePage();
}
private static void OnAddKeyword(string keyword)
{
ServerHideSettings.Add(keyword);
RefreshManagePage();
}
private static void RefreshManagePage()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if (_managePage == null)
{
return;
}
if (_manageElements.Count > 0)
{
_managePage.Remove(_manageElements.ToArray());
_manageElements.Clear();
}
if (ServerHideSettings.Keywords.Count == 0)
{
_manageElements.Add((Element)(object)_managePage.CreateFunction("(no keywords set)", Color.gray, (Action)delegate
{
}));
return;
}
foreach (string keyword in ServerHideSettings.Keywords)
{
string captured = keyword;
Element item = (Element)(object)_managePage.CreateFunction("Remove: " + keyword, Color.red, (Action)delegate
{
ServerHideSettings.Remove(captured);
RefreshManagePage();
});
_manageElements.Add(item);
}
}
}
public static class ServerHideSettings
{
private const string DefaultKeywords = "Hood|Ru Only|French Only|French|Russian";
private const char Delimiter = '|';
private static MelonPreferences_Category _cat = null;
private static MelonPreferences_Entry<bool> _enabled = null;
private static MelonPreferences_Entry<string> _keywordsRaw = null;
private static List<string> _keywords = new List<string>();
public static IReadOnlyList<string> Keywords => _keywords;
public static bool Enabled
{
get
{
return _enabled.Value;
}
set
{
_enabled.Value = value;
_cat.SaveToFile(false);
ServerHideFilter.SetActive(value);
}
}
public static void Initialize()
{
_cat = MelonPreferences.CreateCategory("QuickServerHide");
_enabled = _cat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
_keywordsRaw = _cat.CreateEntry<string>("Keywords", "Hood|Ru Only|French Only|French|Russian", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
LoadKeywords();
}
private static void LoadKeywords()
{
_keywords = (from k in _keywordsRaw.Value.Split('|')
select k.Trim() into k
where k.Length > 0
select k).ToList();
}
private static void SaveKeywords()
{
_keywordsRaw.Value = string.Join('|'.ToString(), _keywords);
_cat.SaveToFile(false);
}
public static void Add(string keyword)
{
keyword = (keyword ?? "").Trim();
if (keyword.Length != 0 && !_keywords.Any((string k) => k.Equals(keyword, StringComparison.OrdinalIgnoreCase)))
{
_keywords.Add(keyword);
SaveKeywords();
}
}
public static void Remove(string keyword)
{
if (_keywords.RemoveAll((string k) => k.Equals(keyword, StringComparison.OrdinalIgnoreCase)) > 0)
{
SaveKeywords();
}
}
}
}