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;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("org.bepinex.plugins.LC_EZAdmin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("An admin plugin for server hosts")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+cc5500601362a72b119d7998abc5f359de313003")]
[assembly: AssemblyProduct("LC_EZAdmin")]
[assembly: AssemblyTitle("org.bepinex.plugins.LC_EZAdmin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LC_EZAdmin
{
[BepInPlugin("org.bepinex.plugins.LC_EZAdmin", "LC_EZAdmin", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static HashSet<ulong> BannedIds = new HashSet<ulong>();
internal const string BannedListFilename = "banned_ids.txt";
private void Awake()
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Log.LogMessage((object)"LC_EZAdmin has started");
Log.LogInfo((object)"Reading banned_ids.txt ...");
try
{
string[] array = File.ReadAllLines("banned_ids.txt");
List<ulong> list = new List<ulong>();
string[] array2 = array;
foreach (string text in array2)
{
if (ulong.TryParse(text.Trim(), out var result))
{
list.Add(result);
}
else
{
Log.LogWarning((object)("Id \"" + text + "\" is not a valid integer. Omitting from ban list"));
}
}
BannedIds.UnionWith(list);
Log.LogInfo((object)$"Sucessfully loaded in {list.Count()} players into ban list");
}
catch (FileNotFoundException)
{
Log.LogWarning((object)"File \"banned_ids.txt\" was not found. Ban list will be empty");
}
new Harmony("org.bepinex.plugins.LC_EZAdmin").PatchAll(typeof(Patches));
Log.LogMessage((object)"LC_EZAdmin has finished loading");
}
}
internal class Patches
{
[HarmonyPatch(typeof(StartOfRound), "KickPlayer")]
[HarmonyPostfix]
public static void Postfix(StartOfRound __instance)
{
Plugin.BannedIds.UnionWith(__instance.KickedClientIds);
Plugin.Log.LogInfo((object)"Dumping kicked players to banned_ids.txt ...");
File.WriteAllLines("banned_ids.txt", Plugin.BannedIds.Select((ulong id) => id.ToString()));
Plugin.Log.LogInfo((object)"Dump complete!");
}
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPrefix]
public static void ServerStart(StartOfRound __instance)
{
Plugin.Log.LogInfo((object)$"Automatically adding {Plugin.BannedIds.Count()} players to kick list");
__instance.KickedClientIds.AddRange(Plugin.BannedIds);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "org.bepinex.plugins.LC_EZAdmin";
public const string PLUGIN_NAME = "LC_EZAdmin";
public const string PLUGIN_VERSION = "1.1.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}