using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UIElements.Collections;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("baer1.SteamBlacklist")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1+e4cae5ea487582ab40038061e0c2c1e054b15c46")]
[assembly: AssemblyProduct("SteamBlacklist")]
[assembly: AssemblyTitle("baer1.SteamBlacklist")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.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.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 SteamBlacklist
{
[BepInPlugin("baer1.SteamBlacklist", "SteamBlacklist", "1.4.1")]
public class SteamBlacklist : BaseUnityPlugin
{
[HarmonyPatch(typeof(MenuManager), "Awake")]
public class CheckLobbyCompatibilityPatch
{
private static void Prefix(MenuManager __instance)
{
if (Instance.DisplayedIncompatibilityPopup > 2)
{
return;
}
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (!(value.Metadata.GUID != "BMX.LobbyCompatibility"))
{
Instance.DisplayedIncompatibilityPopup++;
if (Instance.DisplayedIncompatibilityPopup == 1)
{
break;
}
Logger.LogWarning((object)"LobbyCompatibility detected, please uninstall it as it is incompatible with SteamBlacklist");
GameObject val = GameObject.Find("/Canvas/MenuContainer/");
GameObject val2 = GameObject.Find("Canvas/MenuContainer/LANWarning/");
if ((Object)(object)val2 == (Object)null)
{
break;
}
GameObject val3 = Object.Instantiate<GameObject>(val2, val.transform);
((Object)val3).name = "LOBBYCOMPATIBILITY_POPUP";
val3.SetActive(true);
Transform val4 = val3.transform.Find("Panel/NotificationText");
TextMeshProUGUI component = ((Component)val4).GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = "LobbyCompatibility detected\nPlease uninstall it as it is incompatible with the SteamBlacklist mod";
}
}
}
}
[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")]
public class SteamPlayerJoinPatch
{
private static bool Prefix(Lobby lobby, Friend friend)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected I4, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
Logger.LogDebug((object)$" >> SteamPlayerJoinPatch (SteamMatchmaking_OnLobbyMemberJoined) STEAM PLAYER JOINED {((Friend)(ref friend)).Name} {friend.Id} {((Friend)(ref friend)).Relationship}");
if (!GameNetworkManager.Instance.isHostingGame)
{
Logger.LogDebug((object)$" << SteamPlayerJoinPatch NOT HOST {((Friend)(ref friend)).Name} ({friend.Id}) [{((Friend)(ref friend)).Relationship}]");
return true;
}
bool flag = true;
if (SteamId.op_Implicit(friend.Id) == SteamId.op_Implicit(((Lobby)(ref lobby)).Owner.Id))
{
Logger.LogInfo((object)("Host joined: " + ((Friend)(ref friend)).Name));
Logger.LogDebug((object)$" << SteamPlayerJoinPatch HOST {((Friend)(ref friend)).Name} {friend.Id}");
return true;
}
if (GameNetworkManager.Instance.currentLobby.HasValue)
{
Relationship relationship = ((Friend)(ref friend)).Relationship;
Relationship val = relationship;
switch ((int)val)
{
case 5:
Logger.LogInfo((object)$"Blocked player rejected: {((Friend)(ref friend)).Name} ({friend.Id})");
flag = false;
break;
case 6:
{
string arg;
if (Instance.AllowBlockedFriends.Value)
{
arg = "allowed";
}
else
{
arg = "rejected";
flag = false;
}
Logger.LogInfo((object)$"Blocked friend {arg}: {((Friend)(ref friend)).Name} ({friend.Id})");
break;
}
case 3:
Logger.LogInfo((object)$"Friend joined: {((Friend)(ref friend)).Name} ({friend.Id})");
break;
case 0:
Logger.LogInfo((object)$"Player joined: {((Friend)(ref friend)).Name} ({friend.Id})");
break;
case 4:
Logger.LogInfo((object)$"Player joined: {((Friend)(ref friend)).Name} ({friend.Id})");
Logger.LogInfo((object)"You have sent them a friend request");
break;
case 2:
Logger.LogInfo((object)$"Player joined: {((Friend)(ref friend)).Name} ({friend.Id})");
Logger.LogInfo((object)"They have sent you a friend request");
break;
case 1:
Logger.LogInfo((object)$"Player joined: {((Friend)(ref friend)).Name} ({friend.Id})");
Logger.LogInfo((object)"You have ignored their friend request");
break;
default:
Logger.LogInfo((object)$"Player joined: {((Friend)(ref friend)).Name} ({friend.Id}) [Relationship: {((Friend)(ref friend)).Relationship}]");
break;
}
}
Instance.SteamJoinQueue.TryAdd(SteamId.op_Implicit(friend.Id), flag);
Logger.LogDebug((object)(" << SteamPlayerJoinPatch " + (flag ? "ALLOW" : "DENY") + $" {((Friend)(ref friend)).Name} {friend.Id}"));
return true;
}
}
[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
public class PlayerJoinPatch
{
private static bool Prefix(ConnectionApprovalRequest request, ConnectionApprovalResponse response)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
Logger.LogDebug((object)$" >> PlayerJoinPatch (ConnectionApproval) UNITY-NETCODE PLAYER CONNECTED {request.ClientNetworkId} {request.Payload}");
if (GameNetworkManager.Instance.disableSteam)
{
Logger.LogDebug((object)" << PlayerJoinPatch STEAM DISABLED");
return true;
}
if (request.ClientNetworkId == 0)
{
Logger.LogDebug((object)" << PlayerJoinPatch HOST");
Logger.LogDebug((object)$" >> StartHostPatch (None) Resetting SteamJoinQueue (was {Instance.SteamJoinQueue.Count} items)");
Instance.SteamJoinQueue.Clear();
Logger.LogDebug((object)$" << StartHostPatch RESET SteamJoinQueue {Instance.SteamJoinQueue.Count}");
return true;
}
string[] array;
ulong num;
try
{
array = Encoding.ASCII.GetString(request.Payload).Split(",");
num = (ulong)Convert.ToInt64(array[1]);
Logger.LogDebug((object)$" >> STEAMID={num} - PAYLOAD={array}");
}
catch (Exception)
{
Logger.LogDebug((object)$"Received invalid approval request: {request.Payload}");
return false;
}
Logger.LogDebug((object)$"Received approval request: {num}");
bool? flag;
try
{
flag = DictionaryExtensions.Get<ulong, bool>((IDictionary<ulong, bool>)Instance.SteamJoinQueue, num, false);
}
catch (KeyNotFoundException)
{
flag = null;
}
if (flag.HasValue && flag.Value)
{
Instance.SteamJoinQueue.Remove(num);
Logger.LogDebug((object)$" << PlayerJoinPatch ALLOW {request.ClientNetworkId} {array[1]}");
Logger.LogDebug((object)$"Playing with {num} - notifying steam...");
SteamFriends.SetPlayedWith(SteamId.op_Implicit(num));
return true;
}
response.Reason = (flag.HasValue ? "You have been blacklisted!" : "Invalid SteamID, please remove any AntiKick mods!");
response.CreatePlayerObject = false;
response.Approved = false;
response.Pending = false;
Logger.LogInfo((object)string.Format("Denied approval request: {0} - {1}!", num, response.Reason.Split(",")[0].Replace("!", "")));
Instance.SteamJoinQueue.Remove(num);
Logger.LogDebug((object)$" << PlayerJoinPatch DENY {request.ClientNetworkId} {response.Reason}");
return false;
}
}
[HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")]
private class JoinGamePatch
{
private static bool Prefix(Lobby lobby, ref bool __result)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected I4, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Expected I4, but got Unknown
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0492: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0458: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_056d: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04da: Unknown result type (might be due to invalid IL or missing references)
//IL_066d: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
((Lobby)(ref lobby)).Refresh();
string text = null;
Friend owner = ((Lobby)(ref lobby)).Owner;
Relationship relationship = ((Friend)(ref owner)).Relationship;
Relationship val = relationship;
switch ((int)val)
{
case 5:
{
ManualLogSource logger8 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger8.LogInfo((object)$"Lobby hosted by blocked player: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
text = "Lobby is hosted by a blocked player!";
break;
}
case 6:
{
if (!Instance.AllowBlockedFriends.Value)
{
text = "Lobby is hosted by a blocked friend!";
}
ManualLogSource logger7 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger7.LogInfo((object)$"Lobby is hosted by a blocked friend: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
break;
}
case 3:
{
ManualLogSource logger6 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger6.LogInfo((object)$"Lobby host (Friend): {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
break;
}
case 0:
{
ManualLogSource logger5 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger5.LogInfo((object)$"Lobby host: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
break;
}
case 4:
{
ManualLogSource logger4 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger4.LogInfo((object)$"Lobby host: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
Logger.LogInfo((object)"You have sent them a friend request");
break;
}
case 2:
{
ManualLogSource logger3 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger3.LogInfo((object)$"Lobby host: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
Logger.LogInfo((object)"They have sent you a friend request");
break;
}
case 1:
{
ManualLogSource logger2 = Logger;
owner = ((Lobby)(ref lobby)).Owner;
logger2.LogInfo((object)$"Lobby host: {((Friend)(ref owner)).Name} ({((Lobby)(ref lobby)).Owner.Id})");
Logger.LogInfo((object)"You have ignored their friend request");
break;
}
default:
{
ManualLogSource logger = Logger;
owner = ((Lobby)(ref lobby)).Owner;
string name = ((Friend)(ref owner)).Name;
object arg = ((Lobby)(ref lobby)).Owner.Id;
owner = ((Lobby)(ref lobby)).Owner;
logger.LogInfo((object)$"Lobby host: {name} ({arg}) [Relationship: {((Friend)(ref owner)).Relationship}]");
break;
}
}
if (text != null)
{
Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)11, text);
__result = false;
return false;
}
foreach (Friend member in ((Lobby)(ref lobby)).Members)
{
Friend current = member;
if (Instance.IgnoreBlockedMembers.Value)
{
break;
}
if (SteamId.op_Implicit(current.Id) == SteamId.op_Implicit(((Lobby)(ref lobby)).Owner.Id))
{
continue;
}
Relationship relationship2 = ((Friend)(ref current)).Relationship;
Relationship val2 = relationship2;
switch ((int)val2)
{
case 5:
Logger.LogInfo((object)$"Lobby contains a blocked player: {((Friend)(ref current)).Name} ({current.Id})");
text = "Lobby contains a blocked player!";
break;
case 6:
if (!Instance.AllowBlockedFriends.Value)
{
text = "Lobby contains a blocked friend!";
}
Logger.LogInfo((object)$"Lobby contains a blocked friend: {((Friend)(ref current)).Name} ({current.Id})");
break;
case 3:
Logger.LogInfo((object)$"Lobby member (Friend): {((Friend)(ref current)).Name} ({current.Id})");
break;
case 0:
Logger.LogInfo((object)$"Lobby member: {((Friend)(ref current)).Name} ({current.Id})");
break;
case 4:
Logger.LogInfo((object)$"Lobby member: {((Friend)(ref current)).Name} ({current.Id})");
Logger.LogInfo((object)"You have sent them a friend request");
break;
case 2:
Logger.LogInfo((object)$"Lobby member: {((Friend)(ref current)).Name} ({current.Id})");
Logger.LogInfo((object)"They have sent you a friend request");
break;
case 1:
Logger.LogInfo((object)$"Lobby member: {((Friend)(ref current)).Name} ({current.Id})");
Logger.LogInfo((object)"You have ignored their friend request");
break;
default:
Logger.LogInfo((object)$"Lobby member: {((Friend)(ref current)).Name} ({current.Id}) [Relationship: {((Friend)(ref current)).Relationship}]");
break;
}
if (text == null)
{
continue;
}
Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)11, text);
__result = false;
return false;
}
try
{
string data = ((Lobby)(ref lobby)).GetData("vers");
if (data != GameNetworkManager.Instance.gameVersionNum.ToString())
{
Logger.LogDebug((object)$" == Lobby join denied! Invalid version: '{data}' lobby id: '{((Lobby)(ref lobby)).Id}'");
Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)5, $"Invalid version\nLobby: {data}\nClient: {GameNetworkManager.Instance.gameVersionNum}");
return false;
}
if (((Lobby)(ref lobby)).GetData("joinable") == "false")
{
Logger.LogDebug((object)" == Lobby join denied! Host lobby is not joinable");
Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)3, "The server host has already landed their ship.");
__result = false;
return false;
}
if (((Lobby)(ref lobby)).MemberCount >= 4 || ((Lobby)(ref lobby)).MemberCount < 1)
{
Logger.LogDebug((object)$" == Lobby join denied! Invalid member count {((Lobby)(ref lobby)).MemberCount} lobby id: '{((Lobby)(ref lobby)).Id}'");
Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)4, "The server is full!");
__result = false;
return false;
}
Logger.LogDebug((object)$" == Lobby join accepted! Lobby id {((Lobby)(ref lobby)).Id} is OK");
__result = true;
}
catch (Exception ex)
{
Logger.LogError((object)("Lobby join denied! Error: " + ex.StackTrace));
__result = false;
}
return false;
}
}
[HarmonyPatch(typeof(SteamLobbyManager), "LoadServerList")]
public class LobbyListPatch
{
private static bool Prefix()
{
_Prefix();
return false;
}
private static async void _Prefix()
{
SteamLobbyManager lobbymanager = Object.FindObjectOfType<SteamLobbyManager>();
if (GameNetworkManager.Instance.waitingForLobbyDataRefresh)
{
return;
}
lobbymanager.refreshServerListTimer = 0f;
((TMP_Text)lobbymanager.serverListBlankText).text = "Loading server list...";
lobbymanager.currentLobbyList = null;
LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>();
LobbySlot[] array2 = array;
foreach (LobbySlot slot in array2)
{
Object.Destroy((Object)(object)((Component)slot).gameObject);
}
LobbyQuery val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).WithMaxResults(20);
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).WithKeyValue("started", "0");
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).WithKeyValue("versNum", GameNetworkManager.Instance.gameVersionNum.ToString());
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).WithSlotsAvailable(1);
switch (lobbymanager.sortByDistanceSetting)
{
case 0:
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).FilterDistanceClose();
break;
case 1:
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).FilterDistanceFar();
break;
case 2:
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).FilterDistanceWorldwide();
break;
}
lobbymanager.currentLobbyList = null;
Debug.Log((object)"Requested server list");
GameNetworkManager.Instance.waitingForLobbyDataRefresh = true;
val = SteamMatchmaking.LobbyList;
((LobbyQuery)(ref val)).WithSlotsAvailable(1);
int sortByDistanceSetting = lobbymanager.sortByDistanceSetting;
if (1 == 0)
{
}
LobbyQuery val2;
switch (sortByDistanceSetting)
{
case 0:
val2 = SteamMatchmaking.LobbyList;
val2 = ((LobbyQuery)(ref val2)).FilterDistanceClose();
val2 = ((LobbyQuery)(ref val2)).WithSlotsAvailable(1);
val = ((LobbyQuery)(ref val2)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString());
break;
case 1:
val2 = SteamMatchmaking.LobbyList;
val2 = ((LobbyQuery)(ref val2)).FilterDistanceFar();
val2 = ((LobbyQuery)(ref val2)).WithSlotsAvailable(1);
val = ((LobbyQuery)(ref val2)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString());
break;
default:
val2 = SteamMatchmaking.LobbyList;
val2 = ((LobbyQuery)(ref val2)).FilterDistanceWorldwide();
val2 = ((LobbyQuery)(ref val2)).WithSlotsAvailable(1);
val = ((LobbyQuery)(ref val2)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString());
break;
}
if (1 == 0)
{
}
LobbyQuery lobbyQuery = val;
if (!lobbymanager.sortWithChallengeMoons)
{
lobbyQuery = ((LobbyQuery)(ref lobbyQuery)).WithKeyValue("chal", "f");
}
SteamLobbyManager val3 = lobbymanager;
val = ((lobbymanager.serverTagInputField.text == string.Empty) ? ((LobbyQuery)(ref lobbyQuery)).WithKeyValue("tag", "none") : ((LobbyQuery)(ref lobbyQuery)).WithKeyValue("tag", lobbymanager.serverTagInputField.text.Substring(0, Mathf.Min(19, lobbymanager.serverTagInputField.text.Length)).ToLower()));
val3.currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync();
GameNetworkManager.Instance.waitingForLobbyDataRefresh = false;
if (lobbymanager.currentLobbyList != null)
{
if (lobbymanager.currentLobbyList.Length == 0)
{
((TMP_Text)lobbymanager.serverListBlankText).text = "No available servers to join.";
}
else
{
((TMP_Text)lobbymanager.serverListBlankText).text = "";
}
lobbymanager.lobbySlotPositionOffset = 0f;
lobbymanager.loadLobbyListCoroutine = ((MonoBehaviour)lobbymanager).StartCoroutine(loadLobbyListAndFilter(lobbymanager.currentLobbyList, lobbymanager));
}
else
{
Debug.Log((object)"Lobby list is null after request.");
((TMP_Text)lobbymanager.serverListBlankText).text = "No available servers to join (Steam did not respond).";
}
}
private static IEnumerator loadLobbyListAndFilter(Lobby[] lobbyList, SteamLobbyManager lobbymanager)
{
int hidden = 0;
Lobby[] currentLobbyList = lobbymanager.currentLobbyList;
for (int j = 0; j < currentLobbyList.Length; j++)
{
Lobby lobby = currentLobbyList[j];
string lobbyName = ((Lobby)(ref lobby)).GetData("name");
if (lobbyName.Length == 0)
{
continue;
}
Friend owner = ((Lobby)(ref lobby)).Owner;
int num;
if ((int)((Friend)(ref owner)).Relationship != 5)
{
if (!Instance.AllowBlockedFriends.Value)
{
owner = ((Lobby)(ref lobby)).Owner;
num = (((int)((Friend)(ref owner)).Relationship == 6) ? 1 : 0);
}
else
{
num = 0;
}
}
else
{
num = 1;
}
if (num != 0)
{
ManualLogSource logger = Logger;
object[] obj2 = new object[4]
{
lobbyName,
((Lobby)(ref lobby)).Id,
null,
null
};
owner = ((Lobby)(ref lobby)).Owner;
obj2[2] = ((Friend)(ref owner)).Name;
obj2[3] = ((Lobby)(ref lobby)).Owner.Id;
string text = string.Format("Lobby hidden: '{0}' ({1}) by '{2}' ({3}) [Blocked", obj2);
owner = ((Lobby)(ref lobby)).Owner;
logger.LogInfo((object)(text + (((int)((Friend)(ref owner)).Relationship == 6) ? " friend]" : " host]")));
hidden++;
continue;
}
if (Instance.AddArtificialMenuDelay.Value)
{
for (int i = 0; i < 10; i++)
{
yield return null;
}
}
GameObject original = ((((Lobby)(ref lobby)).GetData("chal") != "t") ? lobbymanager.LobbySlotPrefab : lobbymanager.LobbySlotPrefabChallenge);
GameObject obj = Object.Instantiate<GameObject>(original, lobbymanager.levelListContainer);
obj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f + lobbymanager.lobbySlotPositionOffset);
lobbymanager.lobbySlotPositionOffset -= 42f;
LobbySlot componentInChildren = obj.GetComponentInChildren<LobbySlot>();
((TMP_Text)componentInChildren.LobbyName).text = lobbyName.Substring(0, Mathf.Min(lobbyName.Length, 40));
((TMP_Text)componentInChildren.playerCount).text = $"{((Lobby)(ref lobby)).MemberCount} / 4";
componentInChildren.lobbyId = ((Lobby)(ref lobby)).Id;
componentInChildren.thisLobby = lobby;
lobby = default(Lobby);
}
if (hidden > 0)
{
Logger.LogInfo((object)($"{hidden} " + ((hidden == 1) ? "lobby was" : "lobbies were") + " hidden because you blocked " + ((hidden == 1) ? "its host" : "their hosts")));
}
else if (hidden == lobbymanager.currentLobbyList.Length)
{
((TMP_Text)lobbymanager.serverListBlankText).text = "No available servers to join (All servers are hosted by people you've blocked).";
}
yield return null;
}
}
internal byte DisplayedIncompatibilityPopup = 0;
public static SteamBlacklist Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
internal ConfigEntry<bool> AllowBlockedFriends { get; private set; } = null;
internal ConfigEntry<bool> IgnoreBlockedMembers { get; private set; } = null;
internal ConfigEntry<bool> AddArtificialMenuDelay { get; private set; } = null;
public Dictionary<ulong, bool> SteamJoinQueue { get; set; } = new Dictionary<ulong, bool>();
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
AllowBlockedFriends = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "allowBlockedFriends", true, "Allows blocked players in your friends list");
IgnoreBlockedMembers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ignoreBlockedMembers", true, "true: Join lobby if host is not blocked\nfalse: Join lobby if host and members aren't blocked");
AddArtificialMenuDelay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "addArtificialMenuDelay", true, "true: Lobby list is animated\nfalse: Lobby list created as fast as possible");
Logger.LogInfo((object)"Loaded SteamBlacklist mod v1.4.1");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("baer1.SteamBlacklist");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "baer1.SteamBlacklist";
public const string PLUGIN_NAME = "SteamBlacklist";
public const string PLUGIN_VERSION = "1.4.1";
}
}