Decompiled source of CrimsonKey v1.0.1

CrimsonKey.dll

Decompiled a month ago
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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CrimsonKey.Services;
using CrimsonKey.Structs;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using Steamworks;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using VAMP;
using VAMP.Attributes;
using VAMP.Data;
using VAMP.Models;
using VAMP.Services;
using VAMP.Systems;
using VAMP.Utilities;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CrimsonKey")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Real-time Advanced Server Whitelist Manager")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+1.Branch.master.Sha.ecb74139e4ff4e4f0535d80b1081cb6f19c89acb.ecb74139e4ff4e4f0535d80b1081cb6f19c89acb")]
[assembly: AssemblyProduct("CrimsonKey")]
[assembly: AssemblyTitle("CrimsonKey")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 CrimsonKey
{
	[BepInPlugin("CrimsonKey", "CrimsonKey", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		public static Plugin Instance { get; private set; }

		public static Harmony Harmony => Instance._harmony;

		public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;

		public static Settings Settings { get; private set; }

		public static string ConfigFiles => Path.Combine(Paths.ConfigPath, "CrimsonKey");

		public Database Database { get; internal set; }

		public ModTalkService ModTalkService { get; internal set; }

		public override void Load()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			Instance = this;
			Settings = default(Settings);
			Settings.InitConfig();
			_harmony = new Harmony("CrimsonKey");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			CommandRegistry.RegisterAll();
			Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded));
		}

		public void Loaded()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Database = new Database();
			ModTalkService = new ModTalkService();
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonKey");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			CommandRegistry.UnregisterAssembly();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CrimsonKey";

		public const string PLUGIN_NAME = "CrimsonKey";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace CrimsonKey.Structs
{
	public class Database
	{
		[FileReload("LoadList")]
		public static string WhitelistFile = Path.Combine(Plugin.ConfigFiles, "whitelist.txt");

		public static List<ulong> Whitelist;

		public Database()
		{
			LoadList();
		}

		public static void LoadList()
		{
			if (!Directory.Exists(Plugin.ConfigFiles))
			{
				Directory.CreateDirectory(Plugin.ConfigFiles);
			}
			if (!File.Exists(WhitelistFile))
			{
				File.Create(WhitelistFile).Close();
				Whitelist = new List<ulong>();
			}
			else
			{
				Whitelist = (from x in File.ReadAllLines(WhitelistFile)
					select (!ulong.TryParse(x, out var result)) ? 0 : result).ToList();
			}
		}

		public static bool AddToList(ulong platformId)
		{
			if (Whitelist.Contains(platformId))
			{
				return false;
			}
			Whitelist.Add(platformId);
			File.WriteAllLines(WhitelistFile, Whitelist.Select((ulong x) => x.ToString()));
			return true;
		}

		public static void AddToList(List<ulong> ulongs)
		{
			Whitelist.AddRange(ulongs);
			File.WriteAllLines(WhitelistFile, Whitelist.Select((ulong x) => x.ToString()));
		}

		public static bool RemoveFromList(ulong platformId)
		{
			bool num = Whitelist.Remove(platformId);
			if (num)
			{
				File.WriteAllLines(WhitelistFile, Whitelist.Select((ulong x) => x.ToString()));
			}
			return num;
		}

		public static bool IsOnWhitelist(ulong platformId)
		{
			Player val = default(Player);
			if (PlayerService.TryFindBySteam(platformId, ref val) && val.IsAdminCapable)
			{
				return true;
			}
			return Whitelist.Contains(platformId);
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public readonly struct Settings
	{
		private static readonly List<string> OrderedSections = new List<string> { "Config" };

		public static ConfigEntry<bool> Toggled { get; private set; }

		public static ConfigEntry<bool> Whitelisted { get; private set; }

		public static void InitConfig()
		{
			Toggled = InitConfigEntry(OrderedSections[0], "ToggleMod", defaultValue: true, "Enable or disable the mod");
			Whitelisted = InitConfigEntry(OrderedSections[0], "Locked", defaultValue: true, "If true, the whitelist will block non-listed players from joining.");
			ReorderConfigSections();
		}

		private static ConfigEntry<T> InitConfigEntry<T>(string section, string key, T defaultValue, string description)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<T> val = ((BasePlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description);
			string text = Path.Combine(Paths.ConfigPath, "CrimsonKey.cfg");
			ConfigEntry<T> val2 = default(ConfigEntry<T>);
			if (File.Exists(text) && new ConfigFile(text, true).TryGetEntry<T>(section, key, ref val2))
			{
				val.Value = val2.Value;
			}
			return val;
		}

		private static void ReorderConfigSections()
		{
			string path = Path.Combine(Paths.ConfigPath, "CrimsonKey.cfg");
			if (!File.Exists(path))
			{
				return;
			}
			List<string> list = File.ReadAllLines(path).ToList();
			Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
			string text = "";
			foreach (string item in list)
			{
				if (item.StartsWith("["))
				{
					text = item.Trim('[', ']');
					dictionary[text] = new List<string> { item };
				}
				else if (!string.IsNullOrWhiteSpace(text))
				{
					dictionary[text].Add(item);
				}
			}
			using StreamWriter streamWriter = new StreamWriter(path, append: false);
			foreach (string orderedSection in OrderedSections)
			{
				if (!dictionary.ContainsKey(orderedSection))
				{
					continue;
				}
				foreach (string item2 in dictionary[orderedSection])
				{
					streamWriter.WriteLine(item2);
				}
				streamWriter.WriteLine();
			}
		}
	}
}
namespace CrimsonKey.Services
{
	public static class KickService
	{
		public static void KickUsers(List<User> users)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			foreach (User user in users)
			{
				KickUser(user);
			}
		}

		public static void KickUser(User user)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (user.PlatformId != 0L && !PlayerService.PlayerFromUser(user).IsAdminCapable)
			{
				EntityManager entityManager = Core.EntityManager;
				Entity val = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
				{
					ComponentType.ReadOnly<NetworkEventType>(),
					ComponentType.ReadOnly<SendEventToUser>(),
					ComponentType.ReadOnly<KickEvent>()
				});
				EntityUtil.Write<KickEvent>(val, new KickEvent
				{
					PlatformId = user.PlatformId
				});
				EntityUtil.Write<SendEventToUser>(val, new SendEventToUser
				{
					UserIndex = user.Index
				});
				EntityUtil.Write<NetworkEventType>(val, new NetworkEventType
				{
					EventId = NetworkEvents.EventId_KickEvent,
					IsAdminEvent = false,
					IsDebugEvent = false
				});
			}
		}

		public static void Kick(Player player)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!player.IsAdminCapable)
			{
				KickUser(EntityUtil.Read<User>(player.User));
			}
		}
	}
	public class ModTalkService
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ModTalkDelegate <>9__0_0;

			internal bool <.ctor>b__0_0(string identifier, object[] args, Action<object> callback)
			{
				if (identifier == "CrimsonKey.IsWhitelisted")
				{
					bool flag = Database.IsOnWhitelist((ulong)args[0]);
					callback?.Invoke(flag);
					return true;
				}
				return false;
			}
		}

		public ModTalkService()
		{
			//IL_001a: 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_0025: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				ModTalkDelegate val = delegate(string identifier, object[] args, Action<object> callback)
				{
					if (identifier == "CrimsonKey.IsWhitelisted")
					{
						bool flag = Database.IsOnWhitelist((ulong)args[0]);
						callback?.Invoke(flag);
						return true;
					}
					return false;
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			ModTalk.MessageReceived += (ModTalkDelegate)obj;
		}
	}
}
namespace CrimsonKey.Patches
{
	[HarmonyPatch(typeof(SteamGameServer), "BeginAuthSession", new Type[]
	{
		typeof(Il2CppStructArray<byte>),
		typeof(int),
		typeof(CSteamID)
	})]
	public static class BeginAuthSessionPatch
	{
		public static void Postfix(Il2CppStructArray<byte> pAuthTicket, int cbAuthTicket, CSteamID steamID, ref EBeginAuthSessionResult __result)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Toggled.Value && Settings.Whitelisted.Value && !Database.IsOnWhitelist(steamID.m_SteamID))
			{
				__result = (EBeginAuthSessionResult)1;
			}
		}
	}
	[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")]
	[HarmonyBefore(new string[] { "CrimsonEcho" })]
	public static class OnUserConnectedPatch
	{
		public static void Postfix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			if (!Settings.Toggled.Value)
			{
				return;
			}
			if (Core.PlayerService == null)
			{
				Core.Initialize();
			}
			try
			{
				EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
				int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
				Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num].UserEntity;
				User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
				if (!((FixedString64Bytes)(ref componentData.CharacterName)).IsEmpty)
				{
					((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString();
				}
				if (Settings.Whitelisted.Value && !Database.IsOnWhitelist(componentData.PlatformId))
				{
					KickService.KickUser(componentData);
				}
			}
			catch (Exception ex)
			{
				((BasePlugin)Plugin.Instance).Log.LogError((object)ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(Destroy_TravelBuffSystem), "OnUpdate")]
	public class Destroy_TravelBuffSystem_Patch
	{
		private static void Postfix(Destroy_TravelBuffSystem __instance)
		{
			//IL_001a: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0053: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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)
			if (!Settings.Toggled.Value)
			{
				return;
			}
			if (Core.PlayerService == null)
			{
				Core.Initialize();
			}
			EntityQuery _query_615927226_ = __instance.__query_615927226_0;
			Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_615927226_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
				PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
				if (((PrefabGUID)(ref componentData)).Equals(Prefabs.AB_Interact_TombCoffinSpawn_Travel))
				{
					entityManager = ((ComponentSystemBase)__instance).EntityManager;
					Entity owner = ((EntityManager)(ref entityManager)).GetComponentData<EntityOwner>(current).Owner;
					entityManager = ((ComponentSystemBase)__instance).EntityManager;
					if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(owner))
					{
						break;
					}
					entityManager = ((ComponentSystemBase)__instance).EntityManager;
					Entity userEntity = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(owner).UserEntity;
					entityManager = ((ComponentSystemBase)__instance).EntityManager;
					User componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
					if (Settings.Whitelisted.Value && !Database.IsOnWhitelist(componentData2.PlatformId))
					{
						KickService.KickUser(componentData2);
					}
				}
			}
		}
	}
}
namespace CrimsonKey.Commands
{
	[CommandGroup("key", null)]
	internal static class KeyCommands
	{
		[Command("Lock", null, null, null, null, true)]
		public static void Lock(ChatCommandContext ctx, bool kickNonlisted = false)
		{
			if (!Settings.Toggled.Value)
			{
				return;
			}
			if (Settings.Whitelisted.Value)
			{
				ctx.Reply("Whitelist mode is already enabled.");
				return;
			}
			Settings.Whitelisted.Value = true;
			ctx.Reply("Whitelist mode has been enabled.");
			if (kickNonlisted)
			{
				Purge(ctx);
			}
		}

		[Command("Unlock", null, null, null, null, true)]
		public static void Unlock(ChatCommandContext ctx)
		{
			if (Settings.Toggled.Value)
			{
				if (!Settings.Whitelisted.Value)
				{
					ctx.Reply("Whitelist mode is already disabled.");
					return;
				}
				Settings.Whitelisted.Value = false;
				ctx.Reply("Whitelist mode has been disabled.");
			}
		}

		[Command("Add", null, null, null, null, true)]
		public static void Whitelist(ChatCommandContext ctx, string playerName)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Toggled.Value)
			{
				Player val = default(Player);
				if (!PlayerService.TryFindByName(playerName, ref val))
				{
					ctx.Reply("Could not find " + playerName + ".");
				}
				else if (!Database.AddToList(EntityUtil.Read<User>(val.User).PlatformId))
				{
					ctx.Reply(playerName + " is already on the whitelist.");
				}
				else
				{
					ctx.Reply("Added " + playerName + " to the whitelist.");
				}
			}
		}

		[Command("AddId", null, null, null, null, true)]
		public static void WhitelistId(ChatCommandContext ctx, ulong playerSteamId)
		{
			if (Settings.Toggled.Value)
			{
				if (!Database.AddToList(playerSteamId))
				{
					ctx.Reply($"{playerSteamId} is already on the whitelist.");
				}
				else
				{
					ctx.Reply($"Added {playerSteamId} to the whitelist.");
				}
			}
		}

		[Command("AddAllOnline", null, null, null, null, true)]
		public static void WhitelistOnline(ChatCommandContext ctx)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			if (!Settings.Toggled.Value)
			{
				return;
			}
			IEnumerable<Entity> usersOnline = PlayerService.GetUsersOnline();
			List<ulong> list = new List<ulong>();
			foreach (Entity item in usersOnline)
			{
				if (!Database.IsOnWhitelist(EntityUtil.Read<User>(item).PlatformId))
				{
					list.Add(EntityUtil.Read<User>(item).PlatformId);
				}
			}
			if (list.Count > 0)
			{
				Database.AddToList(list);
			}
			ctx.Reply($"Whitelisted {list.Count} {((list.Count > 1) ? "players" : "player")}.");
		}

		[Command("Remove", null, null, null, null, true)]
		public static void Revoke(ChatCommandContext ctx, string playerName)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Toggled.Value)
			{
				Player val = default(Player);
				if (!PlayerService.TryFindByName(playerName, ref val))
				{
					ctx.Reply("Could not find " + playerName + ".");
				}
				else if (!Database.RemoveFromList(EntityUtil.Read<User>(val.User).PlatformId))
				{
					ctx.Reply(playerName + " is not on the whitelist.");
				}
				else
				{
					ctx.Reply("Removed " + playerName + " from the whitelist.");
				}
			}
		}

		[Command("RemoveId", null, null, null, null, true)]
		public static void RevokeId(ChatCommandContext ctx, ulong playerSteamId)
		{
			if (Settings.Toggled.Value)
			{
				if (!Database.RemoveFromList(playerSteamId))
				{
					ctx.Reply($"{playerSteamId} is not on the whitelist.");
				}
				else
				{
					ctx.Reply($"Removed {playerSteamId} from the whitelist.");
				}
			}
		}

		[Command("PurgeNonlisted", null, null, null, null, true)]
		public static void Purge(ChatCommandContext ctx)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.Toggled.Value)
			{
				return;
			}
			if (!Settings.Whitelisted.Value)
			{
				ctx.Reply("Whitelist mode is not currently enabled. Enable it with the \"Lock\" command before purging.");
				return;
			}
			IEnumerable<Entity> usersOnline = PlayerService.GetUsersOnline();
			List<User> list = new List<User>();
			foreach (Entity item in usersOnline)
			{
				if (!Database.IsOnWhitelist(EntityUtil.Read<User>(item).PlatformId))
				{
					list.Add(EntityUtil.Read<User>(item));
				}
			}
			if (list.Count > 0)
			{
				KickService.KickUsers(list);
			}
			ctx.Reply($"Kicked {list.Count} {((list.Count > 1 || list.Count == 0) ? "players" : "player")} who {((list.Count > 1 || list.Count == 0) ? "were" : "was")} not on the whitelist.");
		}

		[Command("Status", null, null, null, null, true)]
		public static void Status(ChatCommandContext ctx)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.Toggled.Value)
			{
				return;
			}
			IEnumerable<Entity> usersOnline = PlayerService.GetUsersOnline();
			int num = 0;
			int num2 = 0;
			foreach (Entity item in usersOnline)
			{
				if (Database.IsOnWhitelist(EntityUtil.Read<User>(item).PlatformId))
				{
					num++;
				}
				else
				{
					num2++;
				}
			}
			string text = $"Whitelist mode is {(Settings.Whitelisted.Value ? "enabled" : "disabled")}.\n{num} whitelisted {((num > 1 || num == 0) ? "players" : "player")} online.\n{num2} non-whitelisted {((num2 > 1 || num2 == 0) ? "players" : "player")} online.";
			ctx.Reply(text);
		}

		[Command("Check", null, null, null, null, true)]
		public static void CheckPlayer(ChatCommandContext ctx, string playerName)
		{
			if (Settings.Toggled.Value)
			{
				Player val = default(Player);
				if (!PlayerService.TryFindByName(playerName, ref val))
				{
					ctx.Reply("Player " + playerName + " not found.");
				}
				else if (Database.IsOnWhitelist(val.SteamID))
				{
					ctx.Reply("Player " + playerName + " is whitelisted.");
				}
				else
				{
					ctx.Reply("Player " + playerName + " is not whitelisted.");
				}
			}
		}

		[Command("CheckId", null, null, null, null, true)]
		public static void CheckPlayerId(ChatCommandContext ctx, ulong steamId)
		{
			if (Settings.Toggled.Value)
			{
				if (Database.IsOnWhitelist(steamId))
				{
					ctx.Reply($"Player with SteamID {steamId} is whitelisted.");
				}
				else
				{
					ctx.Reply($"Player with SteamID {steamId} is not whitelisted.");
				}
			}
		}
	}
}