using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("StuntedRaccoon.ServerBlocker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.5.5.0")]
[assembly: AssemblyInformationalVersion("1.5.5+a0f59008c6cb31a36093a6d42031fdd7d808b396")]
[assembly: AssemblyProduct("SrvrBlckr")]
[assembly: AssemblyTitle("StuntedRaccoon.ServerBlocker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.5.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BlockServersByHost
{
[BepInPlugin("StuntedRaccoon.ServerBlocker", "SrvrBlckr", "1.5.5")]
public class Plugin : BaseUnityPlugin
{
[Serializable]
public class StringArrayWrapper
{
public string[] items;
public StringArrayWrapper(string[] _items)
{
items = _items;
}
}
[HarmonyPatch(typeof(LobbyDataEntry), "Awake")]
public static class LobbyDataEntry_Awake
{
public static void Postfix(LobbyDataEntry __instance)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
Button joinLobbyButton = __instance._joinLobbyButton;
GameObject val = Object.Instantiate<GameObject>(((Component)joinLobbyButton).gameObject);
((Object)val).name = "BlockServerButton";
val.transform.SetParent(((Component)joinLobbyButton).gameObject.transform.parent, false);
Button component = val.GetComponent<Button>();
RectTransform component2 = val.GetComponent<RectTransform>();
val.transform.position = new Vector3(val.transform.position.x - 2f, val.transform.position.y + component2.sizeDelta.y - 6f, val.transform.position.z);
Text componentInChildren = val.GetComponentInChildren<Text>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.text = "Block Server";
}
if ((Object)(object)joinLobbyButton != (Object)null)
{
RectTransform component3 = ((Component)joinLobbyButton).GetComponent<RectTransform>();
if ((Object)(object)component3 != (Object)null)
{
component2.sizeDelta = component3.sizeDelta;
component2.sizeDelta = new Vector2(component2.sizeDelta.x - 4f, component2.sizeDelta.y - 12f);
}
}
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
OnBlockButtonClick(__instance);
});
}
private static void OnBlockButtonClick(LobbyDataEntry lobbyData)
{
AddBlockedName(lobbyData._lobbyName);
LobbyListManager._current.Init_RefreshLobbyList();
}
}
[HarmonyPatch(typeof(SteamLobby), "GetLobbiesList")]
public static class SteamLobby_GetLobbiesList
{
public static void Prefix(ref SteamLobby __instance)
{
string[] blockedServerNames = BlockedServerNames;
foreach (string text in blockedServerNames)
{
SteamMatchmaking.AddRequestLobbyListStringFilter(SteamMatchmakingServerNameKey, text, (ELobbyComparison)3);
}
}
}
internal static ManualLogSource Logger;
private static HashSet<string> _blockedServerNames = new HashSet<string>();
private static string BlockedServerNamesFileName => "blockedServerNames.json";
public static string SteamMatchmakingServerNameKey => "name";
public static string[] BlockedServerNames => _blockedServerNames.ToArray();
public static void AddBlockedName(string serverName)
{
if (!string.IsNullOrWhiteSpace(serverName))
{
_blockedServerNames.Add(serverName);
Logger.LogMessage((object)(serverName + " added to blocked servers list."));
}
}
private bool LoadBlockedServerNames()
{
if (!File.Exists(BlockedServerNamesFileName))
{
File.OpenWrite(BlockedServerNamesFileName).Close();
return false;
}
try
{
string[] items = JsonUtility.FromJson<StringArrayWrapper>(File.ReadAllText(BlockedServerNamesFileName)).items;
for (int i = 0; i < items.Length; i++)
{
AddBlockedName(items[i]);
}
}
catch (Exception ex)
{
Logger.LogError((object)("Failed to read " + BlockedServerNamesFileName + ": " + ex.Message));
File.OpenWrite(BlockedServerNamesFileName).Close();
return false;
}
return true;
}
private void Awake()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin StuntedRaccoon.ServerBlocker is loaded!");
LoadBlockedServerNames();
Logger.LogWarning((object)("To stop blocking server(s), remove the server from '" + BlockedServerNamesFileName + "' OR delete file '" + BlockedServerNamesFileName + "' from your ATLYSS root directory to unblock all."));
new Harmony("StuntedRaccoon.ServerBlocker").PatchAll();
}
private void OnDestroy()
{
try
{
StreamWriter streamWriter = new StreamWriter(BlockedServerNamesFileName);
string value = JsonUtility.ToJson((object)new StringArrayWrapper(BlockedServerNames.ToArray()));
streamWriter.Write(value);
streamWriter.Close();
}
catch (Exception ex)
{
Logger.LogError((object)("Failed to read " + BlockedServerNamesFileName + ": " + ex.Message));
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "StuntedRaccoon.ServerBlocker";
public const string PLUGIN_NAME = "SrvrBlckr";
public const string PLUGIN_VERSION = "1.5.5";
}
}