using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using Unity.Netcode;
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.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5d3ccb4c5ab3f7aaa7eb73e2ab80adab925ab1b4")]
[assembly: AssemblyProduct("SteamBlacklist")]
[assembly: AssemblyTitle("baer1.SteamBlacklist")]
[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.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.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class SteamBlacklist : BaseUnityPlugin
{
[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
public class StartHostPatch
{
private static void Postfix()
{
}
}
[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_0256: 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_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_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: 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_0200: 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_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: 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_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, RETURNING {((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 1:
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;
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);
if (flag)
{
Logger.LogDebug((object)$" << SteamPlayerJoinPatch ALLOW {((Friend)(ref friend)).Name} {friend.Id}");
}
else
{
Logger.LogDebug((object)$" << SteamPlayerJoinPatch 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_0141: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: 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)
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");
int num = ((Instance.SteamJoinQueue == null) ? (-1) : Instance.SteamJoinQueue.Count);
Logger.LogDebug((object)$" >> StartHostPatch (None) Resetting SteamJoinQueue (was {num} items)");
Instance.SteamJoinQueue = new Dictionary<ulong, bool>();
Logger.LogDebug((object)$" << StartHostPatch RESET SteamJoinQueue! {Instance.SteamJoinQueue.Count}");
return true;
}
string[] array;
ulong num2;
try
{
array = Encoding.ASCII.GetString(request.Payload).Split(",");
num2 = (ulong)Convert.ToInt64(array[1]);
Logger.LogDebug((object)$" >> STEAMID={num2} - PAYLOAD={array}");
}
catch (Exception)
{
Logger.LogDebug((object)$"Received invalid approval request: {request.Payload}");
return false;
}
Logger.LogDebug((object)$"Received approval request: {num2}");
bool? flag;
try
{
flag = DictionaryExtensions.Get<ulong, bool>((IDictionary<ulong, bool>)Instance.SteamJoinQueue, num2, false);
}
catch (KeyNotFoundException)
{
flag = null;
}
if (flag.HasValue && flag.Value)
{
Logger.LogDebug((object)$" << PlayerJoinPatch ALLOW {request.ClientNetworkId} {array[1]}");
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}!", num2, response.Reason.Split(",")[0].Replace("!", "")));
Instance.SteamJoinQueue.Remove(num2);
Logger.LogDebug((object)$" << PlayerJoinPatch DENY {request.ClientNetworkId} {response.Reason}");
return false;
}
}
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;
public Dictionary<ulong, bool>? SteamJoinQueue { get; set; }
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");
Logger.LogInfo((object)"Loaded SteamBlacklist mod v1.0.0");
}
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.0.0";
}
}