Decompiled source of Keys v1.0.1
BepInEx\plugins\Keys.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
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>)World.s_AllWorlds.ToArray()).FirstOrDefault((Func<World, bool>)((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<IgnorePhysicsDebugSystem>(); Object.DontDestroyOnLoad((Object)(object)((Component)_monoBehaviour).gameObject); } _monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public readonly struct NativeAccessor<T> : IDisposable where T : unmanaged { private static NativeArray<T> _array; public T this[int index] { get { return _array[index]; } set { _array[index] = value; } } public int Length => _array.Length; public NativeAccessor(NativeArray<T> 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<T> 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<T>(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<T>()) { componentData = entity.Read<T>(); return true; } return false; } public static bool Has<T>(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<T>(), (AccessMode)0)); } public static T Read<T>(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<T>(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<PlayerCharacter>(out PlayerCharacter componentData)) { return componentData.UserEntity.GetUser().PlatformId; } if (entity.TryGetComponent<User>(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<User>(out User componentData)) { return componentData; } if (entity.TryGetComponent<PlayerCharacter>(out PlayerCharacter componentData2) && componentData2.UserEntity.TryGetComponent<User>(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<char> span = ((object)(Entity)(ref entity)).ToString().AsSpan(); if (!span.StartsWith("Entity(")) { return false; } ref ReadOnlySpan<char> 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<char> 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<PrefabGUID>(out PrefabGUID componentData)) { return componentData; } return PrefabGUID.Empty; } public unsafe static void Write<T>(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<T>(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf<T>(); fixed (byte* ptr = array) { EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } public static byte[] StructureToByteArray<T>(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<string>("Keys"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("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<string, object> FinalConfigValues = new Dictionary<string, object>(); private static readonly Lazy<List<string>> _directoryPaths = new Lazy<List<string>>(() => new List<string>(1) { Path.Combine(Paths.ConfigPath, "Keys") }); public static readonly List<string> SectionOrder = new List<string>(1) { "General" }; public static readonly List<ConfigEntryDefinition> ConfigEntries = new List<ConfigEntryDefinition>(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<string> 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<string>(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<T> InitConfigEntry<T>(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<T> val = ((BasePlugin)Plugin.Instance).Config.Bind<T>(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<string>(key); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(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<string, List<string>> dictionary = new Dictionary<string, List<string>>(); 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<string>(); } } 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<string> list = dictionary[section]; List<string> list2 = new List<string>(); list2.AddRange(from line in list where line.Contains('=') select line.Split('=')[0].Trim()); List<string> sectionKeys = list2; Dictionary<string, object> 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<string>(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<string>(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<string>(ex.Message); } log3.LogError(val2); } } } private static readonly Lazy<bool> _DEV = new Lazy<bool>(() => GetConfigValue<bool>("DEV")); private static readonly Lazy<string> _DiscordProdGameEventsWebhookUrl = new Lazy<string>(() => GetConfigValue<string>("DiscordProdGameEventsWebhookUrl")); private static readonly Lazy<string> _DiscordDevGameEventsWebhookUrl = new Lazy<string>(() => GetConfigValue<string>("DiscordDevGameEventsWebhookUrl")); private static readonly Lazy<int> _ClanMemberLimit = new Lazy<int>(() => GetConfigValue<int>("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<T>(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<User>() || userEntity.Has<PlayerCharacter>()) { User user = userEntity.GetUser(); text2 = ((object)(FixedString64Bytes)(ref user.CharacterName)).ToString(); } if (userEntity.Has<Translation>()) { value = userEntity.Read<Translation>().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>()) { ClanTeam val = targetEntity.Read<ClanTeam>(); 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<HttpStatusCode>(response.StatusCode); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(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<string>(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<User>() }); Enumerator<Entity> 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<User>(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<Entity> 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<Entity> list = new List<Entity>(); EntityManager entityManager = EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<Translation>(playerEntity)) { return list; } entityManager = EntityManager; float3 value = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(playerEntity).Value; EntityQuery playerCharactersQuery = QueryService.PlayerCharactersQuery; Enumerator<Entity> 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<PlayerCharacter>(current).UserEntity; entityManager = EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<Translation>(userEntity)) { entityManager = EntityManager; float3 value2 = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(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<Entity> GetEntitiesByComponentType<T1>(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<T1>(), (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<int, ClanKeyData> KeysByPlayer { get; set; } = new Dictionary<int, ClanKeyData>(); } private static Dictionary<string, ClanCacheEntry> _clanCache = new Dictionary<string, ClanCacheEntry>(); 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<Entity> entitiesByComponentType = EntityService.GetEntitiesByComponentType<ClanTeam>(); Enumerator<Entity> enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val = current.Read<ClanTeam>(); 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<ClanTeam>(); 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<ClanTeam>(); 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<ClanTeam>(); 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<ClanMemberStatus>(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<ClanTeam>(); 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<PlayerData> allPlayerData = PlayerDataService.GetAllPlayerData(); int num = 0; int num2 = 0; int num3 = 0; bool flag = false; foreach (PlayerData playerData in allPlayerData) { int num4 = 0; List<ClanKeyData> list = new List<ClanKeyData>(); 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<int>(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<int>(_clanCache.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" clans registered, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" total keys across "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(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<User>(); 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<ClanTeam>(); 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<ClanMemberStatus> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ClanMemberStatus>(entityOnServer, false); entityManager = Core.EntityManager; DynamicBuffer<SyncToUserBuffer> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<SyncToUserBuffer>(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 <player> 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<User>(); 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<ClanTeam>(); 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<User>(); 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<User>()).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<User>(); 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<ClanTeam>(); 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<ClanTeam>(); 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<User>(); 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 <color=green>.keys use \"{text}\"</color> 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 <color=green>.keys use \"{text}\"</color> 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<User>(); 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<ClanTeam>(); 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<User>(); 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<string, int> GetAllClansKeyCounts() { EnsureCache(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); 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<string> 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<User>()).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<User>(); if (!((object)(NetworkedEntity)(ref user.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) { ClanTeam val = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer().Read<ClanTeam>(); 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<ClanKeyData> list = GetPlayerData(user).ClanKeys.Where((ClanKeyData k) => k.ClanName.Equals(baseName, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(k.ClanGuid)).OrderBy<ClanKeyData, string>((ClanKeyData k) => k.ClanGuid, StringComparer.OrdinalIgnoreCase).ToList(); if (list.Count == 0) { List<string> 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<Entity> entitiesByComponentType = EntityService.GetEntitiesByComponentType<ClanTeam>(); 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<Entity> enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val2 = current.Read<ClanTeam>(); 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<ClanMemberStatus>(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<Entity> entitiesByComponentType = EntityService.GetEntitiesByComponentType<ClanTeam>(); Entity val = Entity.Null; Enumerator<Entity> enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClanTeam val2 = current.Read<ClanTeam>(); 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<ClanTeam>(); 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>(user); ClanRole componentData = userEntity.Read<ClanRole>(); componentData.Value = (ClanRoleEnum)(targetKey.IsOwnerKey ? 2 : 0); userEntity.Write<ClanRole>(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<ClanMemberStatus>(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<ClanTeam>(); 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<ClanTeam>(); 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<ClanTeam>(); string value = ((object)(FixedString64Bytes)(ref val.Name)).ToString(); EntityManager entityManager = Core.EntityManager; DynamicBuffer<ClanMemberStatus> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ClanMemberStatus>(clanEntity, false); entityManager = Core.EntityManager; DynamicBuffer<SyncToUserBuffer> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<SyncToUserBuffer>(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<User>()); 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 <color=green>.keys use \"Clan Name\"</color> 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<User>(); 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<ClanTeam>(); 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<string, int> 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<string, int> item in allClansKeyCounts.OrderByDescending((KeyValuePair<string, int> kv) => kv.Value)) { item.Deconstruct(out var key, out var value); string text = key; int value2 = value; NativeArray<Entity> entitiesByComponentType = EntityService.GetEntitiesByComponentType<ClanTeam>(); string value3 = text; Enumerator<Entity> enumerator2 = entitiesByComponentType.GetEnumerator(); while (enumerator2.MoveNext()) { ClanTeam val = enumerator2.Current.Read<ClanTeam>(); 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<User>(); if (((object)(NetworkedEntity)(ref val.ClanEntity)).Equals((object?)NetworkedEntity.Empty)) {