using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppSystem; using Keys.Models; using Keys.Services; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Network; using ProjectM.Physics; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using UnityEngine; 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("Keys")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5c0e2d668a3e4f5e95e8e999a1d6b7224f461007")] [assembly: AssemblyProduct("Keys")] [assembly: AssemblyTitle("Keys")] [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] internal sealed class IsUnmanagedAttribute : Attribute { } [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Keys { internal static class Core { public static bool _initialized = false; private static MonoBehaviour _monoBehaviour; public static ManualLogSource Log => Plugin.LogInstance; public static World World { get; } = GetServerWorld() ?? throw new Exception("There is no Server world!"); public static EntityManager EntityManager => World.EntityManager; public static void Initialize() { PlayerDataService.Initialize(); KeyManagementService.Initialize(); _initialized = true; } private static World GetServerWorld() { return ((IEnumerable)World.s_AllWorlds.ToArray()).FirstOrDefault((Func)((World world) => world.Name == "Server")); } public static void StartCoroutine(IEnumerator routine) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_monoBehaviour == (Object)null) { _monoBehaviour = (MonoBehaviour)(object)new GameObject("Keys").AddComponent(); Object.DontDestroyOnLoad((Object)(object)((Component)_monoBehaviour).gameObject); } _monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public readonly struct NativeAccessor : IDisposable where T : unmanaged { private static NativeArray _array; public T this[int index] { get { return _array[index]; } set { _array[index] = value; } } public int Length => _array.Length; public NativeAccessor(NativeArray array) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) _array = array; } public Enumerator GetEnumerator() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return _array.GetEnumerator(); } public void Dispose() { _array.Dispose(); } } public static class VExtensions { private const string PREFIX = "Entity("; private const int LENGTH = 7; private static EntityManager EntityManager => Core.EntityManager; public static bool TryGetComponent(this Entity entity, out T componentData) where T : struct { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) componentData = default(T); if (entity.Has()) { componentData = entity.Read(); return true; } return false; } public static bool Has(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0)); } public static T Read(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetComponentData(entity); } public static ulong GetSteamId(this Entity entity) { //IL_0000: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent(out PlayerCharacter componentData)) { return componentData.UserEntity.GetUser().PlatformId; } if (entity.TryGetComponent(out User componentData2)) { return componentData2.PlatformId; } return 0uL; } public static User GetUser(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent(out User componentData)) { return componentData; } if (entity.TryGetComponent(out PlayerCharacter componentData2) && componentData2.UserEntity.TryGetComponent(out componentData)) { return componentData; } return User.Empty; } public static bool IndexWithinCapacity(this Entity entity) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan span = ((object)(Entity)(ref entity)).ToString().AsSpan(); if (!span.StartsWith("Entity(")) { return false; } ref ReadOnlySpan reference = ref span; span = reference.Slice(7, reference.Length - 7); int num = span.IndexOf(':'); if (num <= 0) { return false; } reference = ref span; int result = num + 1; ReadOnlySpan span2 = reference.Slice(result, reference.Length - result); int num2 = span2.IndexOf(')'); if (num2 <= 0) { return false; } if (!int.TryParse(span.Slice(0, num), out var result2)) { return false; } if (!int.TryParse(span2.Slice(0, num2), out result)) { return false; } EntityManager entityManager = EntityManager; int entityCapacity = ((EntityManager)(ref entityManager)).EntityCapacity; return (uint)result2 < (uint)entityCapacity; } public static PrefabGUID GetPrefabGuid(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent(out PrefabGUID componentData)) { return componentData; } return PrefabGUID.Empty; } public unsafe static void Write(this Entity entity, T componentData) where T : struct { //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_0039: 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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf(); fixed (byte* ptr = array) { EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } public static byte[] StructureToByteArray(T structure) where T : struct { int num = Marshal.SizeOf(structure); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } } [BepInPlugin("io.vrising.Keys", "Keys", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BasePlugin { private Harmony _harmony; internal static Plugin Instance { get; private set; } public static Harmony Harmony => Instance._harmony; public static bool IsServer { get; private set; } public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log; public override void Load() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown Instance = this; IsServer = Application.productName == "VRisingServer"; if (!IsServer) { Core.Log.LogWarning((object)"This plugin is intended to run on the server only. It will not function correctly on the client."); return; } _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ConfigService.ConfigInitialization.InitializeConfig(); CommandRegistry.RegisterAll(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Keys"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded successfully!"); } log.LogInfo(val); } public override bool Unload() { _harmony.UnpatchSelf(); if (IsServer) { PlayerDataService.FlushSaveToDisk(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "io.vrising.Keys"; public const string PLUGIN_NAME = "Keys"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Keys.Services { internal static class ConfigService { public static class ConfigInitialization { public class ConfigEntryDefinition { public string Section { get; } public string Key { get; } public object DefaultValue { get; } public string Description { get; } public ConfigEntryDefinition(string section, string key, object defaultValue, string description) { Section = section; Key = key; DefaultValue = defaultValue; Description = description; base..ctor(); } } private static readonly Regex _regex = new Regex("^\\[(.+)\\]$"); public static readonly Dictionary FinalConfigValues = new Dictionary(); private static readonly Lazy> _directoryPaths = new Lazy>(() => new List(1) { Path.Combine(Paths.ConfigPath, "Keys") }); public static readonly List SectionOrder = new List(1) { "General" }; public static readonly List ConfigEntries = new List(4) { new ConfigEntryDefinition("General", "DEV", false, "Enable development mode with additional logging/debugging features"), new ConfigEntryDefinition("General", "DiscordProdGameEventsWebhookUrl", "", "Production Discord webhook URL for game event messages"), new ConfigEntryDefinition("General", "DiscordDevGameEventsWebhookUrl", "", "Development Discord webhook URL for game event messages"), new ConfigEntryDefinition("General", "ClanMemberLimit", 12, "Maximum number of members allowed in a clan for the keys system (default: 12)") }; private const string DEFAULT_VALUE_LINE = "# Default value: "; public static List DirectoryPaths => _directoryPaths.Value; public static void InitializeConfig() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown foreach (string directoryPath in DirectoryPaths) { CreateDirectory(directoryPath); } bool flag = default(bool); foreach (ConfigEntryDefinition configEntry in ConfigEntries) { Type type = configEntry.DefaultValue.GetType(); object obj = typeof(ConfigService).GetNestedType("ConfigInitialization", BindingFlags.Static | BindingFlags.Public).GetMethod("InitConfigEntry", BindingFlags.Static | BindingFlags.NonPublic).MakeGenericMethod(type) .Invoke(null, new object[4] { configEntry.Section, configEntry.Key, configEntry.DefaultValue, configEntry.Description }); UpdateConfigProperty(configEntry.Key, obj); object obj2 = obj.GetType().GetProperty("Value")?.GetValue(obj); if (obj2 != null) { FinalConfigValues[configEntry.Key] = obj2; continue; } ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get value property for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(configEntry.Key); } log.LogError(val); } string text = Path.Combine(Paths.ConfigPath, "io.vrising.Keys.cfg"); if (File.Exists(text)) { OrganizeConfig(text); } } private static void UpdateConfigProperty(string key, object configEntry) { PropertyInfo property = typeof(ConfigService).GetProperty(key, BindingFlags.Static | BindingFlags.Public); if (property != null && property.CanWrite) { object obj = configEntry.GetType().GetProperty("Value")?.GetValue(configEntry); if (obj == null) { throw new Exception("Value property on configEntry is null for key " + key + "."); } property.SetValue(null, Convert.ChangeType(obj, property.PropertyType)); } } private static ConfigEntry InitConfigEntry(string section, string key, T defaultValue, string description) { //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown ConfigEntry val = ((BasePlugin)Plugin.Instance).Config.Bind(section, key, defaultValue, description); string path = Path.Combine(Paths.ConfigPath, "io.vrising.Keys.cfg"); if (File.Exists(path)) { string[] array = File.ReadAllLines(path); bool flag = default(bool); foreach (string text in array) { if (string.IsNullOrWhiteSpace(text) || text.TrimStart().StartsWith("#")) { continue; } string[] array2 = text.Split('='); if (array2.Length != 2) { continue; } string text2 = array2[0].Trim(); string text3 = array2[1].Trim(); if (!text2.Equals(key, StringComparison.OrdinalIgnoreCase)) { continue; } try { Type typeFromHandle = typeof(T); object obj; if (typeFromHandle == typeof(float)) { obj = float.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(double)) { obj = double.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(decimal)) { obj = decimal.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(int)) { obj = int.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(uint)) { obj = uint.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(long)) { obj = long.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(ulong)) { obj = ulong.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(short)) { obj = short.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(ushort)) { obj = ushort.Parse(text3, CultureInfo.InvariantCulture); } else if (typeFromHandle == typeof(bool)) { obj = bool.Parse(text3); } else { if (!(typeFromHandle == typeof(string))) { throw new NotSupportedException($"Type {typeFromHandle} is not supported"); } obj = text3; } val.Value = (T)obj; } catch (Exception ex) { ManualLogSource logInstance = Plugin.LogInstance; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to convert config value for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(key); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } logInstance.LogError(val2); } break; } } return val; } private static void CreateDirectory(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } private static void OrganizeConfig(string configFile) { //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Expected O, but got Unknown //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown bool flag2 = default(bool); try { Dictionary> dictionary = new Dictionary>(); string text = ""; string[] array = File.ReadAllLines(configFile); string[] subArray = array[0..3]; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i].Trim(); Match match = _regex.Match(text2); if (match.Success) { text = match.Groups[1].Value; if (!dictionary.ContainsKey(text)) { dictionary[text] = new List(); } } else if (SectionOrder.Contains(text)) { dictionary[text].Add(text2); } } using StreamWriter streamWriter = new StreamWriter(configFile, append: false); array2 = subArray; foreach (string value in array2) { streamWriter.WriteLine(value); } foreach (string section in SectionOrder) { if (!dictionary.ContainsKey(section)) { continue; } streamWriter.WriteLine("[" + section + "]"); List list = dictionary[section]; List list2 = new List(); list2.AddRange(from line in list where line.Contains('=') select line.Split('=')[0].Trim()); List sectionKeys = list2; Dictionary dictionary2 = ConfigEntries.Where((ConfigEntryDefinition entry) => entry.Section == section).ToDictionary((ConfigEntryDefinition entry) => entry.Key, (ConfigEntryDefinition entry) => entry.DefaultValue); int keyIndex = 0; bool flag = false; foreach (string item in list) { if (item.Contains('=')) { string text3 = item.Split('=')[0].Trim(); if (!dictionary2.ContainsKey(text3)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipping obsolete config entry: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); } log.LogWarning(val); flag = true; continue; } } if (string.IsNullOrWhiteSpace(item) && flag) { continue; } if (item.Contains("# Default value: ")) { ConfigEntryDefinition configEntryDefinition = ConfigEntries.FirstOrDefault((ConfigEntryDefinition e) => e.Key == sectionKeys[keyIndex] && e.Section == section); if (configEntryDefinition != null) { streamWriter.WriteLine("# Default value: " + configEntryDefinition.DefaultValue.ToString()); keyIndex++; } else { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Config entry for key '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(sectionKeys[keyIndex]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found in ConfigEntries!"); } log2.LogWarning(val); streamWriter.WriteLine(item); } } else { streamWriter.WriteLine(item); } flag = false; } } } catch (Exception ex) { ManualLogSource log3 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to clean and organize config file: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log3.LogError(val2); } } } private static readonly Lazy _DEV = new Lazy(() => GetConfigValue("DEV")); private static readonly Lazy _DiscordProdGameEventsWebhookUrl = new Lazy(() => GetConfigValue("DiscordProdGameEventsWebhookUrl")); private static readonly Lazy _DiscordDevGameEventsWebhookUrl = new Lazy(() => GetConfigValue("DiscordDevGameEventsWebhookUrl")); private static readonly Lazy _ClanMemberLimit = new Lazy(() => GetConfigValue("ClanMemberLimit")); public static bool DEV => _DEV.Value; public static string DiscordProdGameEventsWebhookUrl => _DiscordProdGameEventsWebhookUrl.Value; public static string DiscordDevGameEventsWebhookUrl => _DiscordDevGameEventsWebhookUrl.Value; public static int ClanMemberLimit => _ClanMemberLimit.Value; private static T GetConfigValue(string key) { if (ConfigInitialization.FinalConfigValues.TryGetValue(key, out var value)) { return (T)Convert.ChangeType(value, typeof(T)); } ConfigInitialization.ConfigEntryDefinition configEntryDefinition = ConfigInitialization.ConfigEntries.FirstOrDefault((ConfigInitialization.ConfigEntryDefinition e) => e.Key == key); if (configEntryDefinition != null) { return (T)configEntryDefinition.DefaultValue; } throw new InvalidOperationException("Config entry for key '" + key + "' not found."); } } public enum DiscordLogType { ClanKeyJoin } public static class DiscordWebhookService { private static readonly HttpClient _httpClient = new HttpClient(); public static async Task SendGameEventMessageToWebhook(DiscordLogType logType, Entity userEntity, Entity targetEntity = default(Entity)) { //IL_0016: 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_001e: 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) string text = (ConfigService.DEV ? ConfigService.DiscordDevGameEventsWebhookUrl : ConfigService.DiscordProdGameEventsWebhookUrl); if (string.IsNullOrEmpty(text)) { if (ConfigService.DEV) { Core.Log.LogInfo((object)"Discord game events webhook URL not configured"); } return; } string text2 = ""; float3 value = default(float3); ((float3)(ref value))..ctor(0f, 0f, 0f); if (userEntity.Has() || userEntity.Has()) { User user = userEntity.GetUser(); text2 = ((object)(FixedString64Bytes)(ref user.CharacterName)).ToString(); } if (userEntity.Has()) { value = userEntity.Read().Value; } string text3 = "> "; if (logType == DiscordLogType.ClanKeyJoin) { text3 += "\ud83d\udddd\ufe0f\ud83d\udddd\ufe0f\ud83d\udddd\ufe0f "; } text3 += ((text2 != "") ? ("Character '" + text2 + "' ") : "Someone "); if (logType == DiscordLogType.ClanKeyJoin) { if (targetEntity.Has()) { ClanTeam val = targetEntity.Read(); text3 += $"has joined clan '{val.Name}' using a key"; } else { text3 += "has joined a clan using a key"; } } text3 += ((!((float3)(ref value)).Equals(new float3(0f, 0f, 0f))) ? $" at position {value.x:F1} {value.y:F1} {value.z:F1}" : "."); bool flag = default(bool); try { StringContent content = new StringContent(JsonSerializer.Serialize(new { content = text3 }), Encoding.UTF8, "application/json"); HttpResponseMessage response = await _httpClient.PostAsync(text, content); if (!response.IsSuccessStatusCode) { string text4 = await response.Content.ReadAsStringAsync(); ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Discord game events webhook failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(response.StatusCode); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text4); } log.LogError(val2); } else if (ConfigService.DEV) { Core.Log.LogInfo((object)"Discord game event message sent successfully."); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Exception sending Discord game event message webhook: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogError(val2); } } } public static class EntityService { private static EntityManager EntityManager => Core.EntityManager; public static bool TryFindPlayer(string playerName, out Entity playerEntity, out Entity userEntity) { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(playerName)) { playerEntity = Entity.Null; userEntity = Entity.Null; return false; } playerEntity = Entity.Null; userEntity = Entity.Null; EntityManager entityManager = EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); Enumerator enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; entityManager = EntityManager; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString().Equals(playerName, StringComparison.OrdinalIgnoreCase)) { userEntity = current; playerEntity = componentData.LocalCharacter._Entity; return true; } } return false; } public static List GetNearbyUserEntities(Entity playerEntity, float radius = 10f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002e: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0052: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0079: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) List list = new List(); EntityManager entityManager = EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent(playerEntity)) { return list; } entityManager = EntityManager; float3 value = ((EntityManager)(ref entityManager)).GetComponentData(playerEntity).Value; EntityQuery playerCharactersQuery = QueryService.PlayerCharactersQuery; Enumerator enumerator = ((EntityQuery)(ref playerCharactersQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; entityManager = EntityManager; Entity userEntity = ((EntityManager)(ref entityManager)).GetComponentData(current).UserEntity; entityManager = EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(userEntity)) { entityManager = EntityManager; float3 value2 = ((EntityManager)(ref entityManager)).GetComponentData(userEntity).Value; if ((value2.x - value.x) * (value2.x - value.x) + (value2.y - value.y) * (value2.y - value.y) + (value2.z - value.z) * (value2.z - value.z) <= radius * radius) { list.Add(userEntity); } } } return list; } public static NativeArray GetEntitiesByComponentType(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0013: 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_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003a: 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_004d: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) EntityQueryOptions val = (EntityQueryOptions)0; if (includeAll) { val = (EntityQueryOptions)(val | 0xC3); } if (includeDisabled) { val = (EntityQueryOptions)(val | 2); } if (includeSpawn) { val = (EntityQueryOptions)(val | 0x40); } if (includePrefab) { val = (EntityQueryOptions)(val | 1); } if (includeDestroyed) { val = (EntityQueryOptions)(val | 0x80); } EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions(val); EntityManager entityManager = Core.EntityManager; EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); } } internal static class KeyManagementService { private class ClanCacheEntry { public string ClanGuid { get; set; } public string ClanName { get; set; } public Dictionary KeysByPlayer { get; set; } = new Dictionary(); } private static Dictionary _clanCache = new Dictionary(); private static Entity GetClanEntity(string identifier, ChatCommandContext ctx) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_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_001e: 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_0025: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: 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_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) NativeArray entitiesByComponentType = EntityService.GetEntitiesByComponentType(); Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val = current.Read(); if (((object)(Guid)(ref val.ClanGuid)).ToString().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { return current; } } enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current2 = enumerator.Current; ClanTeam val2 = current2.Read(); if (((object)(FixedString64Bytes)(ref val2.Name)).ToString().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { return current2; } } Match match = Regex.Match(identifier, "^(.+?)\\s+#(\\d+)$"); if (match.Success) { string value = match.Groups[1].Value; int num = int.Parse(match.Groups[2].Value); List<(Entity, string)> list = new List<(Entity, string)>(); enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current3 = enumerator.Current; ClanTeam val3 = current3.Read(); if (((object)(FixedString64Bytes)(ref val3.Name)).ToString().Equals(value, StringComparison.OrdinalIgnoreCase)) { list.Add((current3, ((object)(Guid)(ref val3.ClanGuid)).ToString())); } } list.Sort(((Entity Entity, string Guid) a, (Entity Entity, string Guid) b) => string.Compare(a.Guid, b.Guid, StringComparison.OrdinalIgnoreCase)); if (list.Count == 0) { ctx.Reply("Clan '" + value + "' not found."); return Entity.Null; } if (num < 1 || num > list.Count) { ctx.Reply($"Index #{num} out of range. Only {list.Count} clan(s) matched '{value}'."); return Entity.Null; } return list[num - 1].Item1; } List<(Entity, string, string, string, int)> list2 = new List<(Entity, string, string, string, int)>(); enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current4 = enumerator.Current; ClanTeam val4 = current4.Read(); string text = ((object)(FixedString64Bytes)(ref val4.Name)).ToString(); string item = ((object)(Guid)(ref val4.ClanGuid)).ToString(); if (text.Equals(identifier, StringComparison.OrdinalIgnoreCase)) { string item2 = ((object)(FixedString64Bytes)(ref val4.Motto)).ToString(); EntityManager entityManager = Core.EntityManager; int length = ((EntityManager)(ref entityManager)).GetBuffer(current4, false).Length; list2.Add((current4, item, text, item2, length)); } } if (list2.Count == 1) { return list2[0].Item1; } if (list2.Count > 1) { list2.Sort(((Entity Entity, string Guid, string Name, string Motto, int MemberCount) a, (Entity Entity, string Guid, string Name, string Motto, int MemberCount) b) => string.Compare(a.Guid, b.Guid, StringComparison.OrdinalIgnoreCase)); string text2 = $"Ambiguous clan name: '{identifier}' matches {list2.Count} clans:\n"; for (int i = 0; i < list2.Count; i++) { string value2 = (string.IsNullOrEmpty(list2[i].Item4) ? "(no motto)" : ("\"" + list2[i].Item4 + "\"")); text2 += $" {i + 1}. {list2[i].Item3} - {value2} ({list2[i].Item5} members)\n"; } text2 += $"Use the clan name with #N to specify, e.g. \"{identifier} #1\" or \"{identifier} #2\"."; ctx.Reply(text2); return Entity.Null; } ctx.Reply("Clan '" + identifier + "' not found."); return Entity.Null; } internal static string GetClanGuidFromName(string clanName, ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Entity clanEntity = GetClanEntity(clanName, ctx); if (((Entity)(ref clanEntity)).Equals(Entity.Null)) { return null; } ClanTeam val = clanEntity.Read(); return ((object)(Guid)(ref val.ClanGuid)).ToString(); } public static void Initialize() { Core.Log.LogInfo((object)"Initializing Key Management Service..."); BuildCache(); } private static void BuildCache() { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown _clanCache.Clear(); List allPlayerData = PlayerDataService.GetAllPlayerData(); int num = 0; int num2 = 0; int num3 = 0; bool flag = false; foreach (PlayerData playerData in allPlayerData) { int num4 = 0; List list = new List(); foreach (ClanKeyData clanKey in playerData.ClanKeys) { if (string.IsNullOrWhiteSpace(clanKey.ClanGuid) || string.IsNullOrWhiteSpace(clanKey.ClanName)) { list.Add(clanKey); num3++; continue; } if (!_clanCache.ContainsKey(clanKey.ClanGuid)) { _clanCache[clanKey.ClanGuid] = new ClanCacheEntry { ClanGuid = clanKey.ClanGuid, ClanName = clanKey.ClanName }; } _clanCache[clanKey.ClanGuid].KeysByPlayer[playerData.GuidHash] = clanKey; num++; num4++; } if (list.Count > 0) { list.ForEach(delegate(ClanKeyData key) { playerData.ClanKeys.Remove(key); }); flag = true; } if (num4 > 0) { num2++; } } bool flag2 = default(bool); if (num3 > 0) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Disposed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" old keys without ClanGuid"); } log.LogWarning(val); } if (flag) { PlayerDataService.SaveData(); } ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(63, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Key Cache Built: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_clanCache.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" clans registered, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" total keys across "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" players"); } log2.LogInfo(val2); } private static void EnsureCache() { if (_clanCache.Count == 0) { Core.Log.LogInfo((object)"Key cache empty, rebuilding..."); BuildCache(); } } private static void RefreshCache() { BuildCache(); } public static PlayerData GetPlayerData(User user) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return PlayerDataService.GetPlayerData(((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer()); } public static bool IsClanRegistered(string clanGuid) { EnsureCache(); return _clanCache.Keys.Any((string k) => k.Equals(clanGuid, StringComparison.OrdinalIgnoreCase)); } public static void RegisterClan(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //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_001a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Invalid comparison between Unknown and I4 //IL_00db: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) Entity senderUserEntity = ctx.Event.SenderUserEntity; User user = senderUserEntity.Read(); if (((object)(NetworkedEntity)(ref user.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply("You are not in a clan."); return; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); ClanTeam val = entityOnServer.Read(); string text = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); string clanGuid = ((object)(Guid)(ref val.ClanGuid)).ToString(); if (IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text + "' is already registered with the keys system."); return; } EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); entityManager = Core.EntityManager; DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); for (int i = 0; i < buffer.Length; i++) { if ((int)buffer[i].ClanRole == 2) { SyncToUserBuffer val2 = buffer2[i]; if (((Entity)(ref val2.UserEntity)).Equals(senderUserEntity)) { GetPlayerData(user).ClanKeys.Add(new ClanKeyData { ClanName = text, ClanGuid = clanGuid, IsOwnerKey = true, CanIgnoreClanLimit = false, IssuedTime = DateTime.Now }); PlayerDataService.SaveData(); RefreshCache(); ctx.Reply("Clan '" + text + "' registered! You are the owner. Use .keys give to issue keys."); return; } } } ctx.Reply("You must be a clan leader to register the clan."); } public static void TransferOwnership(ChatCommandContext ctx, Entity newUserEntity, Entity? originalOwnerEntity = null) { //IL_0011: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) int num; Entity entity; if (originalOwnerEntity.HasValue) { Entity value = originalOwnerEntity.Value; num = ((!((Entity)(ref value)).Equals(Entity.Null)) ? 1 : 0); if (num != 0) { entity = originalOwnerEntity.Value; goto IL_0041; } } else { num = 0; } entity = ctx.Event.SenderUserEntity; goto IL_0041; IL_0041: User user = entity.Read(); string text = ((num != 0) ? "The original owner" : "You"); string text2 = ((num != 0) ? "the original owner's" : "your"); if (((object)(NetworkedEntity)(ref user.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply(text + " are not in a clan."); return; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); ClanTeam val = entityOnServer.Read(); string text3 = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); string clanGuid = ((object)(Guid)(ref val.ClanGuid)).ToString(); if (!IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text3 + "' is not registered with the keys system. Use .keys register."); return; } PlayerData playerData = GetPlayerData(user); if (!playerData.ClanKeys.Any((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase) && k.IsOwnerKey)) { ctx.Reply(text + " are not the clan owner."); return; } if (((Entity)(ref newUserEntity)).Equals(Entity.Null)) { ctx.Reply("Target player not found."); return; } User user2 = newUserEntity.Read(); string text4 = ((object)(FixedString64Bytes)(ref user2.CharacterName)).ToString(); if (((object)(NetworkedEntity)(ref user2.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply(text4 + " is not in a clan."); return; } Entity entityOnServer2 = ((NetworkedEntity)(ref user2.ClanEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer2)).Equals(entityOnServer)) { ctx.Reply(text4 + " is not in " + text2 + " clan."); return; } PlayerData playerData2 = GetPlayerData(user2); ClanKeyData clanKeyData = playerData.ClanKeys.FirstOrDefault((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase) && k.IsOwnerKey); if (clanKeyData != null) { playerData.ClanKeys.Remove(clanKeyData); } playerData.ClanKeys.Add(new ClanKeyData { ClanName = text3, ClanGuid = clanGuid, IsOwnerKey = false, CanIgnoreClanLimit = false, IssuedTime = DateTime.Now }); ClanKeyData clanKeyData2 = playerData2.ClanKeys.FirstOrDefault((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase)); if (clanKeyData2 != null) { clanKeyData2.IsOwnerKey = true; } else { playerData2.ClanKeys.Add(new ClanKeyData { ClanName = text3, ClanGuid = clanGuid, IsOwnerKey = true, CanIgnoreClanLimit = false, IssuedTime = DateTime.Now }); } PlayerDataService.SaveData(); RefreshCache(); ctx.Reply($"Ownership of '{text3}' transferred to {text4}."); } public static bool CanIssueKeys(Entity userEntity, string clanGuid) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return GetPlayerData(userEntity.Read()).ClanKeys.Any((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase) && k.IsOwnerKey); } public static void IssueKey(ChatCommandContext ctx, Entity senderUserEntity, Entity targetUserEntity, string clanName = null, bool canIgnoreLimit = false, bool isAdmin = false, bool forceOwnershipValidation = true) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) string clanGuid = null; string text = clanName; if (string.IsNullOrEmpty(clanName)) { User val = senderUserEntity.Read(); if (((object)(NetworkedEntity)(ref val.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply("You are not in a clan."); return; } ClanTeam val2 = ((NetworkedEntity)(ref val.ClanEntity)).GetEntityOnServer().Read(); text = ((object)(FixedString64Bytes)(ref val2.Name)).ToString(); clanGuid = ((object)(Guid)(ref val2.ClanGuid)).ToString(); } else { Entity clanEntity = GetClanEntity(clanName, ctx); if (((Entity)(ref clanEntity)).Equals(Entity.Null)) { return; } ClanTeam val3 = clanEntity.Read(); text = ((object)(FixedString64Bytes)(ref val3.Name)).ToString(); clanGuid = ((object)(Guid)(ref val3.ClanGuid)).ToString(); } if (!IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text + "' is not registered with the keys system. Use .keys register first."); return; } if (!isAdmin && forceOwnershipValidation && !CanIssueKeys(senderUserEntity, clanGuid)) { ctx.Reply("Only the clan owner can issue keys."); return; } if (((Entity)(ref targetUserEntity)).Equals(Entity.Null)) { ctx.Reply("Target player not found."); return; } User val4 = targetUserEntity.Read(); PlayerData playerData = GetPlayerData(val4); ClanKeyData clanKeyData = playerData.ClanKeys.FirstOrDefault((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase)); if (clanKeyData != null) { clanKeyData.CanIgnoreClanLimit |= canIgnoreLimit; } else { playerData.ClanKeys.Add(new ClanKeyData { ClanName = text, ClanGuid = clanGuid, IsOwnerKey = false, CanIgnoreClanLimit = canIgnoreLimit, IssuedTime = DateTime.Now }); } PlayerDataService.SaveData(); RefreshCache(); FixedString512Bytes val5 = default(FixedString512Bytes); string text2; if (canIgnoreLimit) { ((FixedString512Bytes)(ref val5))..ctor($"You have been given a key for clan '{text}' that bypasses clan limits!\n Use .keys use \"{text}\" to join."); text2 = $"Bypass key issued to {val4.CharacterName} for {text}."; } else { ((FixedString512Bytes)(ref val5))..ctor($"You have been given a key for clan '{text}'!\n Use .keys use \"{text}\" to join."); text2 = $"Key issued to {val4.CharacterName} for {text}."; } ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, val4, ref val5); ctx.Reply(text2); } public static void RevokeKey(ChatCommandContext ctx, Entity targetUserEntity, bool force = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) Entity senderUserEntity = ctx.Event.SenderUserEntity; User val = senderUserEntity.Read(); if (((object)(NetworkedEntity)(ref val.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply("You are not in a clan."); return; } ClanTeam val2 = ((NetworkedEntity)(ref val.ClanEntity)).GetEntityOnServer().Read(); string text = ((object)(FixedString64Bytes)(ref val2.Name)).ToString(); string clanGuid = ((object)(Guid)(ref val2.ClanGuid)).ToString(); if (!force && !IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text + "' is not registered with the keys system."); return; } if (!force && !CanIssueKeys(senderUserEntity, clanGuid)) { ctx.Reply("Only the clan owner can revoke keys."); return; } if (((Entity)(ref targetUserEntity)).Equals(Entity.Null)) { ctx.Reply("Target player not found."); return; } User val3 = targetUserEntity.Read(); PlayerData playerData = GetPlayerData(val3); ClanKeyData clanKeyData = playerData.ClanKeys.FirstOrDefault((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase)); if (clanKeyData == null) { ctx.Reply($"{val3.CharacterName} does not have a key for your clan."); return; } playerData.ClanKeys.Remove(clanKeyData); PlayerDataService.SaveData(); RefreshCache(); FixedString512Bytes val4 = default(FixedString512Bytes); ((FixedString512Bytes)(ref val4))..ctor("Your key for clan '" + text + "' has been revoked."); ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, val3, ref val4); ctx.Reply($"Key revoked from {val3.CharacterName} for {text}."); } public static List<(PlayerData PlayerData, ClanKeyData Key)> GetKeysForClan(string clanGuid) { EnsureCache(); List<(PlayerData, ClanKeyData)> list = new List<(PlayerData, ClanKeyData)>(); foreach (PlayerData allPlayerDatum in PlayerDataService.GetAllPlayerData()) { foreach (ClanKeyData item in allPlayerDatum.ClanKeys.Where((ClanKeyData k) => k.ClanGuid.Equals(clanGuid, StringComparison.OrdinalIgnoreCase))) { list.Add((allPlayerDatum, item)); } } return list; } public static Dictionary GetAllClansKeyCounts() { EnsureCache(); Dictionary dictionary = new Dictionary(); foreach (PlayerData allPlayerDatum in PlayerDataService.GetAllPlayerData()) { foreach (ClanKeyData clanKey in allPlayerDatum.ClanKeys) { if (!string.IsNullOrEmpty(clanKey.ClanGuid)) { if (dictionary.ContainsKey(clanKey.ClanGuid)) { dictionary[clanKey.ClanGuid]++; } else { dictionary[clanKey.ClanGuid] = 1; } } } } return dictionary; } public static List GetClansWithKeysForPlayer(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (from k in GetPlayerData(playerEntity.Read()).ClanKeys where !string.IsNullOrEmpty(k.ClanGuid) select k.ClanName).ToList(); } public static void JoinClan(ChatCommandContext ctx, string clanName) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002c: 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) //IL_0052: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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_02af: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; User user = senderUserEntity.Read(); if (!((object)(NetworkedEntity)(ref user.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ClanTeam val = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer().Read(); string text = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); ctx.Reply("You are already in a clan: '" + text + "'. Leave it first."); return; } string baseName = clanName; int? num = null; Match match = Regex.Match(clanName, "^(.+?)\\s+#(\\d+)$"); if (match.Success) { baseName = match.Groups[1].Value; num = int.Parse(match.Groups[2].Value); } List list = GetPlayerData(user).ClanKeys.Where((ClanKeyData k) => k.ClanName.Equals(baseName, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(k.ClanGuid)).OrderBy((ClanKeyData k) => k.ClanGuid, StringComparer.OrdinalIgnoreCase).ToList(); if (list.Count == 0) { List clansWithKeysForPlayer = GetClansWithKeysForPlayer(senderUserEntity); ctx.Reply("You don't have a key for clan '" + baseName + "'. You have keys for: " + string.Join(", ", clansWithKeysForPlayer)); } else if (num.HasValue) { if (num.Value < 1 || num.Value > list.Count) { ctx.Reply($"Index #{num.Value} out of range. You have {list.Count} key(s) for clan '{baseName}'."); } else { ClanKeyData targetKey = list[num.Value - 1]; JoinClanByKey(ctx, senderUserEntity, user, targetKey); } } else if (list.Count > 1) { NativeArray entitiesByComponentType = EntityService.GetEntitiesByComponentType(); StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(57, 1, stringBuilder2); handler.AppendLiteral("Ambiguous clan name '"); handler.AppendFormatted(baseName); handler.AppendLiteral("'. You have keys for multiple clans:"); stringBuilder3.AppendLine(ref handler); for (int i = 0; i < list.Count; i++) { ClanKeyData clanKeyData = list[i]; string value = "(no motto)"; int value2 = 0; Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val2 = current.Read(); if (((object)(Guid)(ref val2.ClanGuid)).ToString().Equals(clanKeyData.ClanGuid, StringComparison.OrdinalIgnoreCase)) { string text2 = ((object)(FixedString64Bytes)(ref val2.Motto)).ToString(); if (!string.IsNullOrEmpty(text2)) { value = "\"" + text2 + "\""; } EntityManager entityManager = Core.EntityManager; value2 = ((EntityManager)(ref entityManager)).GetBuffer(current, false).Length; break; } } stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(18, 4, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(i + 1); handler.AppendLiteral(". "); handler.AppendFormatted(clanKeyData.ClanName); handler.AppendLiteral(" - "); handler.AppendFormatted(value); handler.AppendLiteral(" ("); handler.AppendFormatted(value2); handler.AppendLiteral(" members)"); stringBuilder4.AppendLine(ref handler); } stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(50, 2, stringBuilder2); handler.AppendLiteral("Use .keys use \""); handler.AppendFormatted(baseName); handler.AppendLiteral(" #1\" or .keys use \""); handler.AppendFormatted(baseName); handler.AppendLiteral(" #2\" to specify."); stringBuilder5.Append(ref handler); ctx.Reply(stringBuilder.ToString()); } else { JoinClanByKey(ctx, senderUserEntity, user, list[0]); } } private static void JoinClanByKey(ChatCommandContext ctx, Entity userEntity, User user, ClanKeyData targetKey) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0035: 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_0067: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) string clanGuid = targetKey.ClanGuid; string clanName = targetKey.ClanName; NativeArray entitiesByComponentType = EntityService.GetEntitiesByComponentType(); Entity val = Entity.Null; Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val2 = current.Read(); if (((object)(Guid)(ref val2.ClanGuid)).ToString().Equals(clanGuid, StringComparison.OrdinalIgnoreCase)) { val = current; break; } } if (((Entity)(ref val)).Equals(Entity.Null)) { ctx.Reply("Clan '" + clanName + "' not found."); return; } ClanTeam val3 = val.Read(); clanName = ((object)(FixedString64Bytes)(ref val3.Name)).ToString(); bool num = IsClanAtCapacity(val, ignoreLimit: false); bool canIgnoreClanLimit = targetKey.CanIgnoreClanLimit; if (num && !canIgnoreClanLimit) { ctx.Reply("Clan '" + clanName + "' is at maximum capacity."); return; } CastleHeartLimitType val4 = (CastleHeartLimitType)0; TeamUtility.AddUserToClan(Core.EntityManager, val, userEntity, ref user, val4); userEntity.Write(user); ClanRole componentData = userEntity.Read(); componentData.Value = (ClanRoleEnum)(targetKey.IsOwnerKey ? 2 : 0); userEntity.Write(componentData); ctx.Reply("Joined clan '" + clanName + "'!"); DiscordWebhookService.SendGameEventMessageToWebhook(DiscordLogType.ClanKeyJoin, userEntity, val); } public static bool IsClanAtCapacity(Entity clanEntity, bool ignoreLimit) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (ignoreLimit) { return false; } EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false).Length >= ConfigService.ClanMemberLimit; } public static void RevokeAllKeysForClan(ChatCommandContext ctx, string clanName, bool deRegister = false) { //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity clanEntity = GetClanEntity(clanName, ctx); if (((Entity)(ref clanEntity)).Equals(Entity.Null)) { return; } ClanTeam val = clanEntity.Read(); List<(PlayerData PlayerData, ClanKeyData Key)> keysForClan = GetKeysForClan(((object)(Guid)(ref val.ClanGuid)).ToString()); int num = 0; foreach (var (playerData, clanKeyData) in keysForClan) { if (playerData != null && (deRegister || !clanKeyData.IsOwnerKey)) { playerData.ClanKeys.Remove(clanKeyData); num++; } } if (num > 0) { PlayerDataService.SaveData(); RefreshCache(); } ctx.Reply($"Revoked {num} keys for clan '{clanName}'."); } public static void DeregisterClan(ChatCommandContext ctx, string clanName) { //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity clanEntity = GetClanEntity(clanName, ctx); if (!((Entity)(ref clanEntity)).Equals(Entity.Null)) { ClanTeam val = clanEntity.Read(); if (!IsClanRegistered(((object)(Guid)(ref val.ClanGuid)).ToString())) { ctx.Reply("Clan '" + clanName + "' is not registered."); return; } RevokeAllKeysForClan(ctx, clanName, deRegister: true); RefreshCache(); ctx.Reply("Clan '" + clanName + "' deregistered and all keys revoked."); } } public static void IssueKeysToAll(ChatCommandContext ctx, Entity senderUserEntity, string clanName, bool canBypass) { //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity clanEntity = GetClanEntity(clanName, ctx); if (((Entity)(ref clanEntity)).Equals(Entity.Null)) { return; } ClanTeam val = clanEntity.Read(); string value = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false); entityManager = Core.EntityManager; DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false); int num = 0; for (int i = 0; i < buffer.Length; i++) { _ = buffer[i]; Entity userEntity = buffer2[i].UserEntity; if (!((Entity)(ref userEntity)).Equals(senderUserEntity)) { IssueKey(ctx, senderUserEntity, userEntity, clanName, canBypass, isAdmin: false, forceOwnershipValidation: false); num++; } } ctx.Reply($"Issued keys to {num} members of clan '{value}'."); } public static void ListMine(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) PlayerData playerData = GetPlayerData(ctx.Event.SenderUserEntity.Read()); List<(string, string)> list = new List<(string, string)>(); foreach (ClanKeyData clanKey in playerData.ClanKeys) { if (!string.IsNullOrEmpty(clanKey.ClanName) && !string.IsNullOrEmpty(clanKey.ClanGuid)) { string item = (clanKey.IsOwnerKey ? "OWNER" : (clanKey.CanIgnoreClanLimit ? "ADMIN (bypasses limits)" : "MEMBER")); list.Add((clanKey.ClanName, item)); } } if (list.Count == 0) { ctx.Reply("You have no keys."); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Keys you possess:"); foreach (var item4 in list) { string item2 = item4.Item1; string item3 = item4.Item2; StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(16, 2, stringBuilder2); handler.AppendLiteral(" Clan: "); handler.AppendFormatted(item2); handler.AppendLiteral(", Type: "); handler.AppendFormatted(item3); stringBuilder2.AppendLine(ref handler); } stringBuilder.AppendLine("Use .keys use \"Clan Name\" to join a clan."); ctx.Reply(stringBuilder.ToString()); } public static void ListClan(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //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_001a: 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_0096: Unknown result type (might be due to invalid IL or missing references) Entity senderUserEntity = ctx.Event.SenderUserEntity; User val = senderUserEntity.Read(); if (((object)(NetworkedEntity)(ref val.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply("You are not in a clan."); return; } ClanTeam val2 = ((NetworkedEntity)(ref val.ClanEntity)).GetEntityOnServer().Read(); string text = ((object)(FixedString64Bytes)(ref val2.Name)).ToString(); string clanGuid = ((object)(Guid)(ref val2.ClanGuid)).ToString(); if (!IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text + "' is not registered with the keys system. Use .keys register."); return; } if (!CanIssueKeys(senderUserEntity, clanGuid)) { ctx.Reply("Only the clan owner can list keys."); return; } List<(PlayerData, ClanKeyData)> keysForClan = GetKeysForClan(clanGuid); if (keysForClan.Count == 0) { ctx.Reply("No keys issued for clan '" + text + "'."); return; } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(24, 1, stringBuilder2); handler.AppendLiteral("Keys issued for clan '"); handler.AppendFormatted(text); handler.AppendLiteral("':"); stringBuilder3.AppendLine(ref handler); foreach (var item3 in keysForClan) { PlayerData item = item3.Item1; ClanKeyData item2 = item3.Item2; string value = (item2.IsOwnerKey ? "OWNER" : (item2.CanIgnoreClanLimit ? "ADMIN" : "MEMBER")); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(5, 2, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(item.CharacterName); handler.AppendLiteral(" - "); handler.AppendFormatted(value); stringBuilder4.AppendLine(ref handler); } ctx.Reply(stringBuilder.ToString()); } public static void ListAll(ChatCommandContext ctx) { //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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Dictionary allClansKeyCounts = GetAllClansKeyCounts(); if (allClansKeyCounts.Count == 0) { ctx.Reply("No clans have been registered with keys."); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Clans registered with keys:"); foreach (KeyValuePair item in allClansKeyCounts.OrderByDescending((KeyValuePair kv) => kv.Value)) { item.Deconstruct(out var key, out var value); string text = key; int value2 = value; NativeArray entitiesByComponentType = EntityService.GetEntitiesByComponentType(); string value3 = text; Enumerator enumerator2 = entitiesByComponentType.GetEnumerator(); while (enumerator2.MoveNext()) { ClanTeam val = enumerator2.Current.Read(); if (((object)(Guid)(ref val.ClanGuid)).ToString().Equals(text, StringComparison.OrdinalIgnoreCase)) { value3 = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); break; } } StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(11, 2, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(value3); handler.AppendLiteral(": "); handler.AppendFormatted(value2); handler.AppendLiteral(" key(s)"); stringBuilder2.AppendLine(ref handler); } ctx.Reply(stringBuilder.ToString()); } public static void ListClanByName(ChatCommandContext ctx, string clanName) { string clanGuidFromName = GetClanGuidFromName(clanName, ctx); if (clanGuidFromName == null) { return; } List<(PlayerData, ClanKeyData)> keysForClan = GetKeysForClan(clanGuidFromName); if (keysForClan.Count == 0) { ctx.Reply("No keys issued for clan '" + clanName + "'."); return; } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(12, 1, stringBuilder2); handler.AppendLiteral("Keys for '"); handler.AppendFormatted(clanName); handler.AppendLiteral("':"); stringBuilder3.AppendLine(ref handler); foreach (var item3 in keysForClan) { PlayerData item = item3.Item1; ClanKeyData item2 = item3.Item2; string value = (item2.IsOwnerKey ? "OWNER" : (item2.CanIgnoreClanLimit ? "ADMIN" : "MEMBER")); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(5, 2, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(item.CharacterName); handler.AppendLiteral(" - "); handler.AppendFormatted(value); stringBuilder4.AppendLine(ref handler); } ctx.Reply(stringBuilder.ToString()); } public static void RemovePlayerKey(ChatCommandContext ctx, string playerName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!EntityService.TryFindPlayer(playerName, out var _, out var userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); } else { RevokeKey(ctx, userEntity); } } public static void RemoveClanKeys(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //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_001a: 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_0096: Unknown result type (might be due to invalid IL or missing references) Entity senderUserEntity = ctx.Event.SenderUserEntity; User val = senderUserEntity.Read(); if (((object)(NetworkedEntity)(ref val.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ctx.Reply("You are not in a clan."); return; } ClanTeam val2 = ((NetworkedEntity)(ref val.ClanEntity)).GetEntityOnServer().Read(); string text = ((object)(FixedString64Bytes)(ref val2.Name)).ToString(); string clanGuid = ((object)(Guid)(ref val2.ClanGuid)).ToString(); if (!IsClanRegistered(clanGuid)) { ctx.Reply("Clan '" + text + "' is not registered with the keys system. Use .keys register."); } else if (!CanIssueKeys(senderUserEntity, clanGuid)) { ctx.Reply("Only the clan owner can revoke all keys."); } else { RevokeAllKeysForClan(ctx, text); } } public static void IssueKeysInRadius(ChatCommandContext ctx, Entity senderUserEntity, string clanName, float radius, bool canBypass) { //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity clanEntity = GetClanEntity(clanName, ctx); if (((Entity)(ref clanEntity)).Equals(Entity.Null)) { return; } ClanTeam val = clanEntity.Read(); string value = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); List nearbyUserEntities = EntityService.GetNearbyUserEntities(ctx.Event.SenderCharacterEntity, radius); int num = 0; foreach (Entity item in nearbyUserEntities) { Entity current = item; if (!((Entity)(ref current)).Equals(ctx.Event.SenderCharacterEntity)) { IssueKey(ctx, senderUserEntity, current, clanName, canBypass, isAdmin: false, forceOwnershipValidation: false); num++; } } ctx.Reply($"Issued keys to {num} nearby players for clan '{value}'."); } } public static class PlayerDataService { private static readonly string SaveDirectory = Path.Combine(Directory.GetCurrentDirectory(), "BepInEx", "config", "Keys"); private static readonly string SavePath = Path.Combine(SaveDirectory, "keys_player_data.json"); private static List _playerDataList = new List(); private static Dictionary _playerDataCache = new Dictionary(); private static bool _dataDirty = false; private static bool _periodicSaveCoroutineRunning = false; private const float PERIODIC_SAVE_INTERVAL = 30f; public static readonly PrefabGUID CHAR_VampireMale = new PrefabGUID(38526109); private static void MigrateLegacyPlayerData() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown if (!File.Exists(SavePath)) { return; } string json = File.ReadAllText(SavePath); bool flag = false; try { List list = JsonSerializer.Deserialize>(json); if (list != null && list.Count > 0) { flag = true; } } catch { } if (flag) { return; } try { Dictionary dictionary = JsonSerializer.Deserialize>(json); if (dictionary != null && dictionary.Count > 0) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found legacy player data. Records: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(dictionary.Count); } log.LogInfo(val); List list2 = dictionary.Values.ToList(); string contents = JsonSerializer.Serialize(list2); File.WriteAllText(SavePath, contents); ManualLogSource log2 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Migrated legacy player data to array format. Records: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list2.Count); } log2.LogInfo(val); return; } } catch { } Core.Log.LogError((object)"Player data file is invalid or corrupt. Migration failed."); } public static void Initialize() { Directory.CreateDirectory(SaveDirectory); MigrateLegacyPlayerData(); LoadData(); } public static PlayerData GetPlayerData(Entity characterEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0054: 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_005a: 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_007d: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Entity val = characterEntity; EntityManager entityManager = Core.EntityManager; PrefabGUID val2 = default(PrefabGUID); if (((EntityManager)(ref entityManager)).TryGetComponentData(characterEntity, ref val2) && !((PrefabGUID)(ref val2)).Equals(CHAR_VampireMale)) { entityManager = Core.EntityManager; ControlledBy val3 = default(ControlledBy); if (((EntityManager)(ref entityManager)).TryGetComponentData(characterEntity, ref val3)) { val = val3.Controller.GetUser().LocalCharacter._Entity; } } val.GetSteamId(); User user = val.GetUser(); string text = ((object)(FixedString64Bytes)(ref user.CharacterName)).ToString(); if (string.IsNullOrEmpty(text)) { text = "Unknown DAFUQ HAPPENED"; } int guidHash = GetGuidHash(val); if (guidHash != 0 && _playerDataCache.TryGetValue(guidHash, out var value)) { return value; } return GetOrCreatePlayerData(guidHash, text, val); } private static PlayerData GetOrCreatePlayerData(int guidHash, string characterName, Entity characterEntity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) ulong steamId = characterEntity.GetSteamId(); if (guidHash != 0) { PlayerData playerData = _playerDataList.Find((PlayerData pd) => pd.GuidHash == guidHash); if (playerData != null) { playerData.CharacterName = characterName; _playerDataCache[guidHash] = playerData; return playerData; } } PlayerData playerData2 = _playerDataList.Find((PlayerData pd) => pd.CharacterName == characterName && pd.GuidHash == 0); EntityManager entityManager; PrefabGUID val2; if (playerData2 != null) { SequenceGUID val = default(SequenceGUID); ((SequenceGUID)(ref val))..ctor(Guid.NewGuid().GetHashCode()); entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).AddComponentData(characterEntity, val); playerData2.GuidHash = val.GuidHash; val2 = CHAR_VampireMale; playerData2.PrefabGuidHash = ((PrefabGUID)(ref val2)).GuidHash; guidHash = val.GuidHash; _playerDataCache[guidHash] = playerData2; SaveData(); return playerData2; } PlayerData obj = new PlayerData { SteamId = steamId, CharacterName = characterName, GuidHash = ((guidHash != 0) ? guidHash : Guid.NewGuid().GetHashCode()) }; val2 = characterEntity.GetPrefabGuid(); obj.PrefabGuidHash = ((PrefabGUID)(ref val2)).GuidHash; PlayerData playerData3 = obj; if (guidHash == 0) { SequenceGUID val3 = default(SequenceGUID); ((SequenceGUID)(ref val3))..ctor(playerData3.GuidHash); entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).AddComponentData(characterEntity, val3); guidHash = playerData3.GuidHash; } _playerDataList.Add(playerData3); _playerDataCache[guidHash] = playerData3; SaveData(); return playerData3; } public static List GetAllPlayerData() { return _playerDataList; } public static void SaveData() { MarkDirty(); } public static void MarkDirty() { _dataDirty = true; if (!_periodicSaveCoroutineRunning) { Core.StartCoroutine(PeriodicSaveCoroutine()); _periodicSaveCoroutineRunning = true; } } private static IEnumerator PeriodicSaveCoroutine() { while (true) { yield return (object)new WaitForSeconds(30f); if (_dataDirty) { FlushSaveToDisk(); _dataDirty = false; } } } public static void FlushSaveToDisk() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown try { string contents = JsonSerializer.Serialize(_playerDataList); File.WriteAllText(SavePath, contents); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save player data: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } private static void LoadData() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown if (!File.Exists(SavePath)) { return; } try { _playerDataList = JsonSerializer.Deserialize>(File.ReadAllText(SavePath)) ?? new List(); _playerDataCache.Clear(); foreach (PlayerData playerData in _playerDataList) { if (playerData.GuidHash != 0) { _playerDataCache[playerData.GuidHash] = playerData; } } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load player data: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); _playerDataList = new List(); _playerDataCache.Clear(); } } private static int GetGuidHash(Entity characterEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0017: 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) int result = 0; EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(characterEntity)) { entityManager = Core.EntityManager; result = ((EntityManager)(ref entityManager)).GetComponentData(characterEntity).GuidHash; } return result; } } internal static class QueryService { private static readonly EntityQuery _playerCharactersQuery; private static EntityManager EntityManager => Core.EntityManager; public static EntityQuery PlayerCharactersQuery => _playerCharactersQuery; static QueryService() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; _playerCharactersQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); } } } namespace Keys.Patches { [HarmonyPatch] internal static class InitializationPatch { [HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")] [HarmonyPostfix] private static void OnUpdatePostfix() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown bool flag = default(bool); try { Core.Initialize(); if (Core._initialized) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Keys"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] initialized!"); } log.LogInfo(val); Plugin.Harmony.Unpatch((MethodBase)typeof(SpawnTeamSystem_OnPersistenceLoad).GetMethod("OnUpdate"), typeof(InitializationPatch).GetMethod("OnUpdatePostfix")); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(47, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("Keys"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] failed to initialize, exiting on try-catch: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } } } namespace Keys.Models { public class PlayerData { public ulong SteamId { get; set; } public string CharacterName { get; set; } public int GuidHash { get; set; } public int PrefabGuidHash { get; set; } public int LastControlledPlayerGuidHash { get; set; } public List ClanKeys { get; set; } = new List(); } public class ClanKeyData { public string ClanName { get; set; } public string ClanGuid { get; set; } public bool IsOwnerKey { get; set; } public bool CanIgnoreClanLimit { get; set; } public DateTime IssuedTime { get; set; } } } namespace Keys.Commands { [CommandGroup("keys", null)] internal static class KeyCommands { [Command("register", "Register your clan with the keys system", null, null, null, false)] public static void RegisterClanCommand(ChatCommandContext ctx) { KeyManagementService.RegisterClan(ctx); } [Command("owner", "Transfer ownership to another player (owner only)", null, null, null, false)] public static void TransferOwnershipCommand(ChatCommandContext ctx, string playerName) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) Entity playerEntity; Entity userEntity; if (string.IsNullOrEmpty(playerName)) { ctx.Reply("Please specify a player name."); } else if (!EntityService.TryFindPlayer(playerName, out playerEntity, out userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); } else { KeyManagementService.TransferOwnership(ctx, userEntity); } } [Command("owner", "Transfer ownership from one player to another (admin)", null, null, null, true)] public static void TransferOwnershipCommand(ChatCommandContext ctx, string originalOwnerName, string newOwnerName) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Entity playerEntity; Entity userEntity; Entity playerEntity2; Entity userEntity2; if (string.IsNullOrEmpty(originalOwnerName)) { ctx.Reply("Please specify the original owner's name."); } else if (!EntityService.TryFindPlayer(originalOwnerName, out playerEntity, out userEntity)) { ctx.Reply("Original owner '" + originalOwnerName + "' not found."); } else if (string.IsNullOrEmpty(newOwnerName)) { ctx.Reply("Please specify the new owner's name."); } else if (!EntityService.TryFindPlayer(newOwnerName, out playerEntity2, out userEntity2)) { ctx.Reply("New owner '" + newOwnerName + "' not found."); } else { KeyManagementService.TransferOwnership(ctx, userEntity2, userEntity); } } [Command("give", "Issue a key to a player", null, null, null, false)] public static void IssueKeyCommand(ChatCommandContext ctx, string playerName) { //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_0045: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(playerName)) { ctx.Reply("Please specify a player name."); return; } if (!EntityService.TryFindPlayer(playerName, out var _, out var userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; KeyManagementService.IssueKey(ctx, senderUserEntity, userEntity); } [Command("give", "Issue a key for a specific clan (admin)", null, null, null, true)] public static void IssueKeyCommand(ChatCommandContext ctx, string playerName, string clanName) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0059: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(playerName)) { ctx.Reply("Please specify a player name."); return; } if (!EntityService.TryFindPlayer(playerName, out var _, out var userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); return; } if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; KeyManagementService.IssueKey(ctx, senderUserEntity, userEntity, clanName, canIgnoreLimit: false, isAdmin: true, forceOwnershipValidation: false); } [Command("give", "Issue a key for a specific clan with optional bypass (admin)", null, null, null, true)] public static void IssueKeyCommand(ChatCommandContext ctx, string playerName, string clanName, string bypassKeyword) { //IL_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(playerName)) { ctx.Reply("Please specify a player name."); return; } if (!EntityService.TryFindPlayer(playerName, out var _, out var userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); return; } if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } bool canIgnoreLimit = !string.IsNullOrEmpty(bypassKeyword) && bypassKeyword.Equals("bypass", StringComparison.OrdinalIgnoreCase); Entity senderUserEntity = ctx.Event.SenderUserEntity; KeyManagementService.IssueKey(ctx, senderUserEntity, userEntity, clanName, canIgnoreLimit, isAdmin: true, forceOwnershipValidation: false); } [Command("giveall", "Give keys to everyone for a specific clan (admin)", null, null, null, true)] public static void IssueKeysToAllCommand(ChatCommandContext ctx, string clanName, string bypassKeyword = null) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } bool canBypass = !string.IsNullOrEmpty(bypassKeyword) && bypassKeyword.Equals("bypass", StringComparison.OrdinalIgnoreCase); Entity senderUserEntity = ctx.Event.SenderUserEntity; KeyManagementService.IssueKeysToAll(ctx, senderUserEntity, clanName, canBypass); } [Command("giveradius", "Give keys to everyone in radius for a specific clan (admin)", null, null, null, true)] public static void IssueKeysInRadiusCommand(ChatCommandContext ctx, string clanName, float radius = 10f, string bypassKeyword = null) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } if (radius <= 0f) { ctx.Reply("Please specify a valid radius."); return; } bool canBypass = !string.IsNullOrEmpty(bypassKeyword) && bypassKeyword.Equals("bypass", StringComparison.OrdinalIgnoreCase); Entity senderUserEntity = ctx.Event.SenderUserEntity; KeyManagementService.IssueKeysInRadius(ctx, senderUserEntity, clanName, radius, canBypass); } [Command("list", "List keys. Usage: .keys list mine|clan|all|", null, null, null, false)] public static void ListCommand(ChatCommandContext ctx, string target = null) { if (string.IsNullOrEmpty(target)) { ctx.Reply("Usage: .keys list mine|clan|all|"); } else if (target.Equals("mine", StringComparison.OrdinalIgnoreCase)) { KeyManagementService.ListMine(ctx); } else if (target.Equals("clan", StringComparison.OrdinalIgnoreCase)) { KeyManagementService.ListClan(ctx); } else if (target.Equals("all", StringComparison.OrdinalIgnoreCase)) { if (!ctx.IsAdmin) { ctx.Reply("That command is admin only."); } else { KeyManagementService.ListAll(ctx); } } else if (!ctx.IsAdmin) { ctx.Reply("That command is admin only."); } else { KeyManagementService.ListClanByName(ctx, target); } } [Command("remove", "Remove a key. Usage: .keys remove |clan", null, null, null, false)] public static void RemoveCommand(ChatCommandContext ctx, string target) { if (target.Equals("clan", StringComparison.OrdinalIgnoreCase)) { KeyManagementService.RemoveClanKeys(ctx); } else { KeyManagementService.RemovePlayerKey(ctx, target); } } [Command("remove", "Remove a player's key for any clan (admin)", null, null, null, true)] public static void RemoveCommand(ChatCommandContext ctx, string playerName, string clanName) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) Entity playerEntity; Entity userEntity; if (string.IsNullOrEmpty(playerName)) { ctx.Reply("Please specify a player name."); } else if (!EntityService.TryFindPlayer(playerName, out playerEntity, out userEntity)) { ctx.Reply("Player '" + playerName + "' not found."); } else if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); } else { KeyManagementService.RevokeKey(ctx, userEntity, force: true); } } [Command("deregister", "Deregister a clan and remove all keys (admin)", null, null, null, true)] public static void DeregisterClanCommand(ChatCommandContext ctx, string clanName) { if (string.IsNullOrEmpty(clanName)) { ctx.Reply("Please specify a clan name."); return; } KeyManagementService.DeregisterClan(ctx, clanName); ctx.Reply("Clan '" + clanName + "' has been deregistered and all keys have been removed."); } [Command("use", "Join a clan using your key", null, null, null, false)] public static void JoinClanCommand(ChatCommandContext ctx, string clanName) { KeyManagementService.JoinClan(ctx, clanName); } } }