using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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; 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 Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using PlayerServices.Data; using PlayerServices.Services; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Network; using ProjectM.Physics; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Terrain; using Stunlock.Core; using Stunlock.Network; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Scenes; using Unity.Transforms; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("PlayerServices")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Server-side V Rising mod that adds player services, including player info, starter kits, daily kits, give sets, teleport points, aura purchases, name changes, banlist, whitelist, and admin tools")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PlayerServices")] [assembly: AssemblyTitle("PlayerServices")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 PlayerServices { public static class Buffs { public static bool AddBuff(Entity User, Entity Character, PrefabGUID buffPrefab, int duration = 0, bool immortal = true) { //IL_000e: 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_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0060: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_008a: 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_0097: 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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) DebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged(); ApplyBuffDebugEvent val = new ApplyBuffDebugEvent { BuffPrefabGUID = buffPrefab }; FromCharacter val2 = new FromCharacter { User = User, Character = Character }; Entity entity = default(Entity); if (!BuffUtility.TryGetBuff(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity)) { existingSystemManaged.ApplyBuff(val2, val); if (BuffUtility.TryGetBuff(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity)) { if (entity.Has()) { entity.Remove(); } if (entity.Has()) { entity.Remove(); } if (immortal) { entity.Add(); if (entity.Has()) { entity.Remove(); } if (entity.Has()) { entity.Remove(); } } if (duration > -1 && duration != 0) { if (!entity.Has()) { entity.Add(); entity.Write(new LifeTime { EndAction = (LifeTimeEndAction)2 }); } LifeTime componentData = entity.Read(); componentData.Duration = duration; entity.Write(componentData); } else if (duration == -1) { if (entity.Has()) { LifeTime componentData2 = entity.Read(); componentData2.EndAction = (LifeTimeEndAction)0; entity.Write(componentData2); } if (entity.Has()) { entity.Remove(); } if (entity.Has()) { entity.Remove(); } } return true; } return false; } return false; } public static void RemoveBuff(Entity Character, PrefabGUID buffPrefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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 val = default(Entity); if (BuffUtility.TryGetBuff(Core.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref val)) { DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0); } } } internal static class Core { private static World _server; private static bool _hasInitialized; public const int MAX_REPLY_LENGTH = 509; private static MonoBehaviour monoBehaviour; public static World Server { get { if (_server == null) { _server = GetWorld("Server"); } return _server; } } public static EntityManager EntityManager => Server.EntityManager; public static bool IsServer => Application.productName == "VRisingServer"; public static GameDataSystem GameDataSystem => Server.GetExistingSystemManaged(); public static GenerateCastleSystem GenerateCastle { get; private set; } public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; } public static PrefabCollectionSystem PrefabCollection => Server.GetExistingSystemManaged(); public static ServerScriptMapper ServerScriptMapper { get; internal set; } public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; } public static ManualLogSource Log => Plugin.PluginLog; private static World GetWorld(string name) { Enumerator enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == name) { return current; } } return null; } public static void LogException(Exception e, [CallerMemberName] string caller = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(52, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(caller); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.StackTrace); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.StackTrace); } log.LogError(val); } internal static void InitializeAfterLoaded() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (!_hasInitialized) { PrefabCollectionSystem = Server.GetExistingSystemManaged(); ServerScriptMapper = Server.GetExistingSystemManaged(); GenerateCastle = Server.GetOrCreateSystemManaged(); ServerGameSettingsSystem = Server.GetExistingSystemManaged(); PlayerDataService.Initialize(); DailyKitService.Initialize(); GiveService.Initialize(); StarterKitService.Initialize(); TeleportPointsService.Initialize(); AuraService.Initialize(); _hasInitialized = true; ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("InitializeAfterLoaded"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" completed."); } log.LogInfo(val); } } public static Coroutine StartCoroutine(IEnumerator routine) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)monoBehaviour == (Object)null) { GameObject val = new GameObject("PlayerServices"); monoBehaviour = (MonoBehaviour)(object)val.AddComponent(); Object.DontDestroyOnLoad((Object)(object)val); } return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } public static void StopCoroutines() { if ((Object)(object)monoBehaviour != (Object)null) { monoBehaviour.StopAllCoroutines(); Object.Destroy((Object)(object)((Component)monoBehaviour).gameObject); monoBehaviour = null; } } } public static class ECSExtensions { public delegate void ActionRef(ref T item); public unsafe static void Write(this Entity entity, T componentData) where T : struct { //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_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf(); fixed (byte* ptr = array) { EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } public static void With(this Entity entity, ActionRef action) where T : struct { //IL_0001: 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_0016: 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) T item = entity.ReadRW(); action(ref item); EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData(entity, item); } public unsafe static T ReadRW(this Entity entity) where T : struct { //IL_000e: 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_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_0018: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, val.TypeIndex); return Marshal.PtrToStructure(new IntPtr(componentDataRawRW)); } public static byte[] StructureToByteArray(T structure) where T : struct { int num = Marshal.SizeOf(structure); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } public unsafe static T Read(this Entity entity) where T : struct { //IL_000e: 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_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_0018: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; void* componentDataRawRO = ((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex); return Marshal.PtrToStructure(new IntPtr(componentDataRawRO)); } public static DynamicBuffer ReadBuffer(this Entity entity) where T : struct { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.Server.EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer(entity, false); } public static bool Has(this Entity entity) { //IL_000e: 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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, val); } public static string LookupName(this PrefabGUID prefabGuid) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged(); NativeParallelHashMap guidToEntityMap = existingSystemManaged._PrefabLookupMap.GuidToEntityMap; object result; if (!guidToEntityMap.ContainsKey(prefabGuid)) { result = "GUID Not Found"; } else { PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap; result = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(prefabGuid) + " PrefabGuid(" + ((PrefabGUID)(ref prefabGuid)).GuidHash + ")"; } return (string)result; } public static string PrefabName(this PrefabGUID prefabGuid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return prefabGuid.LookupName(); } public unsafe static string EntityName(this Entity entity) { //IL_0007: 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_0017: 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_0040: 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) string text = string.Empty; if (entity.Has()) { NameableInteractable val = entity.Read(); text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); } if (string.IsNullOrEmpty(text) && entity.Has()) { text = entity.Read().PrefabName(); } if (string.IsNullOrEmpty(text)) { text = ((object)(*(Entity*)(&entity))/*cast due to .constrained prefix*/).ToString(); } return text; } public static void Add(this Entity entity) { //IL_000e: 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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).AddComponent(entity, val); } public static void Remove(this Entity entity) { //IL_000e: 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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent(entity, val); } } internal static class Helper { public static NativeArray GetEntitiesByComponentType(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false) { //IL_0002: 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_0010: 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_0019: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_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_004f: 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_0067: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_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_008c: 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_008e: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) EntityQueryOptions val = (EntityQueryOptions)0; if (includeAll) { val = (EntityQueryOptions)(val | 0xC3); } if (includeDisabled) { val = (EntityQueryOptions)(val | 2); } if (includeSpawn) { val = (EntityQueryOptions)(val | 0x40); } if (includePrefab) { val = (EntityQueryOptions)(val | 1); } if (includeDestroyed) { val = (EntityQueryOptions)(val | 0x80); } EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions(val); EntityManager entityManager = Core.EntityManager; EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); } public static bool TryGetInventoryEntity(Entity characterEntity, out Entity inventoryEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, characterEntity, ref inventoryEntity, 0); } public static int GetItemCountInInventory(Entity characterEntity, PrefabGUID itemPrefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0099: 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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (!TryGetInventoryEntity(characterEntity, out var inventoryEntity)) { return 0; } if (((EntityManager)(ref entityManager)).HasComponent(inventoryEntity)) { DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(inventoryEntity, false); int num = 0; for (int i = 0; i < buffer.Length; i++) { InventoryBuffer val = buffer[i]; if (((PrefabGUID)(ref val.ItemType)).GuidHash == ((PrefabGUID)(ref itemPrefab)).GuidHash) { num += val.Amount; } } return num; } int num2 = 0; InventoryBuffer val2 = default(InventoryBuffer); for (int j = 0; j < 36; j++) { if (InventoryUtilities.TryGetItemAtSlot(entityManager, characterEntity, j, ref val2) && ((PrefabGUID)(ref val2.ItemType)).GuidHash == ((PrefabGUID)(ref itemPrefab)).GuidHash) { num2 += val2.Amount; } } return num2; } public static Entity AddItemToInventory(Entity recipient, PrefabGUID guid, int amount) { //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_000b: 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_0013: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) try { ServerGameManager serverGameManager = Core.ServerGameManager; AddItemResponse val = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(recipient, guid, amount); return val.NewEntity; } catch (Exception e) { Core.LogException(e, "AddItemToInventory"); } return Entity.Null; } public static bool TryRemoveItemsFromInventory(Entity characterEntity, PrefabGUID itemPrefab, int amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0022: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (!TryGetInventoryEntity(characterEntity, out var inventoryEntity)) { return false; } if (!((EntityManager)(ref entityManager)).HasComponent(inventoryEntity)) { return false; } DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(inventoryEntity, false); int num = amount; int num2 = buffer.Length - 1; while (num2 >= 0 && num > 0) { InventoryBuffer val = buffer[num2]; if (((PrefabGUID)(ref val.ItemType)).GuidHash == ((PrefabGUID)(ref itemPrefab)).GuidHash && val.Amount > 0) { int num3 = math.min(val.Amount, num); val.Amount -= num3; num -= num3; if (val.Amount <= 0) { val.ItemType = new PrefabGUID(0); val.Amount = 0; } buffer[num2] = val; } num2--; } return num == 0; } public static bool IsInCombat(Entity characterEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) EntityManager entityManager = Core.EntityManager; if (characterEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(characterEntity)) { return false; } foreach (PrefabGUID combatBuff in PrefabData.CombatBuffs) { if (BuffUtility.HasBuff(entityManager, characterEntity, PrefabIdentifier.op_Implicit(combatBuff))) { return true; } } return false; } public static bool IsRaidTime() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_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_0050: Invalid comparison between Unknown and I4 //IL_0060: 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_0067: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 EntityQuery val = default(EntityQuery); try { EntityManager entityManager = Core.EntityManager; val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (!((EntityQuery)(ref val)).HasSingleton()) { return false; } ServerGameBalanceSettings singleton = ((EntityQuery)(ref val)).GetSingleton(); if ((int)singleton.CastleDamageMode == 1) { return true; } if ((int)singleton.CastleDamageMode == 0) { return false; } if ((int)singleton.CastleDamageMode == 2) { ServerGameSettings settings = Core.ServerGameSettingsSystem.Settings; if (settings == null) { return false; } PlayerInteractionSettings playerInteractionSettings = settings.PlayerInteractionSettings; DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek; StartEndTimeData val2 = ((dayOfWeek == DayOfWeek.Saturday || dayOfWeek == DayOfWeek.Sunday) ? playerInteractionSettings.VSCastleWeekendTime : playerInteractionSettings.VSCastleWeekdayTime); if (val2.StartHour == 0 && val2.StartMinute == 0 && val2.EndHour == 0 && val2.EndMinute == 0) { return false; } TimeSpan timeSpan = new TimeSpan(val2.StartHour, val2.StartMinute, 0); TimeSpan timeSpan2 = new TimeSpan(val2.EndHour, val2.EndMinute, 0); TimeSpan timeOfDay = DateTime.Now.TimeOfDay; if (timeSpan <= timeSpan2) { return timeOfDay >= timeSpan && timeOfDay <= timeSpan2; } return timeOfDay >= timeSpan || timeOfDay <= timeSpan2; } return false; } catch (Exception e) { Core.LogException(e, "IsRaidTime"); return false; } finally { if (val != default(EntityQuery)) { ((EntityQuery)(ref val)).Dispose(); } } } public static string TrimName(string name, int maxLength = 20) { if (string.IsNullOrEmpty(name)) { return name; } return (name.Length > maxLength) ? (name.Substring(0, maxLength) + "…") : name; } public unsafe static bool TryFindUserByExactName(string playerName, out Entity userEntity, out User user) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00bb: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; user = default(User); if (string.IsNullOrWhiteSpace(playerName)) { return false; } EntityManager entityManager = Core.EntityManager; NativeArray val = default(NativeArray); try { val = GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(current) && ((EntityManager)(ref entityManager)).HasComponent(current)) { User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); string a = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.Equals(a, playerName, StringComparison.OrdinalIgnoreCase)) { userEntity = current; user = componentData; return true; } } } } finally { if (val.IsCreated) { val.Dispose(); } } return false; } public unsafe static bool TryFindUserByName(string query, out Entity userEntity, out User user, out List candidates) { //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) //IL_001a: 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_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_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_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_005a: 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_006c: 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_012a: 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_013c: 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_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_017c: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_00b0: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; user = default(User); candidates = null; List<(Entity, User, string)> list = new List<(Entity, User, string)>(); NativeArray val = default(NativeArray); try { val = GetEntitiesByComponentType(); for (int i = 0; i < val.Length; i++) { Entity val2 = val[i]; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val2)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(val2)) { User item = val2.Read(); string text = ((object)(*(FixedString64Bytes*)(&item.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text)) { list.Add((val2, item, text)); } } } } finally { if (val.IsCreated) { val.Dispose(); } } List<(Entity, User, string)> list2 = list.Where<(Entity, User, string)>(((Entity ent, User usr, string name) x) => string.Equals(x.name, query, StringComparison.OrdinalIgnoreCase)).ToList(); if (list2.Count == 1) { userEntity = list2[0].Item1; user = list2[0].Item2; return true; } List<(Entity, User, string)> list3 = list.Where<(Entity, User, string)>(((Entity ent, User usr, string name) x) => x.name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); if (list3.Count == 1) { userEntity = list3[0].Item1; user = list3[0].Item2; return true; } if (list3.Count > 1) { candidates = list3.Select<(Entity, User, string), string>(((Entity ent, User usr, string name) x) => x.name).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string n) => n, StringComparer.OrdinalIgnoreCase) .ToList(); } return false; } public static bool TryFindUsersByRadius(Entity centerCharacter, float radius, out List<(Entity UserEntity, Entity CharacterEntity, User User, float Distance)> players, ulong excludeSteamId = 0uL, bool includeAdmins = false) { //IL_0008: 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_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0060: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) players = new List<(Entity, Entity, User, float)>(); EntityManager entityManager = Core.EntityManager; if (radius <= 0f) { return false; } if (centerCharacter == Entity.Null || !((EntityManager)(ref entityManager)).Exists(centerCharacter) || !((EntityManager)(ref entityManager)).HasComponent(centerCharacter)) { return false; } LocalToWorld componentData = ((EntityManager)(ref entityManager)).GetComponentData(centerCharacter); float3 position = ((LocalToWorld)(ref componentData)).Position; NativeArray val = default(NativeArray); try { val = GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!((EntityManager)(ref entityManager)).Exists(current) || !((EntityManager)(ref entityManager)).HasComponent(current)) { continue; } User val2 = current.Read(); if (!val2.IsConnected || (excludeSteamId != 0L && val2.PlatformId == excludeSteamId) || (!includeAdmins && val2.IsAdmin)) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val2.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(entityOnServer) && ((EntityManager)(ref entityManager)).HasComponent(entityOnServer)) { componentData = ((EntityManager)(ref entityManager)).GetComponentData(entityOnServer); float3 position2 = ((LocalToWorld)(ref componentData)).Position; float num = math.distance(position2, position); if (!(num > radius)) { players.Add((current, entityOnServer, val2, num)); } } } } finally { if (val.IsCreated) { val.Dispose(); } } return players.Count > 0; } public static void NotifyUser(Entity userEntity, string message) { //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_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_0019: 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) try { EntityManager entityManager = Core.EntityManager; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); FixedString512Bytes val = default(FixedString512Bytes); ((FixedString512Bytes)(ref val))..ctor(message); ServerChatUtils.SendSystemMessageToClient(entityManager, componentData, ref val); } catch (Exception e) { Core.LogException(e, "NotifyUser"); } } public static string Csv(string s) { if (string.IsNullOrEmpty(s)) { return "\"\""; } return "\"" + s.Replace("\"", "\"\"") + "\""; } } [BepInPlugin("PlayerServices", "PlayerServices", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { internal static Harmony Harmony; internal static ManualLogSource PluginLog; internal static ConfigFile PluginConfig; internal static ConfigEntry pisCommandEnabled; internal static ConfigEntry playerInfoShowClanCastleInfo; internal static ConfigEntry playerInfoShowClanMemberLastOnline; internal static ConfigEntry dailyKitEnabled; internal static ConfigEntry dailyKitItems; internal static ConfigEntry starterKitEnabled; internal static ConfigEntry starterKitItems; internal static ConfigEntry changeNameFeatureEnabled; internal static ConfigEntry adminChangeNameBroadcastAndWebhookEnabled; internal static ConfigEntry playerChangeNameBroadcastEnabled; internal static ConfigEntry playerChangeNameWebhookEnabled; internal static ConfigEntry changeNameCurrencyName; internal static ConfigEntry changeNameCurrencyPrefab; internal static ConfigEntry changeNameCurrencyCost; internal static ConfigEntry changeNameBroadcastMessage; internal static ConfigEntry changeNameWebhookMessage; internal static ConfigEntry changeNameWebhookUrl; internal static ConfigEntry onlyWhitelistEnable; internal static ConfigEntry welcomeMessageEnabled; internal static ConfigEntry welcomeMessageText1; internal static ConfigEntry welcomeMessageText2; internal static ConfigEntry auraFeatureEnabled; internal static ConfigEntry auraBroadcastMessage; internal static ConfigEntry auraCurrencyName; internal static ConfigEntry auraCurrencyPrefabGuid; internal static ConfigEntry auraPrefabGuids; internal static ConfigEntry auraCosts; internal static ConfigEntry playerTeleportEnabled; internal static ConfigEntry playerTeleportDelaySeconds; public override void Load() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Expected O, but got Unknown //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Expected O, but got Unknown if (!(Application.productName != "VRisingServer")) { PluginLog = ((BasePlugin)this).Log; PluginConfig = ((BasePlugin)this).Config; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("PlayerServices"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); pisCommandEnabled = ((BasePlugin)this).Config.Bind("PlayerInformations", "pisCommandEnabled", true, "Enable the player information command."); playerInfoShowClanCastleInfo = ((BasePlugin)this).Config.Bind("PlayerInformations", "ShowClanCastleInfo", false, "Show clan castle information in .pis command. Admins can always see this information."); playerInfoShowClanMemberLastOnline = ((BasePlugin)this).Config.Bind("PlayerInformations", "ShowClanMemberLastOnline", false, "Show last online time for offline clan members in .pis command. Admins can always see this information."); dailyKitEnabled = ((BasePlugin)this).Config.Bind("DailyKit", "DailyKitEnabled", true, "Enable players to claim Daily Kits."); dailyKitItems = ((BasePlugin)this).Config.Bind("DailyKit", "dailyKitItemsAndQuantity", "429052660:10,800879747:10", "List of daily kit items in the format PrefabGuid:Quantity, separated by commas."); starterKitEnabled = ((BasePlugin)this).Config.Bind("StarterKit", "StarterKitEnabled", true, "Enable automatically granting a one-time Starter Kit to new players upon character creation."); starterKitItems = ((BasePlugin)this).Config.Bind("StarterKit", "StarterKitItemsAndQuantity", "1821405450:208,-1222725729:64,-219760992:1,-1593377811:300,-1531666018:300,862477668:100", "List of starter kit items in the format PrefabGuid:Quantity separated by commas."); changeNameFeatureEnabled = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameFeatureEnabled", true, "Enable the character name change feature."); adminChangeNameBroadcastAndWebhookEnabled = ((BasePlugin)this).Config.Bind("ChangeName", "AdminChangeNameIngameBroadcastAndWebhookEnabled", false, "Enable in-game broadcasts and Discord webhook notifications when an admin changes a player's name."); playerChangeNameBroadcastEnabled = ((BasePlugin)this).Config.Bind("ChangeName", "PlayerChangeNameIngameBroadcastEnabled", true, "Enable in-game broadcast messages when players change their names."); playerChangeNameWebhookEnabled = ((BasePlugin)this).Config.Bind("ChangeName", "PlayerChangeNameWebhookEnabled", false, "Enable Discord webhook messages when players change their names."); changeNameCurrencyName = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameCurrencyName", "Primal Stygian Shards", "Currency name required to change a character name."); changeNameCurrencyPrefab = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameCurrencyPrefabGuid", 28358550, "Currency prefab Guid required to change a character name."); changeNameCurrencyCost = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameCurrencyCost", 1000, "Currency cost required to change a character name."); changeNameBroadcastMessage = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameIngameBroadcastMessage", "#oldname# has changed their name to #newname#. For more info, type .changename help", "Format of the in-game broadcast message."); changeNameWebhookMessage = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameWebhookMessage", "**[Change Name]** - **#oldname#** has changed their name to **#newname#**", "Format of the Discord webhook message."); changeNameWebhookUrl = ((BasePlugin)this).Config.Bind("ChangeName", "ChangeNameWebhookUrl", "", "Webhook URL. Example: https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxx"); onlyWhitelistEnable = ((BasePlugin)this).Config.Bind("Whitelist", "OnlyWhitelistEnable", false, "Set the server to private and only allow players marked as whitelisted to join."); welcomeMessageEnabled = ((BasePlugin)this).Config.Bind("WelcomeMessage", "WelcomeMessageEnabled", true, "Enable the welcome message sent to players after they connect."); welcomeMessageText1 = ((BasePlugin)this).Config.Bind("WelcomeMessage", "WelcomeMessageText1", "Welcome to the server, #player#!", "Text for the first welcome message."); welcomeMessageText2 = ((BasePlugin)this).Config.Bind("WelcomeMessage", "WelcomeMessageText2", "", "Text for the second welcome message. Leave blank to disable it."); auraFeatureEnabled = ((BasePlugin)this).Config.Bind("Aura", "AuraFeatureEnabled", true, "Enable the aura feature."); auraBroadcastMessage = ((BasePlugin)this).Config.Bind("Aura", "AuraBroadcastMessage", "#player# bought aura #aura#. For more info, type .aura help", "Format of the in-game broadcast message."); auraCurrencyName = ((BasePlugin)this).Config.Bind("Aura", "AuraCurrencyName", "Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards,Primal Stygian Shards", "Currency names for each aura, separated by comma."); auraCurrencyPrefabGuid = ((BasePlugin)this).Config.Bind("Aura", "AuraCurrencyPrefabGuid", "28358550,28358550,28358550,28358550,28358550,28358550,28358550,28358550,28358550,28358550,28358550", "Currency prefab GUIDs for each aura, separated by comma."); auraCosts = ((BasePlugin)this).Config.Bind("Aura", "AuraCosts", "100,200,300,400,500,600,700,800,900,0,0", "Comma-separated aura costs. The order must match AuraPrefabGuids. Cost must be greater than 0 to allow purchase; use 0 to make that aura admin-only/not for sale. Example: 100,0,300"); auraPrefabGuids = ((BasePlugin)this).Config.Bind("Aura", "AuraPrefabGuids", "-1242403012,-1887712500,-1083643277,1343911070,784366378,1237097606,647429443,-646349605,-1124645803,-1640482518,1163490655", "Comma-separated aura prefab GUIDs. The order must match AuraCosts, AuraCurrencyName, and AuraCurrencyPrefabGuid."); playerTeleportEnabled = ((BasePlugin)this).Config.Bind("Teleport", "PlayerTeleportEnabled", false, "Enable players to use .pls tp where AdminOnly is false. Admins can still teleport."); playerTeleportDelaySeconds = ((BasePlugin)this).Config.Bind("Teleport", "PlayerTeleportDelaySeconds", 10, new ConfigDescription("Delay in seconds before player teleport. Set to 0 for instant teleport.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 20), Array.Empty())); Harmony = new Harmony("PlayerServices"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); CommandRegistry.RegisterAll(); } } public override bool Unload() { PlayerDataService.ForceSaveIfDirty(); Core.StopCoroutines(); CommandRegistry.UnregisterAssembly(); Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PlayerServices"; public const string PLUGIN_NAME = "PlayerServices"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace PlayerServices.Services { internal static class AccessControlService { public static void CheckUserLogin(Entity userEntity, User user) { //IL_0001: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00d9: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_00ec: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0171: 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_018c: Unknown result type (might be due to invalid IL or missing references) if (user.PlatformId == 0) { return; } PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(user.PlatformId); bool flag = default(bool); if (BanService.IsBannedPlayer(playerCache)) { KickPlayer(userEntity); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Banlist] Banned player was kicked: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } else if (Plugin.onlyWhitelistEnable.Value) { BepInExInfoLogInterpolatedStringHandler val; if (!WhitelistService.IsWhitelistedPlayer(playerCache)) { KickPlayer(userEntity); ManualLogSource log2 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Whitelist] Non-whitelisted player was kicked: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log2.LogInfo(val); return; } string text = (string.IsNullOrWhiteSpace(playerCache.KnownAs) ? "Unknown" : playerCache.KnownAs); ManualLogSource log3 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Whitelist] Whitelisted player connected: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") | Known As: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log3.LogInfo(val); } else { string text2 = ((playerCache == null || string.IsNullOrWhiteSpace(playerCache.KnownAs)) ? "" : (" | Known As: " + playerCache.KnownAs)); ManualLogSource log4 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Connected] Player connected: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); } log4.LogInfo(val); } } public static void KickPlayer(Entity userEntity) { //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_0013: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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_006e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009f: 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_00c4: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.Server.EntityManager; User val = userEntity.Read(); if (val.IsConnected && val.PlatformId != 0) { Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3] { ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.ReadOnly() }); entity.Write(new KickEvent { PlatformId = val.PlatformId }); entity.Write(new SendEventToUser { UserIndex = val.Index }); entity.Write(new NetworkEventType { EventId = NetworkEvents.EventId_KickEvent, IsAdminEvent = false, IsDebugEvent = false }); } } public static void KickIfOnline(ulong steamId) { //IL_0003: 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) //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_0022: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0039: 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) NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User val2 = current.Read(); if (val2.PlatformId == steamId && val2.IsConnected) { KickPlayer(current); break; } } } finally { if (val.IsCreated) { val.Dispose(); } } } } internal static class AdminService { private static readonly Dictionary _trackers = new Dictionary(); private static bool _trackingMonitorRunning = false; private const float TRACKING_INTERVAL = 0.04f; private const float REBUFF_DELAY_SECONDS = 0.2f; private unsafe static IEnumerator TrackPlayerRoutine(ChatCommandContext ctx, ulong adminSteamId, Entity adminUserEntity, Entity adminChar, Entity targetUserEntity, Entity targetChar, User targetUser, float delay) { //IL_0015: 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_001c: 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_0023: 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_002b: 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_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) if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } try { EntityManager em = Core.EntityManager; string targetName = ((object)(*(FixedString64Bytes*)(&targetUser.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!TryReadConnectedUser(em, adminUserEntity, out var user)) { yield break; } if (!TryReadConnectedUser(em, targetUserEntity, out user)) { Helper.NotifyUser(adminUserEntity, "Tracking stopped: " + targetName + " is offline."); } else if (adminChar == Entity.Null || !((EntityManager)(ref em)).Exists(adminChar) || !((EntityManager)(ref em)).HasComponent(adminChar) || targetChar == Entity.Null || !((EntityManager)(ref em)).Exists(targetChar) || !((EntityManager)(ref em)).HasComponent(targetChar) || !BuffUtility.HasBuff(em, adminChar, PrefabIdentifier.op_Implicit(PrefabData.Observe))) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Admin] Failed to start tracking "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(targetName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" after delay."); } log.LogWarning(val); } else { _trackers[adminSteamId] = (adminUserEntity, adminChar, targetUserEntity, targetChar, targetName); EnsureTrackingMonitorRunning(); float3 targetPos = targetChar.Read().Value; adminChar.Write(new Translation { Value = targetPos }); ctx.Reply("Now tracking: " + targetName + ""); ctx.Reply("Usage: .pls track to track others or .pls untrack to stop."); ctx.Reply("Usage: .pls observe to toggle Observe mode and untrack."); em = default(EntityManager); } } catch (Exception e) { Core.LogException(e, "TrackPlayerRoutine"); } } private static void EnsureTrackingMonitorRunning() { if (!_trackingMonitorRunning) { _trackingMonitorRunning = true; Core.StartCoroutine(MonitorTrackingCoroutine()); } } private static IEnumerator MonitorTrackingCoroutine() { try { while (_trackers.Count > 0) { try { MonitorTrackingTick(); } catch (Exception e) { Core.LogException(e, "MonitorTrackingCoroutine"); _trackers.Clear(); } yield return (object)new WaitForSeconds(0.04f); } } finally { _trackingMonitorRunning = false; } } private static void MonitorTrackingTick() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_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_0055: 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_005f: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c9: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0124: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; List list = new List(); foreach (KeyValuePair tracker in _trackers) { ulong key = tracker.Key; var (userEntity, val, userEntity2, val2, text) = tracker.Value; if (!TryReadConnectedUser(entityManager, userEntity, out var user)) { list.Add(key); } else if (!TryReadConnectedUser(entityManager, userEntity2, out user)) { Helper.NotifyUser(userEntity, "Tracking stopped: " + text + " is offline."); list.Add(key); } else if (val == Entity.Null || val2 == Entity.Null || !((EntityManager)(ref entityManager)).Exists(val) || !((EntityManager)(ref entityManager)).Exists(val2) || !BuffUtility.HasBuff(entityManager, val, PrefabIdentifier.op_Implicit(PrefabData.Observe))) { list.Add(key); } else if (!((EntityManager)(ref entityManager)).HasComponent(val) || !((EntityManager)(ref entityManager)).HasComponent(val2)) { list.Add(key); } else { float3 value = val2.Read().Value; val.Write(new Translation { Value = value }); } } foreach (ulong item in list) { _trackers.Remove(item); } } private static bool TryReadConnectedUser(EntityManager em, Entity userEntity, out User user) { //IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003f: Unknown result type (might be due to invalid IL or missing references) user = default(User); if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity) || !((EntityManager)(ref em)).HasComponent(userEntity)) { return false; } user = ((EntityManager)(ref em)).GetComponentData(userEntity); return user.IsConnected; } public static void ToggleObserve(ChatCommandContext ctx) { //IL_0007: 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_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_001f: 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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0120: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; EntityManager entityManager = Core.EntityManager; ulong platformId = senderUserEntity.Read().PlatformId; bool flag = default(bool); if (BuffUtility.HasBuff(entityManager, senderCharacterEntity, PrefabIdentifier.op_Implicit(PrefabData.Observe))) { Buffs.RemoveBuff(senderCharacterEntity, PrefabData.Observe); _trackers.Remove(platformId); ctx.Reply("Observe mode: Off. Usage: .pls observe to toggle."); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Admin] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ctx.Event.SenderUserEntity.Read().CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" disabled observe mode."); } log.LogInfo(val); } else { Buffs.AddBuff(senderUserEntity, senderCharacterEntity, PrefabData.Observe, -1); ctx.Reply("Observe mode: On. Usage: .pls observe to toggle."); ctx.Reply("Usage: .pls track to track a player."); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Admin] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ctx.Event.SenderUserEntity.Read().CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" enabled observe mode."); } log2.LogInfo(val); } } public static void TrackPlayer(ChatCommandContext ctx, string targetName) { //IL_001c: 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_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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0050: 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_0072: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if (!TryFindPlayerName(ctx, targetName, out var targetUserEntity, out var targetCharEntity, out var targetUser)) { return; } EntityManager entityManager = Core.EntityManager; Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); ulong platformId = val.PlatformId; if (platformId == targetUser.PlatformId) { ctx.Reply("You cannot track yourself."); return; } if (senderCharacterEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(senderCharacterEntity) || !((EntityManager)(ref entityManager)).HasComponent(senderCharacterEntity)) { ctx.Reply("Could not read your character position."); return; } if (targetCharEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(targetCharEntity) || !((EntityManager)(ref entityManager)).HasComponent(targetCharEntity)) { ctx.Reply("Could not read target position."); return; } bool flag = false; if (!BuffUtility.HasBuff(entityManager, senderCharacterEntity, PrefabIdentifier.op_Implicit(PrefabData.Observe))) { if (!Buffs.AddBuff(senderUserEntity, senderCharacterEntity, PrefabData.Observe, -1)) { ctx.Reply("Failed to enter observe mode."); return; } flag = true; } Core.StartCoroutine(TrackPlayerRoutine(ctx, platformId, senderUserEntity, senderCharacterEntity, targetUserEntity, targetCharEntity, targetUser, flag ? 0.2f : 0f)); } public static void UntrackPlayer(ChatCommandContext ctx) { //IL_0007: 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) ulong platformId = ctx.Event.SenderUserEntity.Read().PlatformId; if (_trackers.ContainsKey(platformId)) { _trackers.Remove(platformId); ctx.Reply("Tracking stopped. Usage: .pls track to track."); ctx.Reply("Usage: .pls observe to toggle Observe mode and untrack."); } else { ctx.Reply("You are not currently tracking anyone."); } } public unsafe static void ApplyPotionBuffs(ChatCommandContext ctx, string targetName) { //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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) Entity targetUserEntity; Entity targetCharEntity; User targetUser; if (string.IsNullOrWhiteSpace(targetName)) { targetUserEntity = ctx.Event.SenderUserEntity; targetCharEntity = ctx.Event.SenderCharacterEntity; targetUser = targetUserEntity.Read(); } else if (!TryFindPlayerName(ctx, targetName, out targetUserEntity, out targetCharEntity, out targetUser)) { return; } string text = ((object)(*(FixedString64Bytes*)(&targetUser.CharacterName))/*cast due to .constrained prefix*/).ToString(); ctx.Reply("Applied Potion Buffs to " + text + "."); Helper.NotifyUser(targetUserEntity, "You have received Potion Buffs."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Admin] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ctx.Event.SenderUserEntity.Read().CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" applied Potion Buffs to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); Core.StartCoroutine(ApplyBuffsRoutine(targetUserEntity, targetCharEntity)); } private static IEnumerator ApplyBuffsRoutine(Entity targetUserEntity, Entity targetCharEntity) { //IL_0007: 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_000e: 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) bool hasRemovedAny; try { hasRemovedAny = RemoveExistingPotionBuffs(targetCharEntity); } catch (Exception ex) { Exception e = ex; Core.LogException(e, "ApplyBuffsRoutine"); yield break; } if (hasRemovedAny) { yield return (object)new WaitForSeconds(0.2f); } try { ApplyPotionBuffsAfterDelay(targetUserEntity, targetCharEntity); } catch (Exception e2) { Core.LogException(e2, "ApplyBuffsRoutine"); } } private static bool RemoveExistingPotionBuffs(Entity targetCharEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0047: 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_005a: 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) EntityManager entityManager = Core.EntityManager; if (targetCharEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(targetCharEntity)) { return false; } bool result = false; foreach (PrefabGUID item in PrefabData.PotionBuff) { if (BuffUtility.HasBuff(entityManager, targetCharEntity, PrefabIdentifier.op_Implicit(item))) { Buffs.RemoveBuff(targetCharEntity, item); result = true; } } return result; } private static void ApplyPotionBuffsAfterDelay(Entity targetUserEntity, Entity targetCharEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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_0015: 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_002d: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (targetCharEntity == Entity.Null || targetUserEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(targetCharEntity) || !((EntityManager)(ref entityManager)).Exists(targetUserEntity)) { return; } foreach (PrefabGUID item in PrefabData.PotionBuff) { Buffs.AddBuff(targetUserEntity, targetCharEntity, item); } } private static bool TryFindPlayerName(ChatCommandContext ctx, string targetName, out Entity targetUserEntity, out Entity targetCharEntity, out User targetUser) { //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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) targetUserEntity = Entity.Null; targetCharEntity = Entity.Null; targetUser = default(User); if (string.IsNullOrWhiteSpace(targetName) || targetName.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return false; } string text = targetName.Trim(); if (!Helper.TryFindUserByName(text, out targetUserEntity, out targetUser, out var candidates)) { if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many players found for " + text + ". Please enter a more specific name."); } else { ctx.Reply("Multiple players matched " + text + ": " + string.Join(", ", candidates)); } return false; } ctx.Reply("No player found matching " + text + ""); return false; } if (!targetUser.IsConnected) { ctx.Reply($"{targetUser.CharacterName} is offline."); return false; } targetCharEntity = ((NetworkedEntity)(ref targetUser.LocalCharacter)).GetEntityOnServer(); if (!(targetCharEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(targetCharEntity)) { return true; } } ctx.Reply("Target character not found."); return false; } public static void ReloadAll(ChatCommandContext ctx) { //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown try { ConfigFile pluginConfig = Plugin.PluginConfig; if (pluginConfig != null) { pluginConfig.Reload(); } int num = DailyKitService.ReloadConfig(); int num2 = StarterKitService.ReloadConfig(); int num3 = AuraService.ReloadConfig(); int pointCount; bool flag = TeleportPointsService.ReloadConfig(out pointCount); int setCount; bool flag2 = GiveService.ReloadConfig(out setCount); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("PlayerServices configs reloaded."); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(39, 1, stringBuilder2); handler.AppendLiteral("DailyKit: "); handler.AppendFormatted(num); handler.AppendLiteral(" item(s)"); stringBuilder3.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(41, 1, stringBuilder2); handler.AppendLiteral("StarterKit: "); handler.AppendFormatted(num2); handler.AppendLiteral(" item(s)"); stringBuilder4.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(44, 1, stringBuilder2); handler.AppendLiteral("Aura: reloaded "); handler.AppendFormatted(num3); handler.AppendLiteral(" aura(s)"); stringBuilder5.AppendLine(ref handler); stringBuilder.AppendLine($"Teleport: {pointCount} point(s)" + (flag ? "" : " (failed)")); stringBuilder.AppendLine($"Give: {setCount} set(s)" + (flag2 ? "" : " (failed)")); ctx.Reply(stringBuilder.ToString().TrimEnd()); ManualLogSource log = Core.Log; bool flag3 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(99, 7, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Admin] Reloaded all configs. DailyKit="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", StarterKit="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Aura="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Teleport="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pointCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", TeleportOk="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(flag); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Give="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(setCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", GiveOk="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(flag2); } log.LogInfo(val); } catch (Exception e) { Core.LogException(e, "ReloadAll"); ctx.Reply("Failed to reload PlayerServices configs. Check the server log."); } } } internal static class AuraService { private static readonly string LOG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string LOG_FILE = Path.Combine(LOG_DIR, "aura_log.csv"); private static readonly object LOG_LOCK = new object(); private const int AURA_COOLDOWN_SECONDS = 5; private const int AURA_PREVIEW_SECONDS = 10; private const int AURAS_PER_LIST_REPLY = 6; private const float AFTER_CONNECT_DELAY = 2f; private static readonly Dictionary<(ulong SteamId, int AuraGuid), DateTime> _auraPreviewUntil = new Dictionary<(ulong, int), DateTime>(); private static readonly Dictionary _auraToggleCooldowns = new Dictionary(); private static readonly List _auraCurrencyNames = new List(); private static readonly List _auraCurrencyPrefabGuids = new List(); private static readonly List _auraPrefabGuids = new List(); private static readonly List _auraCosts = new List(); private static bool _initialized; public static void Initialize() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (_initialized) { return; } LoadConfig(); _initialized = true; if (!Plugin.auraFeatureEnabled.Value) { DeactivateAllPlayerAuras(); Core.Log.LogInfo((object)"[Aura] Aura system is disabled. Active aura states will be disabled and aura buffs will be removed on player connect."); return; } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Initialized and loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" aura(s)."); } log.LogInfo(val); } public static void RefreshOnConnect(Entity userEntity, User user) { //IL_0007: 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_0048: 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_0034: 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) EnsureInitialized(); if (user.IsConnected && user.PlatformId != 0) { if (!Plugin.auraFeatureEnabled.Value) { Core.StartCoroutine(RemoveAuraBuffsOnConnectRoutine(userEntity, user.PlatformId)); } else { Core.StartCoroutine(RefreshOnConnectRoutine(userEntity, user.PlatformId)); } } } private static IEnumerator RefreshOnConnectRoutine(Entity userEntity, ulong steamId) { //IL_0007: 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) yield return (object)new WaitForSeconds(2f); try { EntityManager em = Core.EntityManager; if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity) || !((EntityManager)(ref em)).HasComponent(userEntity)) { yield break; } User user = ((EntityManager)(ref em)).GetComponentData(userEntity); if (!user.IsConnected || user.PlatformId != steamId) { yield break; } Entity character = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (character == Entity.Null || !((EntityManager)(ref em)).Exists(character)) { yield break; } PlayerCacheData cache = PlayerDataService.GetPlayerCache(user.PlatformId); if (cache == null || cache.Auras == null || cache.Auras.Count == 0) { yield break; } HashSet configuredAuraGuids = new HashSet(_auraPrefabGuids); int orphanInactiveCount = 0; int orphanRemovedBuffCount = 0; foreach (PlayerAuraData aura in cache.Auras) { if (!configuredAuraGuids.Contains(aura.PrefabGuid)) { if (RemoveAuraBuff(character, aura.PrefabGuid)) { orphanRemovedBuffCount++; } if (aura.Active) { aura.Active = false; orphanInactiveCount++; } } } if (orphanInactiveCount > 0) { PlayerDataService.SaveNow(); } if (orphanInactiveCount > 0 || orphanRemovedBuffCount > 0) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(96, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Cleaned up "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(orphanInactiveCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" inactive old aura state(s) and removed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(orphanRemovedBuffCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" old aura buff(s) from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") on connect."); } log.LogInfo(val); } foreach (PlayerAuraData aura2 in cache.Auras) { if (aura2.Active && configuredAuraGuids.Contains(aura2.PrefabGuid)) { ApplyAuraBuff(userEntity, character, aura2.PrefabGuid); } } em = default(EntityManager); user = default(User); } catch (Exception ex) { Exception e = ex; Core.LogException(e, "RefreshOnConnectRoutine"); } } private static IEnumerator RemoveAuraBuffsOnConnectRoutine(Entity userEntity, ulong steamId) { //IL_0007: 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) yield return (object)new WaitForSeconds(2f); try { EntityManager em = Core.EntityManager; if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity) || !((EntityManager)(ref em)).HasComponent(userEntity)) { yield break; } User user = ((EntityManager)(ref em)).GetComponentData(userEntity); if (!user.IsConnected || user.PlatformId != steamId) { yield break; } Entity character = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (character == Entity.Null || !((EntityManager)(ref em)).Exists(character)) { yield break; } HashSet auraGuidsToRemove = new HashSet(_auraPrefabGuids); PlayerCacheData cache = PlayerDataService.GetPlayerCache(user.PlatformId); if (cache?.Auras != null) { foreach (PlayerAuraData aura in cache.Auras) { auraGuidsToRemove.Add(aura.PrefabGuid); } } int removedCount = 0; foreach (int auraGuid in auraGuidsToRemove) { if (RemoveAuraBuff(character, auraGuid)) { removedCount++; } } if (removedCount > 0) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(74, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Aura system is disabled. Removed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(removedCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" aura buff(s) from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") on connect."); } log.LogInfo(val); } em = default(EntityManager); user = default(User); } catch (Exception ex) { Exception e = ex; Core.LogException(e, "RemoveAuraBuffsOnConnectRoutine"); } } public unsafe static void BuyAura(ChatCommandContext ctx, string idToken) { //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_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_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_0314: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); ulong platformId = val.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!Plugin.auraFeatureEnabled.Value) { ctx.Reply("Aura system is currently disabled."); return; } if (platformId == 0) { ctx.Reply("Cannot read your SteamID."); AppendAuraLog("buy", 0uL, text, 0uL, text, 0, 0, 0, 0, "", success: false, "invalid_steam_id"); return; } if (!TryResolveAuraId(ctx, idToken, out var auraId, out var auraGuid)) { AppendAuraLog("buy", platformId, text, platformId, text, 0, 0, 0, 0, "", success: false, "invalid_aura_id"); return; } if (IsAuraPreviewActive(platformId, auraGuid, out var remainingSeconds)) { ctx.Reply($"Please wait {remainingSeconds:0.0}s for the aura preview to end before buying this aura."); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, 0, 0, "", success: false, "preview_active"); return; } if (!TryGetAuraCost(auraId, out var cost, out var purchaseDisabled)) { if (purchaseDisabled) { ctx.Reply("This aura is not available for purchase."); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, 0, 0, "", success: false, "purchase_disabled"); } else { ctx.Reply("This aura does not have a configured cost. Please contact an admin."); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, 0, 0, "", success: false, "cost_not_configured"); } return; } if (!TryGetAuraCurrency(auraId, out var currencyGuid, out var currencyName)) { ctx.Reply("This aura does not have a configured currency. Please contact an admin."); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, cost, 0, "", success: false, "currency_not_configured"); return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(platformId); if (HasAura(orCreatePlayerCache, auraGuid)) { ctx.Reply("You already own this aura."); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, 0, 0, "", success: false, "already_owned"); return; } if (!TrySpendCurrency(senderCharacterEntity, currencyGuid, currencyName, cost, out var spendLogReason, out var spendReplyMessage)) { ctx.Reply(spendReplyMessage); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, cost, currencyGuid, currencyName, success: false, spendLogReason); return; } AddOrSetAura(orCreatePlayerCache, auraGuid, active: true); ApplyAuraBuff(senderUserEntity, senderCharacterEntity, auraGuid); PlayerDataService.SaveNow(); string text2 = Plugin.auraBroadcastMessage.Value.Replace("#player#", text).Replace("#aura#", auraId.ToString()); if (!string.IsNullOrWhiteSpace(text2)) { FixedString512Bytes val2 = default(FixedString512Bytes); ((FixedString512Bytes)(ref val2))..ctor(text2); ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val2); } ctx.Reply($"Purchased aura {auraId} for {cost} {currencyName}."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(36, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Aura] "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(platformId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") bought aura "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(auraId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(auraGuid); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") for "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(cost); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(currencyName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(currencyGuid); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogInfo(val3); AppendAuraLog("buy", platformId, text, platformId, text, auraId, auraGuid, cost, currencyGuid, currencyName, success: true, "successful"); } private static bool TrySpendCurrency(Entity character, int currencyGuid, string currencyName, int amount, out string spendLogReason, out string spendReplyMessage) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) spendLogReason = string.Empty; spendReplyMessage = string.Empty; try { if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { if (currencyGuid == 0) { spendLogReason = "invalid_currency_prefab"; spendReplyMessage = "Invalid aura currency."; return false; } if (amount <= 0) { spendLogReason = "invalid_cost"; spendReplyMessage = "Invalid aura cost."; return false; } PrefabGUID itemPrefab = default(PrefabGUID); ((PrefabGUID)(ref itemPrefab))..ctor(currencyGuid); int itemCountInInventory = Helper.GetItemCountInInventory(character, itemPrefab); if (itemCountInInventory < amount) { spendLogReason = $"not_enough_currency_{itemCountInInventory}/{amount}"; spendReplyMessage = $"Not enough {currencyName} ({itemCountInInventory}/{amount})."; return false; } if (!Helper.TryRemoveItemsFromInventory(character, itemPrefab, amount)) { spendLogReason = "remove_items_failed"; spendReplyMessage = "Failed to remove the required currency."; return false; } return true; } } spendLogReason = "character_not_ready"; spendReplyMessage = "Character not ready."; return false; } catch (Exception ex) { spendLogReason = "exception: " + ex.Message; spendReplyMessage = "Error: An unexpected error occurred while spending currency."; Core.LogException(ex, "TrySpendCurrency"); return false; } } private static bool TryResolveAuraId(ChatCommandContext ctx, string idToken, out int auraId, out int auraGuid) { auraId = 0; auraGuid = 0; if (!int.TryParse(idToken, out auraId) || auraId <= 0) { ReplyHelp(ctx); return false; } int num = auraId - 1; if (num < 0 || num >= _auraPrefabGuids.Count) { ctx.Reply("Invalid aura ID."); return false; } auraGuid = _auraPrefabGuids[num]; return true; } private static bool TryGetAuraCost(int auraId, out int cost, out bool purchaseDisabled) { cost = 0; purchaseDisabled = false; int num = auraId - 1; if (num < 0 || num >= _auraCosts.Count) { return false; } cost = _auraCosts[num]; if (cost <= 0) { purchaseDisabled = true; return false; } return true; } private static bool TryGetAuraCurrency(int auraId, out int currencyGuid, out string currencyName) { currencyGuid = 0; currencyName = string.Empty; int num = auraId - 1; if (num < 0) { return false; } if (num >= _auraCurrencyPrefabGuids.Count) { return false; } if (num >= _auraCurrencyNames.Count) { return false; } currencyGuid = _auraCurrencyPrefabGuids[num]; currencyName = _auraCurrencyNames[num]; return currencyGuid != 0 && !string.IsNullOrWhiteSpace(currencyName); } public static void PreviewAura(ChatCommandContext ctx, string idToken) { //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_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_001f: 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_004b: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); int auraId; int auraGuid; if (!Plugin.auraFeatureEnabled.Value) { ctx.Reply("Aura system is currently disabled."); } else if (val.PlatformId == 0) { ctx.Reply("Cannot read your SteamID."); } else if (TryResolveAuraId(ctx, idToken, out auraId, out auraGuid)) { PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(val.PlatformId); string reason; if (playerCache != null && HasAura(playerCache, auraGuid)) { ctx.Reply($"You already own aura {auraId}.\nUsage: .aura on {auraId} to activate or .aura off {auraId} to deactivate."); } else if (!TryApplyPreviewAuraBuff(senderUserEntity, senderCharacterEntity, auraGuid, out reason)) { ctx.Reply(reason); } else { _auraPreviewUntil[(val.PlatformId, auraGuid)] = DateTime.UtcNow.AddSeconds(10.0); ctx.Reply(string.Concat(str1: (TryGetAuraCost(auraId, out var cost, out var purchaseDisabled) && TryGetAuraCurrency(auraId, out var _, out var currencyName)) ? $"Buy this aura with .buy aura {auraId} for {cost}x {currencyName}." : ((!purchaseDisabled) ? "This aura does not have a configured price." : "This aura is not available for purchase."), str0: $"Previewing aura {auraId} for {10} seconds.\n")); } } } private static bool TryApplyPreviewAuraBuff(Entity userEntity, Entity character, int auraGuid, out string reason) { //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_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) reason = string.Empty; try { EntityManager entityManager = Core.EntityManager; PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(auraGuid); if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity)) { reason = "User not ready."; return false; } if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character)) { reason = "Character not ready."; return false; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(val))) { reason = "This aura is already active."; return false; } Buffs.AddBuff(userEntity, character, val, 10, immortal: false); return true; } catch (Exception e) { Core.LogException(e, "TryApplyPreviewAuraBuff"); reason = "Failed to apply aura preview."; return false; } } private static bool IsAuraPreviewActive(ulong steamId, int auraGuid, out double remainingSeconds) { remainingSeconds = 0.0; if (steamId == 0) { return false; } (ulong, int) key = (steamId, auraGuid); if (!_auraPreviewUntil.TryGetValue(key, out var value)) { return false; } DateTime utcNow = DateTime.UtcNow; if (utcNow >= value) { _auraPreviewUntil.Remove(key); return false; } remainingSeconds = Math.Max(0.0, (value - utcNow).TotalSeconds); return true; } public unsafe static void AdminAddAura(ChatCommandContext ctx, string playerName, string idToken) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00ff: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_0299: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); User user = ctx.Event.User; ulong platformId = user.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!Plugin.auraFeatureEnabled.Value) { ctx.Reply("Aura system is currently disabled."); } else { if (!TryResolveAuraId(ctx, idToken, out var auraId, out var auraGuid)) { return; } if (!TryFindPlayerByName(playerName, out var userEntity, out var user2, out var candidates)) { HandleFindPlayer(ctx, playerName, candidates); return; } Entity entityOnServer = ((NetworkedEntity)(ref user2.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(user2.PlatformId); bool flag = HasAura(orCreatePlayerCache, auraGuid); AddOrSetAura(orCreatePlayerCache, auraGuid, active: true); ApplyAuraBuff(userEntity, entityOnServer, auraGuid); TryGetAuraCurrency(auraId, out var _, out var _); PlayerDataService.SaveNow(); if (flag) { ctx.Reply($"{user2.CharacterName} already has aura {auraId}. It has been activated."); AppendAuraLog("admin_add", platformId, text, user2.PlatformId, ((object)(*(FixedString64Bytes*)(&user2.CharacterName))/*cast due to .constrained prefix*/).ToString(), auraId, auraGuid, 0, 0, "", success: true, "already_owned_activated"); } else { ctx.Reply($"Granted aura {auraId} to {user2.CharacterName}."); Helper.NotifyUser(userEntity, $"You have been granted aura {auraId}."); AppendAuraLog("admin_add", platformId, text, user2.PlatformId, ((object)(*(FixedString64Bytes*)(&user2.CharacterName))/*cast due to .constrained prefix*/).ToString(), auraId, auraGuid, 0, 0, "", success: true, "successful"); } ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 6, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Admin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(platformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") granted aura "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(auraId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(auraGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user2.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user2.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); return; } } ctx.Reply("Target character not found."); } } public unsafe static void AdminRemoveAura(ChatCommandContext ctx, string playerName, string idToken) { //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_007d: 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_0084: 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_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: 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) EnsureInitialized(); User user = ctx.Event.User; ulong platformId = user.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!TryResolveAuraId(ctx, idToken, out var auraId, out var auraGuid)) { return; } if (!TryFindPlayerByName(playerName, out var userEntity, out var user2, out var candidates)) { HandleFindPlayer(ctx, playerName, candidates); return; } Entity entityOnServer = ((NetworkedEntity)(ref user2.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(user2.PlatformId); PlayerCacheData playerCacheData = orCreatePlayerCache; if (playerCacheData.Auras == null) { List list = (playerCacheData.Auras = new List()); } PlayerAuraData playerAuraData = orCreatePlayerCache.Auras.FirstOrDefault((PlayerAuraData a) => a.PrefabGuid == auraGuid); if (playerAuraData == null) { ctx.Reply($"{user2.CharacterName} does not own aura {auraId}."); return; } orCreatePlayerCache.Auras.Remove(playerAuraData); RemoveAuraBuff(entityOnServer, auraGuid); TryGetAuraCurrency(auraId, out var _, out var _); PlayerDataService.SaveNow(); ctx.Reply($"Removed aura {auraId} from {user2.CharacterName}."); Helper.NotifyUser(userEntity, $"Your aura {auraId} has been removed by an admin."); AppendAuraLog("admin_remove", platformId, text, user2.PlatformId, ((object)(*(FixedString64Bytes*)(&user2.CharacterName))/*cast due to .constrained prefix*/).ToString(), auraId, auraGuid, 0, 0, "", success: true, "successful"); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Admin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(platformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") removed aura "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(auraId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(auraGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user2.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user2.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); return; } } ctx.Reply("Target character not found."); } private static void AddOrSetAura(PlayerCacheData cache, int auraGuid, bool active) { if (cache.Auras == null) { List list = (cache.Auras = new List()); } PlayerAuraData playerAuraData = cache.Auras.FirstOrDefault((PlayerAuraData a) => a.PrefabGuid == auraGuid); if (playerAuraData == null) { cache.Auras.Add(new PlayerAuraData { PrefabGuid = auraGuid, Active = active }); } else { playerAuraData.Active = active; } } public static void ListAuras(ChatCommandContext ctx) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); if (_auraPrefabGuids.Count == 0) { ctx.Reply("No auras are configured."); return; } User val = ctx.Event.SenderUserEntity.Read(); if (val.PlatformId == 0) { ctx.Reply("Cannot read your SteamID."); return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(val.PlatformId); PlayerCacheData playerCacheData = orCreatePlayerCache; if (playerCacheData.Auras == null) { List list = (playerCacheData.Auras = new List()); } int count = _auraPrefabGuids.Count; int num = (int)Math.Ceiling((double)count / 6.0); for (int i = 0; i < num; i++) { int num2 = i * 6; int num3 = Math.Min(num2 + 6, count); StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(35, 2, stringBuilder2); handler.AppendLiteral("Aura list ("); handler.AppendFormatted(i + 1); handler.AppendLiteral("/"); handler.AppendFormatted(num); handler.AppendLiteral(")"); stringBuilder3.AppendLine(ref handler); for (int j = num2; j < num3; j++) { int num4 = j + 1; int auraGuid = _auraPrefabGuids[j]; int cost; bool purchaseDisabled; int currencyGuid; string currencyName; string value = ((TryGetAuraCost(num4, out cost, out purchaseDisabled) && TryGetAuraCurrency(num4, out currencyGuid, out currencyName)) ? $"{cost}x {currencyName}" : ((!purchaseDisabled) ? "Not configured" : "Not for sale")); PlayerAuraData playerAuraData = orCreatePlayerCache.Auras.FirstOrDefault((PlayerAuraData a) => a.PrefabGuid == auraGuid); string value2 = ((playerAuraData == null) ? "Not owned" : (playerAuraData.Active ? "ON" : "OFF")); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(8, 3, stringBuilder2); handler.AppendLiteral("["); handler.AppendFormatted(num4); handler.AppendLiteral("] "); handler.AppendFormatted(value); handler.AppendLiteral(" - ("); handler.AppendFormatted(value2); handler.AppendLiteral(")"); stringBuilder4.AppendLine(ref handler); } ctx.Reply(stringBuilder.ToString().TrimEnd()); } } public static void ReplyHelp(ChatCommandContext ctx) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); bool value = Plugin.auraFeatureEnabled.Value; string value2 = (value ? "Enabled" : "Disabled"); if (value) { stringBuilder.AppendLine("Aura Commands:"); stringBuilder.AppendLine(".aura on or .aura on all"); stringBuilder.AppendLine(".aura off or .aura off all"); stringBuilder.AppendLine(".buy aura or .aura buy "); stringBuilder.AppendLine(".aura preview "); stringBuilder.AppendLine(".aura list"); if (ctx.Event.User.IsAdmin) { stringBuilder.AppendLine(".aura add "); stringBuilder.AppendLine(".aura remove "); } } StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(35, 1, stringBuilder2); handler.AppendLiteral("Aura Status: "); handler.AppendFormatted(value2); stringBuilder2.AppendLine(ref handler); ctx.Reply(stringBuilder.ToString().TrimEnd()); } public static void SetAuraActive(ChatCommandContext ctx, string idToken, bool active) { //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_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_0089: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); if (string.Equals(idToken, "all", StringComparison.OrdinalIgnoreCase)) { SetAllAurasActive(ctx, active); } else if (!Plugin.auraFeatureEnabled.Value && active) { ctx.Reply("Aura system is currently disabled."); } else { if (!TryResolveAuraId(ctx, idToken, out var auraId, out var auraGuid)) { return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); if (val.PlatformId == 0) { ctx.Reply("Cannot read your SteamID."); return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(val.PlatformId); PlayerCacheData playerCacheData = orCreatePlayerCache; if (playerCacheData.Auras == null) { List list = (playerCacheData.Auras = new List()); } PlayerAuraData playerAuraData = orCreatePlayerCache.Auras.FirstOrDefault((PlayerAuraData a) => a.PrefabGuid == auraGuid); if (playerAuraData == null) { ctx.Reply("You do not own this aura."); return; } if (playerAuraData.Active == active) { if (!active) { RemoveAuraBuff(senderCharacterEntity, auraGuid); } ctx.Reply(active ? "This aura is already active." : "This aura is already inactive."); return; } if (!TryBeginAuraSaveCooldown(val.PlatformId, out var remainingSeconds)) { ctx.Reply($"Please wait {remainingSeconds:0.0}s before changing aura again."); return; } playerAuraData.Active = active; PlayerDataService.SaveNow(); if (active) { ApplyAuraBuff(senderUserEntity, senderCharacterEntity, auraGuid); ctx.Reply($"Aura {auraId} activated."); } else { RemoveAuraBuff(senderCharacterEntity, auraGuid); ctx.Reply($"Aura {auraId} deactivated."); } } } public static void SetAllAurasActive(ChatCommandContext ctx, bool active) { //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_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); if (!Plugin.auraFeatureEnabled.Value && active) { ctx.Reply("Aura system is currently disabled."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); if (val.PlatformId == 0) { ctx.Reply("Cannot read your SteamID."); return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(val.PlatformId); PlayerCacheData playerCacheData = orCreatePlayerCache; if (playerCacheData.Auras == null) { List list = (playerCacheData.Auras = new List()); } if (orCreatePlayerCache.Auras.Count == 0) { ctx.Reply("You do not own any auras."); return; } List list3 = (from aura in orCreatePlayerCache.Auras where _auraPrefabGuids.Contains(aura.PrefabGuid) where aura.Active != active select aura).ToList(); if (list3.Count == 0) { if (!active) { foreach (PlayerAuraData aura in orCreatePlayerCache.Auras) { if (_auraPrefabGuids.Contains(aura.PrefabGuid)) { RemoveAuraBuff(senderCharacterEntity, aura.PrefabGuid); } } } ctx.Reply(active ? "All owned auras are already active." : "All owned auras are already inactive."); return; } if (!TryBeginAuraSaveCooldown(val.PlatformId, out var remainingSeconds)) { ctx.Reply($"Please wait {remainingSeconds:0.0}s before changing aura again."); return; } foreach (PlayerAuraData item in list3) { item.Active = active; if (active) { ApplyAuraBuff(senderUserEntity, senderCharacterEntity, item.PrefabGuid); } else { RemoveAuraBuff(senderCharacterEntity, item.PrefabGuid); } } PlayerDataService.SaveNow(); ctx.Reply(active ? $"Activated {list3.Count} aura(s)." : $"Deactivated {list3.Count} aura(s)."); } private static void DeactivateAllPlayerAuras() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown int num = 0; int num2 = 0; foreach (PlayerCacheData allPlayerCache in PlayerDataService.GetAllPlayerCaches()) { if (allPlayerCache.Auras == null || allPlayerCache.Auras.Count == 0) { continue; } bool flag = false; foreach (PlayerAuraData aura in allPlayerCache.Auras) { if (aura.Active) { aura.Active = false; flag = true; num2++; } } if (flag) { num++; } } if (num2 > 0) { PlayerDataService.SaveNow(); ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] Set "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" aura(s) inactive for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player(s)."); } log.LogInfo(val); } } private static void ApplyAuraBuff(Entity userEntity, Entity character, int auraGuid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0010: 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_0030: 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_003f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0067: 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) EntityManager entityManager = Core.EntityManager; PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(auraGuid); if (!(character == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(character) && !(userEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(userEntity) && !BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(val))) { Buffs.AddBuff(userEntity, character, val, -1); } } private static bool RemoveAuraBuff(Entity character, int auraGuid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0010: 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_0032: 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_0034: 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_004c: 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) EntityManager entityManager = Core.EntityManager; PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(auraGuid); if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character)) { return false; } if (!BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(val))) { return false; } Buffs.RemoveBuff(character, val); return true; } private static bool HasAura(PlayerCacheData cache, int auraGuid) { return cache.Auras != null && cache.Auras.Any((PlayerAuraData a) => a.PrefabGuid == auraGuid); } private static bool TryBeginAuraSaveCooldown(ulong steamId, out double remainingSeconds) { remainingSeconds = 0.0; if (steamId == 0) { return true; } DateTime utcNow = DateTime.UtcNow; if (_auraToggleCooldowns.TryGetValue(steamId, out var value) && utcNow < value) { remainingSeconds = Math.Max(0.0, (value - utcNow).TotalSeconds); return false; } _auraToggleCooldowns[steamId] = utcNow.AddSeconds(5.0); return true; } private static void HandleFindPlayer(ChatCommandContext ctx, string playerName, List candidates) { if (string.IsNullOrWhiteSpace(playerName) || playerName.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return; } playerName = playerName.Trim(); if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many players found for " + playerName + ". Please enter a more specific name."); } else { ctx.Reply("Multiple players matched " + playerName + ": " + string.Join(", ", candidates)); } } else { ctx.Reply("Player not found: " + playerName + ""); } } private unsafe static bool TryFindPlayerByName(string query, out Entity userEntity, out User user, out List candidates) { //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) //IL_001a: 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_0064: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00cd: 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_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_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; user = default(User); candidates = null; query = (query ?? string.Empty).Trim(); if (query.Length < 2) { candidates = new List(); return false; } EntityManager entityManager = Core.EntityManager; NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); List<(Entity, User, string)> list = new List<(Entity, User, string)>(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (current == Entity.Null || !((EntityManager)(ref entityManager)).Exists(current) || !((EntityManager)(ref entityManager)).HasComponent(current)) { continue; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.PlatformId != 0) { string text = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text)) { list.Add((current, componentData, text)); } } } List<(Entity, User, string)> list2 = list.Where<(Entity, User, string)>(((Entity Entity, User User, string Name) x) => string.Equals(x.Name, query, StringComparison.OrdinalIgnoreCase)).ToList(); if (list2.Count == 1) { userEntity = list2[0].Item1; user = list2[0].Item2; return true; } if (list2.Count > 1) { candidates = list2.Select<(Entity, User, string), string>(((Entity Entity, User User, string Name) x) => x.Name).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string x) => x, StringComparer.OrdinalIgnoreCase) .ToList(); return false; } List<(Entity, User, string)> list3 = list.Where<(Entity, User, string)>(((Entity Entity, User User, string Name) x) => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); if (list3.Count == 1) { userEntity = list3[0].Item1; user = list3[0].Item2; return true; } if (list3.Count > 1) { candidates = list3.Select<(Entity, User, string), string>(((Entity Entity, User User, string Name) x) => x.Name).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string x) => x, StringComparer.OrdinalIgnoreCase) .ToList(); } return false; } finally { if (val.IsCreated) { val.Dispose(); } } } private static void EnsureInitialized() { if (!_initialized) { Initialize(); } } public static int ReloadConfig() { LoadConfig(); return _auraPrefabGuids.Count; } public static void LoadConfig() { List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); bool flag = true; flag &= ParseIntListStrict("AuraPrefabGuids", Plugin.auraPrefabGuids.Value, list); flag &= ParseIntListStrict("AuraCosts", Plugin.auraCosts.Value, list2); flag &= ParseStringListStrict("AuraCurrencyName", Plugin.auraCurrencyName.Value, list3); if (!(flag & ParseIntListStrict("AuraCurrencyPrefabGuid", Plugin.auraCurrencyPrefabGuid.Value, list4))) { Core.Log.LogError((object)"[Aura] Aura config contains invalid value(s). Keeping previous aura config. Fix the config and restart or reload the plugin."); return; } _auraPrefabGuids.Clear(); _auraCosts.Clear(); _auraCurrencyNames.Clear(); _auraCurrencyPrefabGuids.Clear(); _auraPrefabGuids.AddRange(list); _auraCosts.AddRange(list2); _auraCurrencyNames.AddRange(list3); _auraCurrencyPrefabGuids.AddRange(list4); ValidateAuraConfigCounts(); } private static bool ParseIntListStrict(string configName, string input, List output) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown output.Clear(); if (string.IsNullOrWhiteSpace(input)) { return true; } string[] array = input.Split(','); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (string.IsNullOrWhiteSpace(text)) { ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(configName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has an empty value at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); return false; } if (!int.TryParse(text, out var result)) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(configName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has an invalid integer at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"."); } log2.LogError(val); return false; } output.Add(result); } return true; } private static bool ParseStringListStrict(string configName, string input, List output) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown output.Clear(); if (string.IsNullOrWhiteSpace(input)) { return true; } string[] array = input.Split(','); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (string.IsNullOrWhiteSpace(text)) { ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(configName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has an empty value at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); return false; } output.Add(text); } return true; } private static void ValidateAuraConfigCounts() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown bool flag = default(bool); if (_auraCosts.Count < _auraPrefabGuids.Count) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(105, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCosts has fewer entries than AuraPrefabGuids. Some auras cannot be purchased. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Costs: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCosts.Count); } log.LogWarning(val); } else if (_auraCosts.Count > _auraPrefabGuids.Count) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(101, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCosts has more entries than AuraPrefabGuids. Extra costs will be ignored. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Costs: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCosts.Count); } log2.LogWarning(val); } if (_auraCurrencyNames.Count < _auraPrefabGuids.Count) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(120, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCurrencyName has fewer entries than AuraPrefabGuids. Some auras cannot be purchased. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", CurrencyNames: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCurrencyNames.Count); } log3.LogWarning(val); } else if (_auraCurrencyNames.Count > _auraPrefabGuids.Count) { ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(116, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCurrencyName has more entries than AuraPrefabGuids. Extra names will be ignored. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", CurrencyNames: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCurrencyNames.Count); } log4.LogWarning(val); } if (_auraCurrencyPrefabGuids.Count < _auraPrefabGuids.Count) { ManualLogSource log5 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(132, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCurrencyPrefabGuid has fewer entries than AuraPrefabGuids. Some auras cannot be purchased. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", CurrencyPrefabGuids: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCurrencyPrefabGuids.Count); } log5.LogWarning(val); } else if (_auraCurrencyPrefabGuids.Count > _auraPrefabGuids.Count) { ManualLogSource log6 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(144, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Aura] AuraCurrencyPrefabGuid has more entries than AuraPrefabGuids. Extra currency prefab GUIDs will be ignored. Auras: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraPrefabGuids.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", CurrencyPrefabGuids: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_auraCurrencyPrefabGuids.Count); } log6.LogWarning(val); } } private static void AppendAuraLog(string action, ulong actorSteamId, string actorName, ulong targetSteamId, string targetName, int auraId, int auraGuid, int cost, int currencyGuid, string currencyName, bool success, string reason = "") { try { lock (LOG_LOCK) { Directory.CreateDirectory(LOG_DIR); bool flag = !File.Exists(LOG_FILE); using FileStream stream = new FileStream(LOG_FILE, FileMode.Append, FileAccess.Write, FileShare.Read); using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (flag) { streamWriter.WriteLine("times,action,actor_steam_id,actor_name,target_steam_id,target_name,aura_id,aura_guid,cost,currency_prefab,currency_name,success,reason"); } streamWriter.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss},{Helper.Csv(action)},{actorSteamId},{Helper.Csv(actorName)},{targetSteamId},{Helper.Csv(targetName)},{auraId},{auraGuid},{cost},{currencyGuid},{Helper.Csv(currencyName)},{(success ? "true" : "false")},{Helper.Csv(reason)}"); } } catch (Exception e) { Core.LogException(e, "AppendAuraLog"); } } } internal static class BanService { public static void AddBan(ChatCommandContext ctx, string targetInput) { //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown PlayerCacheData playerCacheData = null; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (ulong.TryParse(targetInput, out var result)) { playerCacheData = PlayerDataService.GetOrCreatePlayerCache(result); playerCacheData.IsBanned = true; PlayerDataService.SaveData(); string text = (string.IsNullOrWhiteSpace(playerCacheData.InGameName) ? $"{result}" : $"{playerCacheData.InGameName} ({result})"); ctx.Reply("Banned player: " + text + ""); ManualLogSource log = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Banlist] Banned player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log.LogInfo(val); AccessControlService.KickIfOnline(result); return; } playerCacheData = PlayerDataService.GetPlayerCacheByName(targetInput); if (playerCacheData == null) { ctx.Reply("Player not found in history: " + targetInput + ". To pre-ban a new player, please use their SteamID."); return; } playerCacheData.IsBanned = true; PlayerDataService.SaveData(); ctx.Reply($"Banned player: {playerCacheData.InGameName} ({playerCacheData.SteamID})"); ManualLogSource log2 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Banlist] Banned player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerCacheData.InGameName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerCacheData.SteamID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log2.LogInfo(val); AccessControlService.KickIfOnline(playerCacheData.SteamID); } public static void RemoveBan(ChatCommandContext ctx, string targetInput) { //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown PlayerCacheData playerCacheData = null; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (ulong.TryParse(targetInput, out var result)) { playerCacheData = PlayerDataService.GetPlayerCache(result); if (playerCacheData == null || !playerCacheData.IsBanned) { ctx.Reply($"{result} is not in the banlist."); return; } playerCacheData.IsBanned = false; if (string.IsNullOrWhiteSpace(playerCacheData.InGameName) && string.IsNullOrWhiteSpace(playerCacheData.KnownAs) && !playerCacheData.IsWhitelisted && playerCacheData.LastOnlineTicks == 0) { PlayerDataService.RemovePlayerCache(result); } else { PlayerDataService.SaveData(); } string text = (string.IsNullOrWhiteSpace(playerCacheData.InGameName) ? $"{result}" : $"{playerCacheData.InGameName} ({result})"); ctx.Reply("Unbanned player: " + text + ""); ManualLogSource log = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Banlist] Unbanned player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log.LogInfo(val); return; } playerCacheData = PlayerDataService.GetPlayerCacheByName(targetInput); if (playerCacheData == null || !playerCacheData.IsBanned) { ctx.Reply("" + targetInput + " is not in the banlist."); return; } playerCacheData.IsBanned = false; PlayerDataService.SaveData(); ctx.Reply($"Unbanned player: {playerCacheData.InGameName} ({playerCacheData.SteamID})"); ManualLogSource log2 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Banlist] Unbanned player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerCacheData.InGameName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerCacheData.SteamID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log2.LogInfo(val); } public static void ShowBanlist(ChatCommandContext ctx) { List bannedPlayers = PlayerDataService.GetBannedPlayers(); if (bannedPlayers.Count == 0) { ctx.Reply("The banlist is empty."); return; } int num = 8; int value = (int)Math.Ceiling((double)bannedPlayers.Count / (double)num); for (int i = 0; i < bannedPlayers.Count; i += num) { StringBuilder stringBuilder = new StringBuilder(); int value2 = i / num + 1; StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(37, 2, stringBuilder2); handler.AppendLiteral("Banned Players ("); handler.AppendFormatted(value2); handler.AppendLiteral("/"); handler.AppendFormatted(value); handler.AppendLiteral(")"); stringBuilder3.AppendLine(ref handler); List range = bannedPlayers.GetRange(i, Math.Min(num, bannedPlayers.Count - i)); foreach (PlayerCacheData item in range) { string value3 = (string.IsNullOrWhiteSpace(item.InGameName) ? "Unknown" : item.InGameName); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(22, 2, stringBuilder2); handler.AppendFormatted(item.SteamID); handler.AppendLiteral(" "); handler.AppendFormatted(value3); handler.AppendLiteral(""); stringBuilder4.AppendLine(ref handler); } ctx.Reply(stringBuilder.ToString().TrimEnd()); } } public static bool IsBannedPlayer(PlayerCacheData cache) { return cache?.IsBanned ?? false; } public static void ReplyBanHelp(ChatCommandContext ctx) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Ban Commands:"); stringBuilder.AppendLine(".pls ban "); stringBuilder.AppendLine(".pls unban "); stringBuilder.AppendLine(".pls banlist"); stringBuilder.AppendLine(".pls banhelp"); ctx.Reply(stringBuilder.ToString().TrimEnd()); } } internal static class ChangeNameService { private static readonly string LOG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string LOG_FILE = Path.Combine(LOG_DIR, "rename_log.csv"); private static readonly object LOG_LOCK = new object(); public static void ProcessRename(ChatCommandContext ctx, Entity userEntity, Entity charEntity, string oldName, string newName, ulong steamId, bool isAdminOverride) { //IL_00fb: 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_00b4: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown if (!Plugin.changeNameFeatureEnabled.Value) { ctx.Reply("Change name feature is currently disabled."); return; } if (!isAdminOverride && Helper.IsRaidTime()) { ctx.Reply("You cannot change your name during active Raid Time."); return; } if (!isAdminOverride && Helper.IsInCombat(charEntity)) { ctx.Reply("You cannot change your name while in combat."); return; } if (!ValidateNewName(newName, oldName, steamId, out var normalizedName, out var logReason, out var replyMessage)) { ReplyHelp(ctx, replyMessage); AppendRenameLog(steamId, oldName, newName, success: false, logReason); return; } newName = normalizedName; bool currencySpent = false; if (!isAdminOverride) { if (!TrySpendCurrency(charEntity, out var spendLogReason, out var spendReplyMessage)) { ctx.Reply(spendReplyMessage); AppendRenameLog(steamId, oldName, newName, success: false, spendLogReason); return; } currencySpent = true; } try { PerformRenameECS(userEntity, charEntity, oldName, newName); } catch (Exception ex) { HandleRenameFailureAfterPayment(ctx, charEntity, steamId, oldName, newName, ex, currencySpent); return; } string reason = (isAdminOverride ? "admin_rename" : "successful"); SendRenameNotifications(ctx, userEntity, oldName, newName, isAdminOverride); AppendRenameLog(steamId, oldName, newName, success: true, reason); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(63, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ChangeName] Player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(oldName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has changed name to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(newName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") (Admin Override: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(isAdminOverride); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } private unsafe static bool ValidateNewName(string newName, string oldName, ulong currentSteamId, out string normalizedName, out string logReason, out string replyMessage) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_010b: 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_0119: 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_0121: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) normalizedName = string.Empty; logReason = string.Empty; replyMessage = string.Empty; if (string.IsNullOrWhiteSpace(newName)) { logReason = "empty_name"; replyMessage = "Name cannot be empty."; return false; } normalizedName = newName.Trim().Normalize(NormalizationForm.FormC); newName = normalizedName; string b = (oldName ?? string.Empty).Trim().Normalize(NormalizationForm.FormC); if (string.Equals(newName, b, StringComparison.OrdinalIgnoreCase)) { logReason = "same_name"; replyMessage = "This is already your current name."; return false; } if (!Regex.IsMatch(newName, "^[\\p{L}\\p{M}\\p{N}]+$")) { logReason = "invalid_chars"; replyMessage = "Name can only contain letters and numbers."; return false; } int byteCount = Encoding.UTF8.GetByteCount(newName); if (byteCount > 56) { logReason = "too_long"; replyMessage = "Name is too long."; return false; } NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); string text = newName.ToLowerInvariant(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(current)) { User val2 = current.Read(); if (val2.PlatformId != currentSteamId && ((object)(*(FixedString64Bytes*)(&val2.CharacterName))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant() == text) { logReason = "duplicate_name"; replyMessage = "This name is already in use."; return false; } } } } finally { if (val.IsCreated) { val.Dispose(); } } return true; } private static void PerformRenameECS(Entity userEntity, Entity charEntity, string oldName, string newName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0010: 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_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_001c: 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_0024: 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_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) EntityManager entityManager = Core.EntityManager; FixedString64Bytes fixedName = default(FixedString64Bytes); ((FixedString64Bytes)(ref fixedName))..ctor(newName); UpdateUserNameAndClanName(entityManager, userEntity, oldName, newName, fixedName); SendRenameDebugEvent(entityManager, userEntity, charEntity, fixedName); UpdatePlayerMapIconName(entityManager, charEntity, fixedName); RefreshCastleOwnershipAfterRename(entityManager, userEntity); } private static void UpdateUserNameAndClanName(EntityManager em, Entity userEntity, string oldName, string newName, FixedString64Bytes fixedName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0047: 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_0052: 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_005a: 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_0062: 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) if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity)) { throw new InvalidOperationException("User entity is not available."); } if (!((EntityManager)(ref em)).HasComponent(userEntity)) { throw new InvalidOperationException("User entity does not have User component."); } User componentData = ((EntityManager)(ref em)).GetComponentData(userEntity); componentData.CharacterName = fixedName; ((EntityManager)(ref em)).SetComponentData(userEntity, componentData); UpdateDefaultClanName(em, componentData.ClanEntity._Entity, oldName, newName); } private unsafe static void UpdateDefaultClanName(EntityManager em, Entity clanEntity, string oldName, string newName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0085: 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) if (!(clanEntity == Entity.Null) && ((EntityManager)(ref em)).Exists(clanEntity) && ((EntityManager)(ref em)).HasComponent(clanEntity)) { ClanTeam componentData = ((EntityManager)(ref em)).GetComponentData(clanEntity); string text = ((object)(*(FixedString64Bytes*)(&componentData.Name))/*cast due to .constrained prefix*/).ToString(); if (!(text != oldName) || !(text != oldName + "'s Clan")) { string text2 = text.Replace(oldName, newName); componentData.Name = new FixedString64Bytes(text2); ((EntityManager)(ref em)).SetComponentData(clanEntity, componentData); } } } private static void SendRenameDebugEvent(EntityManager em, Entity userEntity, Entity charEntity, FixedString64Bytes fixedName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_003c: 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_0082: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_009b: 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) //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_00a6: 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_00af: 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_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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity)) { throw new InvalidOperationException("User entity is not available."); } if (charEntity == Entity.Null || !((EntityManager)(ref em)).Exists(charEntity)) { throw new InvalidOperationException("Character entity is not available."); } if (!((EntityManager)(ref em)).HasComponent(userEntity)) { throw new InvalidOperationException("User entity does not have NetworkId."); } DebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged(); NetworkId componentData = ((EntityManager)(ref em)).GetComponentData(userEntity); RenameUserDebugEvent val = new RenameUserDebugEvent { NewName = fixedName, Target = componentData }; FromCharacter val2 = new FromCharacter { User = userEntity, Character = charEntity }; existingSystemManaged.RenameUser(val2, val); } private static void UpdatePlayerMapIconName(EntityManager em, Entity charEntity, FixedString64Bytes fixedName) { //IL_0003: 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_0024: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //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_0043: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b6: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref em)).Exists(charEntity) || !((EntityManager)(ref em)).HasBuffer(charEntity)) { return; } Enumerator enumerator = ((EntityManager)(ref em)).GetBuffer(charEntity, false).GetEnumerator(); while (enumerator.MoveNext()) { AttachedBuffer current = enumerator.Current; PrefabGUID val = current.PrefabGuid; int guidHash = ((PrefabGUID)(ref val)).GuidHash; val = PrefabData.MapIconPlayer; if (guidHash == ((PrefabGUID)(ref val)).GuidHash && ((EntityManager)(ref em)).Exists(current.Entity) && ((EntityManager)(ref em)).HasComponent(current.Entity)) { PlayerMapIcon componentData = ((EntityManager)(ref em)).GetComponentData(current.Entity); componentData.UserName = fixedName; ((EntityManager)(ref em)).SetComponentData(current.Entity, componentData); } } } private static void RefreshCastleOwnershipAfterRename(EntityManager em, Entity userEntity) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_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_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0091: 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_00a1: 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_00a5: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref em)).Exists(userEntity)) { return; } Entity renamedUserClan = Entity.Null; if (((EntityManager)(ref em)).HasComponent(userEntity)) { renamedUserClan = ((EntityManager)(ref em)).GetComponentData(userEntity).ClanEntity._Entity; } NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref em)).Exists(current) && ((EntityManager)(ref em)).HasComponent(current)) { UserOwner componentData = ((EntityManager)(ref em)).GetComponentData(current); Entity entityOnServer = ((NetworkedEntity)(ref componentData.Owner)).GetEntityOnServer(); if (ShouldRefreshCastleForRenamedUser(em, entityOnServer, userEntity, renamedUserClan)) { TeamUtility.ClaimCastle(em, entityOnServer, current, (CastleHeartLimitType)0); } } } } finally { if (val.IsCreated) { val.Dispose(); } } } private static bool ShouldRefreshCastleForRenamedUser(EntityManager em, Entity castleOwnerEntity, Entity renamedUserEntity, Entity renamedUserClan) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (castleOwnerEntity == Entity.Null || !((EntityManager)(ref em)).Exists(castleOwnerEntity)) { return false; } if (castleOwnerEntity == renamedUserEntity) { return true; } if (renamedUserClan == Entity.Null) { return false; } if (!((EntityManager)(ref em)).HasComponent(castleOwnerEntity)) { return false; } User componentData = ((EntityManager)(ref em)).GetComponentData(castleOwnerEntity); return componentData.ClanEntity._Entity == renamedUserClan; } private static bool TrySpendCurrency(Entity characterEntity, out string spendLogReason, out string spendReplyMessage) { //IL_004c: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) spendLogReason = string.Empty; spendReplyMessage = string.Empty; try { PrefabGUID itemPrefab = default(PrefabGUID); ((PrefabGUID)(ref itemPrefab))..ctor(Plugin.changeNameCurrencyPrefab.Value); int value = Plugin.changeNameCurrencyCost.Value; string value2 = Plugin.changeNameCurrencyName.Value; if (value <= 0) { return true; } int itemCountInInventory = Helper.GetItemCountInInventory(characterEntity, itemPrefab); if (itemCountInInventory < value) { spendLogReason = $"not_enough_currency_{itemCountInInventory}/{value}"; spendReplyMessage = $"Not enough {value2} ({itemCountInInventory}/{value})."; return false; } if (!Helper.TryRemoveItemsFromInventory(characterEntity, itemPrefab, value)) { spendLogReason = "remove_items_failed"; spendReplyMessage = "Failed to remove the required currency."; return false; } return true; } catch (Exception ex) { spendLogReason = "exception: " + ex.Message; spendReplyMessage = "Error: An unexpected error occurred while spending currency."; Core.LogException(ex, "TrySpendCurrency"); return false; } } private static void HandleRenameFailureAfterPayment(ChatCommandContext ctx, Entity charEntity, ulong steamId, string oldName, string newName, Exception ex, bool currencySpent) { //IL_001d: 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_0072: Expected O, but got Unknown string text = "rename_exception: " + ex.Message; if (currencySpent) { if (TryRefundCurrency(charEntity, out var refundLogReason)) { ctx.Reply("Failed to change name. Your currency has been refunded."); text += " | refund_success"; } else { ctx.Reply("Failed to change name. Currency refund failed. Please contact an admin."); text = text + " | refund_failed: " + refundLogReason; ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ChangeName] Rename failed and refund failed for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(oldName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(refundLogReason); } log.LogError(val); } } else { ctx.Reply("Failed to change name."); } AppendRenameLog(steamId, oldName, newName, success: false, text); Core.LogException(ex, "HandleRenameFailureAfterPayment"); } private static bool TryRefundCurrency(Entity characterEntity, out string refundLogReason) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) refundLogReason = string.Empty; try { PrefabGUID guid = default(PrefabGUID); ((PrefabGUID)(ref guid))..ctor(Plugin.changeNameCurrencyPrefab.Value); int value = Plugin.changeNameCurrencyCost.Value; if (value <= 0) { return true; } Entity val = Helper.AddItemToInventory(characterEntity, guid, value); if (val == Entity.Null) { refundLogReason = "add_item_failed"; return false; } return true; } catch (Exception ex) { refundLogReason = "exception: " + ex.Message; Core.LogException(ex, "TryRefundCurrency"); return false; } } public static void ReplyHelp(ChatCommandContext ctx, string warningLine = null) { StringBuilder stringBuilder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(warningLine)) { stringBuilder.AppendLine(warningLine); } bool value = Plugin.changeNameFeatureEnabled.Value; string value2 = (value ? "Enabled" : "Disabled"); int value3 = Plugin.changeNameCurrencyCost.Value; string value4 = Plugin.changeNameCurrencyName.Value; StringBuilder stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler; if (value) { stringBuilder.AppendLine("Change Name Feature"); stringBuilder.AppendLine("Command: .cn to "); stringBuilder.AppendLine("Example: .cn to ShadowHunter"); stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(52, 2, stringBuilder2); handler.AppendLiteral("Cost: "); handler.AppendFormatted(value3); handler.AppendLiteral(" "); handler.AppendFormatted(value4); handler.AppendLiteral(""); stringBuilder3.AppendLine(ref handler); stringBuilder.AppendLine("Allowed characters: letters from any language and numbers"); } stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(42, 1, stringBuilder2); handler.AppendLiteral("Change Name Status: "); handler.AppendFormatted(value2); stringBuilder4.AppendLine(ref handler); ctx.Reply(stringBuilder.ToString().TrimEnd()); } private static void SendRenameNotifications(ChatCommandContext ctx, Entity userEntity, string oldName, string newName, bool isAdminOverride) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_01a3: Unknown result type (might be due to invalid IL or missing references) if (isAdminOverride) { ctx.Reply($"Renamed {oldName} to {newName}."); if (userEntity != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity) && userEntity.Has()) { User val = userEntity.Read(); if (val.IsConnected) { FixedString512Bytes val2 = default(FixedString512Bytes); ((FixedString512Bytes)(ref val2))..ctor("Your name has been changed to " + newName + " by an admin."); ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, val, ref val2); } } } } else { ctx.Reply("Your name has been changed to " + newName + "."); } string text = Plugin.changeNameBroadcastMessage.Value.Replace("#oldname#", oldName).Replace("#newname#", newName); string message = Plugin.changeNameWebhookMessage.Value.Replace("#oldname#", oldName).Replace("#newname#", newName); if (isAdminOverride) { if (Plugin.adminChangeNameBroadcastAndWebhookEnabled.Value) { if (!string.IsNullOrWhiteSpace(text)) { FixedString512Bytes val3 = default(FixedString512Bytes); ((FixedString512Bytes)(ref val3))..ctor(text); ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val3); } WebhookService.SendAsync(message); } } else { if (Plugin.playerChangeNameBroadcastEnabled.Value && !string.IsNullOrWhiteSpace(text)) { FixedString512Bytes val4 = default(FixedString512Bytes); ((FixedString512Bytes)(ref val4))..ctor(text); ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val4); } if (Plugin.playerChangeNameWebhookEnabled.Value) { WebhookService.SendAsync(message); } } } public unsafe static bool TryFindUserByName(string query, out Entity userEntity, out Entity charEntity, out User user) { //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_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_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_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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: 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_0063: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; charEntity = Entity.Null; user = default(User); NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(current)) { User val2 = current.Read(); if (string.Equals(((object)(*(FixedString64Bytes*)(&val2.CharacterName))/*cast due to .constrained prefix*/).ToString(), query, StringComparison.OrdinalIgnoreCase)) { userEntity = current; user = val2; charEntity = ((NetworkedEntity)(ref val2.LocalCharacter)).GetEntityOnServer(); return true; } } } } finally { if (val.IsCreated) { val.Dispose(); } } return false; } private static void AppendRenameLog(ulong steamId, string oldName, string newName, bool success, string reason = "") { try { lock (LOG_LOCK) { Directory.CreateDirectory(LOG_DIR); bool flag = !File.Exists(LOG_FILE); using FileStream stream = new FileStream(LOG_FILE, FileMode.Append, FileAccess.Write, FileShare.Read); using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (flag) { streamWriter.WriteLine("times,steam_id,player_name_old,player_name_new,success,reason"); } streamWriter.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss},{steamId},{Helper.Csv(oldName)},{Helper.Csv(newName)},{(success ? "true" : "false")},{Helper.Csv(reason)}"); } } catch (Exception e) { Core.LogException(e, "AppendRenameLog"); } } } internal static class ClanService { private const float AUTO_JOIN_DELAY_SECONDS = 1f; public static void CreateClanForPlayer(ChatCommandContext ctx, string playerName) { //IL_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) if (TryFindPlayer(ctx, playerName, out var userEntity, out var charEntity, out var user, out var characterName)) { string clanName2; string reason; if (TryGetClanEntity(user, out var clanEntity)) { string clanName = GetClanName(clanEntity); ctx.Reply($"{characterName} is already in clan {clanName}."); } else if (!TryCreateClanRequest(userEntity, charEntity, characterName, out clanName2, out reason)) { ctx.Reply(reason); } else { ctx.Reply($"Force create clan for {characterName}: {clanName2}."); } } } public static void JoinPlayerToPlayerClan(ChatCommandContext ctx, string playerAName, string playerBName) { //IL_003b: 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_005a: 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_007e: 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_0090: 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_0171: 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_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: 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_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) if (!TryFindPlayer(ctx, playerAName, out var userEntity, out var _, out var user, out var characterName) || !TryFindPlayer(ctx, playerBName, out var userEntity2, out var charEntity2, out var user2, out var characterName2)) { return; } if (userEntity == userEntity2) { ctx.Reply("Player A and Player B cannot be the same."); return; } Entity clanEntity; bool flag = TryGetClanEntity(user, out clanEntity); Entity clanEntity2; bool flag2 = TryGetClanEntity(user2, out clanEntity2); string clanName5; string reason3; if (flag && flag2) { string clanName = GetClanName(clanEntity); string clanName2 = GetClanName(clanEntity2); if (clanEntity == clanEntity2) { ctx.Reply($"{characterName} and {characterName2} are already in the same clan {clanName}."); } else { ctx.Reply($"{characterName} and {characterName2} already have clans."); } } else if (flag) { if (!TryAddUserToClan(userEntity2, clanEntity, out var clanName3, out var reason)) { ctx.Reply(reason); return; } ctx.Reply($"Forced {characterName2} to join {characterName}'s clan {clanName3}."); } else if (flag2) { if (!TryAddUserToClan(userEntity, clanEntity2, out var clanName4, out var reason2)) { ctx.Reply(reason2); return; } ctx.Reply($"Forced {characterName} to join {characterName2}'s clan {clanName4}."); } else if (!TryCreateClanRequest(userEntity2, charEntity2, characterName2, out clanName5, out reason3)) { ctx.Reply(reason3); } else { ctx.Reply($"{characterName} and {characterName2} have no clan. Creating clan for {characterName2}."); Core.StartCoroutine(JoinAfterClanCreateRoutine(ctx.Event.SenderUserEntity, userEntity, userEntity2, characterName, characterName2, clanName5)); } } public static void LeaveClan(ChatCommandContext ctx, string playerName) { //IL_001e: 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) if (TryFindPlayer(ctx, playerName, out var userEntity, out var charEntity, out var user, out var characterName)) { if (!TryGetClanEntity(user, out var clanEntity)) { ctx.Reply("" + characterName + " is not in a clan."); return; } if (!TryLeaveClanRequest(userEntity, charEntity, clanEntity, out var clanName, out var reason)) { ctx.Reply(reason); return; } ctx.Reply($"{characterName} has been forced to leave clan {clanName}."); } } private static IEnumerator JoinAfterClanCreateRoutine(Entity adminUserEntity, Entity userAEntity, Entity userBEntity, string nameA, string nameB, string expectedClanName) { //IL_0007: 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_000e: 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_0015: 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) yield return (object)new WaitForSeconds(1f); try { EntityManager em = Core.EntityManager; if (userAEntity == Entity.Null || userBEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userAEntity) || !((EntityManager)(ref em)).Exists(userBEntity)) { NotifyAdmin(adminUserEntity, "Clan join failed because player data is no longer available."); yield break; } if (!((EntityManager)(ref em)).HasComponent(userAEntity) || !((EntityManager)(ref em)).HasComponent(userBEntity)) { NotifyAdmin(adminUserEntity, "Clan join failed because user data is no longer available."); yield break; } User userA = ((EntityManager)(ref em)).GetComponentData(userAEntity); User userB = ((EntityManager)(ref em)).GetComponentData(userBEntity); if (TryGetClanEntity(userA, out var clanAEntity)) { string clanAName = GetClanName(clanAEntity); NotifyAdmin(adminUserEntity, $"{nameA} is already in clan {clanAName}."); yield break; } Entity clanBEntity = Entity.Null; if (!TryGetClanEntity(userB, out clanBEntity)) { FindClan(expectedClanName, out clanBEntity); } if (clanBEntity == Entity.Null || !((EntityManager)(ref em)).Exists(clanBEntity) || !((EntityManager)(ref em)).HasComponent(clanBEntity)) { NotifyAdmin(adminUserEntity, "Clan join failed because " + nameB + "'s clan was not created yet."); yield break; } RefreshClanTagOnCharacter(userBEntity, GetClanName(clanBEntity)); if (!TryAddUserToClan(userAEntity, clanBEntity, out var joinedClanName, out var reason)) { NotifyAdmin(adminUserEntity, reason); yield break; } NotifyAdmin(adminUserEntity, $"Forced {nameA} to join {nameB}'s clan {joinedClanName}."); em = default(EntityManager); } catch (Exception ex) { Exception e = ex; Core.LogException(e, "JoinAfterClanCreateRoutine"); NotifyAdmin(adminUserEntity, "Clan join failed because an error occurred."); } } private static bool TryCreateClanRequest(Entity userEntity, Entity charEntity, string characterName, out string clanName, out string reason) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0098: 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_009f: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) clanName = string.Empty; reason = string.Empty; EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || charEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).Exists(charEntity)) { reason = "Failed: target character entity not found."; return false; } clanName = GenerateUniqueClanName(characterName); if (string.IsNullOrWhiteSpace(clanName)) { reason = "Failed: cannot generate clan name."; return false; } FromCharacter val = new FromCharacter { User = userEntity, Character = charEntity }; EntityArchetype val2 = ((EntityManager)(ref entityManager)).CreateArchetype((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadWrite(), ComponentType.ReadWrite() }); Entity val3 = ((EntityManager)(ref entityManager)).CreateEntity(val2); ((EntityManager)(ref entityManager)).SetComponentData(val3, val); ((EntityManager)(ref entityManager)).SetComponentData(val3, new CreateClan_Request { ClanName = new FixedString64Bytes(clanName), ClanMotto = new FixedString64Bytes(clanName) }); return true; } private static bool TryAddUserToClan(Entity userEntity, Entity clanEntity, out string clanName, out string reason) { //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) //IL_0015: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) clanName = string.Empty; reason = string.Empty; EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || clanEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).Exists(clanEntity)) { reason = "Failed to resolve user or clan entity."; return false; } if (!((EntityManager)(ref entityManager)).HasComponent(userEntity)) { reason = "Failed to read target user data."; return false; } if (!((EntityManager)(ref entityManager)).HasComponent(clanEntity)) { reason = "Failed to resolve clan data."; return false; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); if (TryGetClanEntity(componentData, out var clanEntity2)) { string clanName2 = GetClanName(clanEntity2); reason = $"{componentData.CharacterName} is already in clan {clanName2}."; return false; } TeamUtility.AddUserToClan(entityManager, clanEntity, userEntity, ref componentData, (CastleHeartLimitType)0); ((EntityManager)(ref entityManager)).SetComponentData(userEntity, componentData); SetClanRoleMember(userEntity, clanEntity); clanName = GetClanName(clanEntity); RefreshClanTagOnCharacter(userEntity, clanName); return true; } private static bool TryLeaveClanRequest(Entity userEntity, Entity charEntity, Entity clanEntity, out string clanName, out string reason) { //IL_0002: 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_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0032: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00ab: 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_00b3: 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_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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00e2: 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_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_00ef: 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_00fa: 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_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_010c: 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_004a: 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) clanName = GetClanName(clanEntity); reason = string.Empty; EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || charEntity == Entity.Null || clanEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).Exists(charEntity) || !((EntityManager)(ref entityManager)).Exists(clanEntity)) { reason = "Failed to resolve user, character, or clan entity."; return false; } if (!((EntityManager)(ref entityManager)).HasComponent(clanEntity)) { reason = "Failed to read clan NetworkId."; return false; } FromCharacter val = new FromCharacter { User = userEntity, Character = charEntity }; NetworkId componentData = ((EntityManager)(ref entityManager)).GetComponentData(clanEntity); EntityArchetype val2 = ((EntityManager)(ref entityManager)).CreateArchetype((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadWrite(), ComponentType.ReadWrite() }); Entity val3 = ((EntityManager)(ref entityManager)).CreateEntity(val2); ((EntityManager)(ref entityManager)).SetComponentData(val3, val); ((EntityManager)(ref entityManager)).SetComponentData(val3, new LeaveClan { ClanId = componentData }); RefreshClanTagOnCharacter(userEntity, string.Empty); return true; } private static void SetClanRoleMember(Entity userEntity, Entity clanEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasBuffer(clanEntity) && ((EntityManager)(ref entityManager)).HasBuffer(clanEntity)) { DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false); DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false); for (int i = 0; i < buffer.Length && i < buffer2.Length; i++) { SyncToUserBuffer val = buffer2[i]; if (((Entity)(ref val.UserEntity)).Equals(userEntity)) { ClanMemberStatus val2 = buffer[i]; val2.ClanRole = (ClanRoleEnum)0; buffer[i] = val2; break; } } } if (((EntityManager)(ref entityManager)).HasComponent(userEntity)) { ClanRole componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); componentData.Value = (ClanRoleEnum)0; ((EntityManager)(ref entityManager)).SetComponentData(userEntity, componentData); } } private static bool TryFindPlayer(ChatCommandContext ctx, string playerName, out Entity userEntity, out Entity charEntity, out User user, out string characterName) { //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_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_0019: 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_005d: 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_0071: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_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) userEntity = Entity.Null; charEntity = Entity.Null; user = default(User); characterName = string.Empty; if (!Helper.TryFindUserByExactName(playerName, out userEntity, out user)) { ctx.Reply("Player not found: " + playerName + ""); return false; } EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).HasComponent(userEntity)) { ctx.Reply("Target user entity is not available."); return false; } user = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); charEntity = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); characterName = ((object)Unsafe.As(ref user.CharacterName)/*cast due to .constrained prefix*/).ToString(); if (charEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(charEntity)) { ctx.Reply("Target character entity not found: " + characterName + ""); return false; } return true; } private static bool TryGetClanEntity(User user, out Entity clanEntity) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: 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_005d: Unknown result type (might be due to invalid IL or missing references) clanEntity = Entity.Null; ref NetworkedEntity clanEntity2 = ref user.ClanEntity; object obj = NetworkedEntity.Empty; if (((object)Unsafe.As(ref clanEntity2)/*cast due to .constrained prefix*/).Equals(obj)) { return false; } clanEntity = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); int result; if (clanEntity != Entity.Null) { EntityManager entityManager = Core.EntityManager; result = (((EntityManager)(ref entityManager)).Exists(clanEntity) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } private static string GenerateUniqueClanName(string characterName) { string source = (string.IsNullOrWhiteSpace(characterName) ? "CLAN" : characterName); string text = new string(source.Where(char.IsLetterOrDigit).ToArray()); if (string.IsNullOrWhiteSpace(text)) { text = "CLAN"; } text = text.ToUpperInvariant(); string text2 = ((text.Length <= 4) ? text : text.Substring(0, 4)); string text3 = text2; int num = 2; Entity clanEntity; while (FindClan(text3, out clanEntity)) { text3 = $"{text2}{num}"; num++; if (num > 99) { return string.Empty; } } return text3; } private unsafe static bool FindClan(string clanName, out Entity clanEntity) { //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_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_0014: 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_0029: 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_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_006c: 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_0072: 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_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_00c3: 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) clanEntity = Entity.Null; EntityManager entityManager = Core.EntityManager; NativeArray val = default(NativeArray); try { val = Helper.GetEntitiesByComponentType(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(current) && ((EntityManager)(ref entityManager)).HasComponent(current)) { ClanTeam componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (string.Equals(((object)(*(FixedString64Bytes*)(&componentData.Name))/*cast due to .constrained prefix*/).ToString(), clanName, StringComparison.OrdinalIgnoreCase) && (!((EntityManager)(ref entityManager)).HasBuffer(current) || ((EntityManager)(ref entityManager)).GetBuffer(current, false).Length != 0)) { clanEntity = current; return true; } } } } finally { if (val.IsCreated) { val.Dispose(); } } return false; } private unsafe static string GetClanName(Entity clanEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (clanEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(clanEntity) || !((EntityManager)(ref entityManager)).HasComponent(clanEntity)) { return "Unknown"; } ClanTeam componentData = ((EntityManager)(ref entityManager)).GetComponentData(clanEntity); return ((object)(*(FixedString64Bytes*)(&componentData.Name))/*cast due to .constrained prefix*/).ToString(); } private static void RefreshClanTagOnCharacter(Entity userEntity, string clanName) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) //IL_0040: 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_004e: 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_005d: 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_007d: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a8: Unknown result type (might be due to invalid IL or missing references) try { EntityManager entityManager = Core.EntityManager; if (!(userEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).HasComponent(userEntity)) { User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); Entity entityOnServer = ((NetworkedEntity)(ref componentData.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(entityOnServer) && ((EntityManager)(ref entityManager)).HasComponent(entityOnServer)) { PlayerCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData(entityOnServer); componentData2.SmartClanName = (FixedString32Bytes)(string.IsNullOrWhiteSpace(clanName) ? default(FixedString32Bytes) : ClanUtility.GetSmartClanName(clanName)); ((EntityManager)(ref entityManager)).SetComponentData(entityOnServer, componentData2); } } } catch (Exception e) { Core.LogException(e, "RefreshClanTagOnCharacter"); } } private static void NotifyAdmin(Entity adminUserEntity, string message) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) try { EntityManager entityManager = Core.EntityManager; if (!(adminUserEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(adminUserEntity) && ((EntityManager)(ref entityManager)).HasComponent(adminUserEntity)) { Helper.NotifyUser(adminUserEntity, message); } } catch (Exception e) { Core.LogException(e, "NotifyAdmin"); } } public static void ReplyHelp(ChatCommandContext ctx) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Clan Commands:"); stringBuilder.AppendLine(".clan forcecreate or .c fc"); stringBuilder.AppendLine(".clan forcejoin or .c fj"); stringBuilder.AppendLine(".clan forceleave or .c fl"); ctx.Reply(stringBuilder.ToString().TrimEnd()); } } internal static class DailyKitService { public class DailyKitEntry { public int ItemPrefab { get; set; } public int Quantity { get; set; } } private static class CsvLogger { internal static void LogRow(ulong steamId, string playerName, string status) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); bool flag = !File.Exists(LOG_FILE); lock (LOG_LOCK) { using FileStream stream = new FileStream(LOG_FILE, FileMode.Append, FileAccess.Write, FileShare.Read); using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (flag) { streamWriter.WriteLine("time,steam_id,player_name,status"); } string value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); streamWriter.WriteLine($"{value},{steamId},{Helper.Csv(playerName)},{Helper.Csv(status)}"); } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Failed to write dailykit_log.csv: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string LOG_FILE = Path.Combine(CONFIG_DIR, "dailykit_log.csv"); private static readonly object LOG_LOCK = new object(); private static List _dailykitItems = new List(); public static void Initialize() { LoadConfig(); } public static void AddKit(ChatCommandContext ctx, int prefabGuid, int quantity) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); return; } PrefabGUID guid = default(PrefabGUID); ((PrefabGUID)(ref guid))..ctor(prefabGuid); string text = ResolveItemLabel(guid, prefabGuid.ToString()); DailyKitEntry dailyKitEntry = _dailykitItems.Find((DailyKitEntry i) => i.ItemPrefab == prefabGuid); bool flag = default(bool); if (dailyKitEntry != null) { dailyKitEntry.Quantity = quantity; ctx.Reply($"Updated daily kit item {text} to {quantity}."); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Updated daily kit item "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(quantity); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } else { _dailykitItems.Add(new DailyKitEntry { ItemPrefab = prefabGuid, Quantity = quantity }); ctx.Reply($"Added {text} ×{quantity} to the daily kit."); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Added "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(quantity); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to the daily kit."); } log2.LogInfo(val); } SaveToConfig(); } public static void RemoveKit(ChatCommandContext ctx, int prefabGuid) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown int num = _dailykitItems.RemoveAll((DailyKitEntry i) => i.ItemPrefab == prefabGuid); if (num > 0) { ctx.Reply($"Removed item {prefabGuid} from the daily kit."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Removed item "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from the daily kit."); } log.LogInfo(val); SaveToConfig(); } else { ctx.Reply($"Item not found in the daily kit: {prefabGuid}"); } } public static void ListKit(ChatCommandContext ctx) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); string value = (Plugin.dailyKitEnabled.Value ? "Enabled" : "Disabled"); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 1, stringBuilder2); handler.AppendLiteral("Daily Kit Status: "); handler.AppendFormatted(value); stringBuilder2.AppendLine(ref handler); if (_dailykitItems.Count == 0) { stringBuilder.AppendLine("(Empty)"); ctx.Reply(stringBuilder.ToString().TrimEnd()); return; } int num = 0; PrefabGUID guid = default(PrefabGUID); foreach (DailyKitEntry dailykitItem in _dailykitItems) { ((PrefabGUID)(ref guid))..ctor(dailykitItem.ItemPrefab); string value2 = ResolveItemLabel(guid, ((PrefabGUID)(ref guid)).GuidHash.ToString()); string text = $"{value2} ×{dailykitItem.Quantity}"; if (stringBuilder.Length + text.Length + Environment.NewLine.Length > 509) { break; } stringBuilder.AppendLine(text); num++; } int num2 = _dailykitItems.Count - num; if (num2 > 0) { string text2 = $"...and {num2} more item(s)."; if (stringBuilder.Length + text2.Length + Environment.NewLine.Length <= 509) { stringBuilder.AppendLine(text2); } else { string text3 = "..."; if (stringBuilder.Length + text3.Length + Environment.NewLine.Length <= 509) { stringBuilder.AppendLine(text3); } } } ctx.Reply(stringBuilder.ToString().TrimEnd()); } private static string ResolveItemLabel(PrefabGUID guid, string fallbackInput) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { string text = guid.LookupName(); if (text != "GUID Not Found") { int num = text.IndexOf(" PrefabGuid", StringComparison.Ordinal); if (num > 0) { return text.Substring(0, num); } return text; } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Failed to resolve item label: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return string.IsNullOrWhiteSpace(fallbackInput) ? ((PrefabGUID)(ref guid)).GuidHash.ToString() : fallbackInput; } public unsafe static void ClaimKit(ChatCommandContext ctx) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown if (!Plugin.dailyKitEnabled.Value) { ctx.Reply("Daily kit feature is currently disabled."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); ulong platformId = val.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(platformId); if (playerCache == null) { ctx.Reply("System is initializing your data. Please wait a few seconds and try again."); return; } string text2 = DateTime.Now.ToString("yyyy-MM-dd"); if (playerCache.LastDailyKitClaim == text2) { ctx.Reply("You have already claimed your daily kit today."); return; } if (_dailykitItems.Count == 0) { ctx.Reply("The daily kit is currently empty. Please contact an admin."); return; } int num = 0; PrefabGUID guid = default(PrefabGUID); foreach (DailyKitEntry dailykitItem in _dailykitItems) { if (dailykitItem.Quantity > 0) { try { ((PrefabGUID)(ref guid))..ctor(dailykitItem.ItemPrefab); Helper.AddItemToInventory(senderCharacterEntity, guid, dailykitItem.Quantity); num++; } catch (Exception e) { Core.LogException(e, "ClaimKit"); } } } bool flag = default(bool); if (num == 0) { ctx.Reply("Failed to give the daily kit. An error occurred."); ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DailyKit] Failed to give the daily kit to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogError(val2); CsvLogger.LogRow(platformId, text, "fail"); return; } playerCache.LastDailyKitClaim = text2; PlayerDataService.SaveData(); ctx.Reply("Successfully claimed your daily kit."); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DailyKit] "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has claimed a daily kit."); } log2.LogInfo(val3); CsvLogger.LogRow(platformId, text, "success"); } public static int ReloadConfig() { LoadConfig(); return _dailykitItems.Count; } private static void LoadConfig() { //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown _dailykitItems.Clear(); string value = Plugin.dailyKitItems.Value; if (string.IsNullOrWhiteSpace(value)) { return; } string[] array = value.Split(','); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (string.IsNullOrWhiteSpace(text)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Invalid config entry at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": empty entry."); } log.LogWarning(val); continue; } string[] array2 = text.Split(':'); if (array2.Length != 2) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(86, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Invalid config entry at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\". Expected format: ItemPrefab:Quantity"); } log2.LogWarning(val); continue; } string text2 = array2[0].Trim(); string text3 = array2[1].Trim(); int result2; if (!int.TryParse(text2, out var result)) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Invalid item prefab at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"."); } log3.LogWarning(val); } else if (!int.TryParse(text3, out result2)) { ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Invalid quantity at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"."); } log4.LogWarning(val); } else if (result2 <= 0) { ManualLogSource log5 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(76, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DailyKit] Invalid quantity at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Quantity must be greater than 0."); } log5.LogWarning(val); } else { _dailykitItems.Add(new DailyKitEntry { ItemPrefab = result, Quantity = result2 }); } } ManualLogSource log6 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DailyKit] Loaded "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_dailykitItems.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" item(s) from config."); } log6.LogInfo(val2); } private static void SaveToConfig() { List list = new List(); foreach (DailyKitEntry dailykitItem in _dailykitItems) { list.Add($"{dailykitItem.ItemPrefab}:{dailykitItem.Quantity}"); } Plugin.dailyKitItems.Value = string.Join(",", list); ((ConfigEntryBase)Plugin.dailyKitItems).ConfigFile.Save(); } } internal static class GiveService { public class GiveEntry { public int ItemPrefab { get; set; } public int Quantity { get; set; } } private static class CsvLogger { internal static void LogRow(string method, string setName, string targetName, int multiplier, string adminName) { try { lock (LOG_LOCK) { Directory.CreateDirectory(CONFIG_DIR); bool flag = !File.Exists(LOG_FILE); using FileStream stream = new FileStream(LOG_FILE, FileMode.Append, FileAccess.Write, FileShare.Read); using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (flag) { streamWriter.WriteLine("time,method,setname,target_player,multiplier,admin_name"); } string value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); streamWriter.WriteLine($"{value},{Helper.Csv(method)},{Helper.Csv(setName)},{Helper.Csv(targetName)},{multiplier},{Helper.Csv(adminName)}"); } } catch (Exception e) { Core.LogException(e, "LogRow"); } } } private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string CONFIG_FILE = Path.Combine(CONFIG_DIR, "gives.json"); private static readonly string LOG_FILE = Path.Combine(CONFIG_DIR, "give_log.csv"); private static readonly object LOG_LOCK = new object(); private static Dictionary> _giveSets = new Dictionary>(StringComparer.OrdinalIgnoreCase); private static bool _initialized = false; public static void Initialize() { if (!_initialized) { LoadConfig(); _initialized = true; } } public static void AddGiveItem(ChatCommandContext ctx, string setName, string itemPrefab, int quantity) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown if (!TryResolveItemGuid(itemPrefab, out var guid)) { ctx.Reply("Unknown item: " + itemPrefab); return; } setName = setName.Trim(); if (!_giveSets.TryGetValue(setName, out var value)) { value = new List(); _giveSets[setName] = value; } GiveEntry giveEntry = value.Find((GiveEntry x) => x.ItemPrefab == ((PrefabGUID)(ref guid)).GuidHash); if (giveEntry != null) { giveEntry.Quantity += quantity; } else { value.Add(new GiveEntry { ItemPrefab = ((PrefabGUID)(ref guid)).GuidHash, Quantity = quantity }); } SaveToDisk(); string text = ResolveItemLabel(guid, itemPrefab); ctx.Reply($"Added {text} ×{quantity} to give set {setName}."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Added "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(quantity); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(setName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } public static void RemoveGiveSet(ChatCommandContext ctx, string setName) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown setName = setName.Trim(); if (_giveSets.Remove(setName)) { SaveToDisk(); ctx.Reply("Removed give set " + setName + "."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Removed set "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(setName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } else { ctx.Reply("Give set not found: " + setName); } } public static void ListGiveSets(ChatCommandContext ctx) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (_giveSets.Count == 0) { ctx.Reply("No give sets found."); return; } PrefabGUID guid = default(PrefabGUID); foreach (KeyValuePair> giveSet in _giveSets) { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(34, 1, stringBuilder2); handler.AppendLiteral("Give set "); handler.AppendFormatted(giveSet.Key); handler.AppendLiteral(":\n"); stringBuilder2.Append(ref handler); List list = new List(); foreach (GiveEntry item in giveSet.Value) { ((PrefabGUID)(ref guid))..ctor(item.ItemPrefab); string value = ResolveItemLabel(guid, ((PrefabGUID)(ref guid)).GuidHash.ToString()); list.Add($"{value} ×{item.Quantity}"); } stringBuilder.Append(string.Join(", ", list)); ctx.Reply(stringBuilder.ToString()); } } public unsafe static void GiveToPlayer(ChatCommandContext ctx, string playerName, string setName, int multiplier) { //IL_0040: 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) //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_006a: 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_00cf: 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_00ef: Unknown result type (might be due to invalid IL or missing references) if (!VerifyAndGetSet(ctx, setName, multiplier, out var finalItems, out var descriptor)) { return; } if (!Helper.TryFindUserByName(playerName, out var userEntity, out var user, out var candidates)) { HandleFindPlayer(ctx, playerName, candidates); return; } if (!user.IsConnected) { ctx.Reply($"{user.CharacterName} is offline. Cannot send give."); return; } Entity entityOnServer = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (GiveItemsToCharacter(entityOnServer, finalItems)) { string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); User val = ctx.Event.SenderUserEntity.Read(); string adminName = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); Helper.NotifyUser(userEntity, "You received a give: " + descriptor + "."); ctx.Reply($"Gave {descriptor} to {text}."); CsvLogger.LogRow("player", setName, text, multiplier, adminName); } } public unsafe static void GiveToRadius(ChatCommandContext ctx, float radius, string setName, int multiplier) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) if (!VerifyAndGetSet(ctx, setName, multiplier, out var finalItems, out var descriptor)) { return; } Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = ctx.Event.SenderUserEntity.Read(); string adminName = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!Helper.TryFindUsersByRadius(senderCharacterEntity, radius, out List<(Entity, Entity, User, float)> players, 0uL)) { ctx.Reply($"No eligible players found within {radius:0.#}m."); return; } int num = 0; foreach (var item in players) { if (GiveItemsToCharacter(item.Item2, finalItems)) { num++; FixedString64Bytes characterName = item.Item3.CharacterName; string targetName = ((object)(*(FixedString64Bytes*)(&characterName))/*cast due to .constrained prefix*/).ToString(); Helper.NotifyUser(item.Item1, "You received a give: " + descriptor + "."); CsvLogger.LogRow("radius", setName, targetName, multiplier, adminName); } } if (num > 0) { ctx.Reply($"Gave {descriptor} to {num} players within {radius:0.#}m."); } else { ctx.Reply($"No eligible players found within {radius:0.#}m."); } } public unsafe static void GiveToClan(ChatCommandContext ctx, string playerName, string setName, int multiplier) { //IL_0040: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_00b0: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) if (!VerifyAndGetSet(ctx, setName, multiplier, out var finalItems, out var descriptor)) { return; } if (!Helper.TryFindUserByName(playerName, out var _, out var user, out var candidates)) { HandleFindPlayer(ctx, playerName, candidates); return; } Entity entity = user.ClanEntity._Entity; if (entity == Entity.Null) { ctx.Reply($"{user.CharacterName} is not in a clan."); return; } User val = ctx.Event.SenderUserEntity.Read(); string adminName = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); NativeArray entitiesByComponentType = Helper.GetEntitiesByComponentType(); int num = 0; try { Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User val2 = current.Read(); if (val2.IsConnected && !val2.IsAdmin && !(val2.ClanEntity._Entity != entity)) { Entity entityOnServer = ((NetworkedEntity)(ref val2.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null) && GiveItemsToCharacter(entityOnServer, finalItems)) { num++; string targetName = ((object)(*(FixedString64Bytes*)(&val2.CharacterName))/*cast due to .constrained prefix*/).ToString(); Helper.NotifyUser(current, "You received a give: " + descriptor + "."); CsvLogger.LogRow("clan", setName, targetName, multiplier, adminName); } } } } finally { if (entitiesByComponentType.IsCreated) { entitiesByComponentType.Dispose(); } } if (num > 0) { ctx.Reply($"Gave {descriptor} to {num} online members of {user.CharacterName}'s clan."); } else { ctx.Reply($"No eligible clan members found online for {user.CharacterName}."); } } public static void ReplyHelp(ChatCommandContext ctx) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Give Commands:"); stringBuilder.AppendLine(".pls give (multiplier)"); stringBuilder.AppendLine(".pls giveradius (multiplier)"); stringBuilder.AppendLine(".pls giveclan (multiplier)"); stringBuilder.AppendLine(".pls addgive "); stringBuilder.AppendLine(".pls removegive "); stringBuilder.AppendLine(".pls listgive"); ctx.Reply(stringBuilder.ToString().TrimEnd()); } private static bool VerifyAndGetSet(ChatCommandContext ctx, string setName, int multiplier, out List finalItems, out string descriptor) { finalItems = new List(); descriptor = string.Empty; if (!_giveSets.TryGetValue(setName, out var value) || value.Count == 0) { ctx.Reply("Give set not found or empty: " + setName + ""); return false; } foreach (GiveEntry item in value) { long num = (long)item.Quantity * (long)multiplier; if (num > 0) { finalItems.Add(new GiveEntry { ItemPrefab = item.ItemPrefab, Quantity = (int)Math.Clamp(num, 1L, 2147483647L) }); } } descriptor = ((multiplier > 1) ? $"{setName} ×{multiplier}" : setName); return true; } private static bool GiveItemsToCharacter(Entity character, List items) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //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_0029: Unknown result type (might be due to invalid IL or missing references) bool result = false; bool flag = default(bool); foreach (GiveEntry item in items) { try { Helper.AddItemToInventory(character, new PrefabGUID(item.ItemPrefab), item.Quantity); result = true; } catch (Exception ex) { ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Failed to give item to character: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } return result; } private static void HandleFindPlayer(ChatCommandContext ctx, string playerName, List candidates) { if (string.IsNullOrWhiteSpace(playerName) || playerName.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return; } playerName = playerName.Trim(); if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many players found for " + playerName + ". Please enter a more specific name."); } else { ctx.Reply("Multiple players matched " + playerName + ": " + string.Join(", ", candidates)); } } else { ctx.Reply("Player not found: " + playerName + ""); } } private static bool TryResolveItemGuid(string token, out PrefabGUID guid) { //IL_005e: 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) token = token?.Trim() ?? ""; if (token.StartsWith("Prefabs.", StringComparison.OrdinalIgnoreCase)) { token = token.Substring("Prefabs.".Length); } if (int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { guid = new PrefabGUID(result); return true; } guid = default(PrefabGUID); return false; } private static string ResolveItemLabel(PrefabGUID guid, string fallbackInput) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { string text = guid.LookupName(); if (text != "GUID Not Found") { int num = text.IndexOf(" PrefabGuid"); if (num > 0) { return text.Substring(0, num); } return text; } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Failed to resolve item label: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return string.IsNullOrWhiteSpace(fallbackInput) ? ((PrefabGUID)(ref guid)).GuidHash.ToString() : fallbackInput; } private static void EnsureConfigFileExists() { if (!File.Exists(CONFIG_FILE)) { File.WriteAllText(CONFIG_FILE, GetDefaultJson(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); } } public static bool ReloadConfig(out int setCount) { bool result = LoadConfig(); setCount = _giveSets.Count; return result; } private static bool LoadConfig() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); EnsureConfigFileExists(); string json = File.ReadAllText(CONFIG_FILE, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); Dictionary> dictionary = JsonSerializer.Deserialize>>(json); _giveSets.Clear(); if (dictionary != null) { foreach (KeyValuePair> item in dictionary) { _giveSets[item.Key] = item.Value ?? new List(); } } return true; } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Failed to reload gives.json: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return false; } private static void SaveToDisk() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); string contents = JsonSerializer.Serialize(_giveSets, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(CONFIG_FILE, contents, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Give] Failed to save gives.json: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static string GetDefaultJson() { Dictionary> value = new Dictionary>(StringComparer.OrdinalIgnoreCase) { ["Potion"] = new List { new GiveEntry { ItemPrefab = 429052660, Quantity = 10 }, new GiveEntry { ItemPrefab = 800879747, Quantity = 10 } }, ["Buff"] = new List { new GiveEntry { ItemPrefab = 1510182325, Quantity = 1 }, new GiveEntry { ItemPrefab = -1568756102, Quantity = 1 }, new GiveEntry { ItemPrefab = 541321301, Quantity = 1 }, new GiveEntry { ItemPrefab = -38051433, Quantity = 1 }, new GiveEntry { ItemPrefab = 970650569, Quantity = 1 } } }; return JsonSerializer.Serialize(value, new JsonSerializerOptions { WriteIndented = true }); } } internal static class PlayerDataService { private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string CONFIG_FILE = Path.Combine(CONFIG_DIR, "player_data.json"); private static readonly string BACKUP_FILE = CONFIG_FILE + ".bak"; private static float SCAN_INTERVAL = 10f; private static readonly TimeSpan PROFILE_SAVE_INTERVAL = TimeSpan.FromSeconds(60.0); private static Dictionary _cache = new Dictionary(); private static DateTime _lastProfileSaveTime = DateTime.MinValue; private static bool _profileDirty = false; private static bool _isInitialized = false; private static bool _saveDisabledDueToLoadFailure = false; private static bool _skipBackupCopyOnNextSave = false; public static void Initialize() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (!_isInitialized) { Directory.CreateDirectory(CONFIG_DIR); LoadData(); Core.StartCoroutine(MonitorPlayersCoroutine()); _isInitialized = true; ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerData] Initialized and loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_cache.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player(s)."); } log.LogInfo(val); } } private static IEnumerator MonitorPlayersCoroutine() { while (true) { try { MonitorPlayersTick(); } catch (Exception ex) { Exception e = ex; Core.LogException(e, "MonitorPlayersCoroutine"); } yield return (object)new WaitForSeconds(SCAN_INTERVAL); } } private static void MonitorPlayersTick() { Dictionary> ownerRegionMap = BuildOwnerRegionMap(); if (UpdatePlayerCaches(ownerRegionMap)) { MarkProfileDirty(); } SaveProfileIfNeeded(); } private static bool UpdatePlayerCaches(Dictionary> ownerRegionMap) { //IL_0008: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003d: 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_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_006c: 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) bool result = false; NativeArray entitiesByComponentType = Helper.GetEntitiesByComponentType(); try { Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(current)) { User val = current.Read(); if (val.PlatformId != 0 && UpdatePlayerCacheFromUser(current, val, ownerRegionMap)) { result = true; } } } } finally { if (entitiesByComponentType.IsCreated) { entitiesByComponentType.Dispose(); } } return result; } private unsafe static bool UpdatePlayerCacheFromUser(Entity userEntity, User user, Dictionary> ownerRegionMap) { //IL_0003: 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_00b3: Unknown result type (might be due to invalid IL or missing references) bool result = false; ulong platformId = user.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); ownerRegionMap.TryGetValue(userEntity, out var value); if (value == null) { value = new Dictionary(); } if (!_cache.TryGetValue(platformId, out var value2)) { if (Plugin.onlyWhitelistEnable.Value) { return false; } value2 = new PlayerCacheData { SteamID = platformId, KnownAs = string.Empty, IsWhitelisted = false }; _cache[platformId] = value2; result = true; } if (value2.InGameName != text) { value2.InGameName = text; result = true; } int currentPlayerLevel = GetCurrentPlayerLevel(user, value2.CurrentLevel); if (value2.CurrentLevel != currentPlayerLevel) { value2.CurrentLevel = currentPlayerLevel; result = true; } if (currentPlayerLevel > value2.MaxLevel) { value2.MaxLevel = currentPlayerLevel; result = true; } if (!DictionariesEqual(value2.CastleRegions, value)) { value2.CastleRegions = value; result = true; } return result; } private static int GetCurrentPlayerLevel(User user, int fallbackLevel) { //IL_0008: 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_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(entityOnServer)) { entityManager = Core.EntityManager; Equipment componentData = ((EntityManager)(ref entityManager)).GetComponentData(entityOnServer); return Mathf.RoundToInt(ModifiableFloat.op_Implicit(componentData.ArmorLevel) + ModifiableFloat.op_Implicit(componentData.SpellLevel) + ModifiableFloat.op_Implicit(componentData.WeaponLevel)); } } } return fallbackLevel; } private unsafe static Dictionary> BuildOwnerRegionMap() { //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_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_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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0047: 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_0056: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007d: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c0: 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_00d7: 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_00ec: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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) Dictionary> dictionary = new Dictionary>(); NativeArray entitiesByComponentType = Helper.GetEntitiesByComponentType(); try { Enumerator enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current)) { continue; } CastleTerritory val = current.Read(); if (((Entity)(ref val.CastleHeart)).Equals(Entity.Null)) { continue; } Entity castleHeart = val.CastleHeart; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(castleHeart)) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent(castleHeart)) { continue; } UserOwner val2 = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val2.Owner)).GetEntityOnServer(); if (((Entity)(ref entityOnServer)).Equals(Entity.Null)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(current)) { TerritoryWorldRegion val3 = current.Read(); string key = ((object)(*(WorldRegionType*)(&val3.Region))/*cast due to .constrained prefix*/).ToString(); if (!dictionary.TryGetValue(entityOnServer, out var value)) { value = (dictionary[entityOnServer] = new Dictionary(StringComparer.OrdinalIgnoreCase)); } value.TryGetValue(key, out var value2); value[key] = value2 + 1; } } } finally { if (entitiesByComponentType.IsCreated) { entitiesByComponentType.Dispose(); } } return dictionary; } private static bool DictionariesEqual(Dictionary dict1, Dictionary dict2) { if (dict1 == dict2) { return true; } if (dict1 == null || dict2 == null) { return false; } if (dict1.Count != dict2.Count) { return false; } foreach (KeyValuePair item in dict1) { if (!dict2.TryGetValue(item.Key, out var value) || value != item.Value) { return false; } } return true; } public static IEnumerable GetAllPlayerCaches() { return _cache.Values; } public static PlayerCacheData GetPlayerCache(ulong steamId) { PlayerCacheData value; return _cache.TryGetValue(steamId, out value) ? value : null; } public static PlayerCacheData GetOrCreatePlayerCache(ulong steamId) { if (!_cache.TryGetValue(steamId, out var value)) { value = new PlayerCacheData { SteamID = steamId, InGameName = string.Empty, KnownAs = string.Empty, LastDailyKitClaim = string.Empty, IsBanned = false, IsWhitelisted = false }; _cache[steamId] = value; } return value; } public static PlayerCacheData GetPlayerCacheByName(string inGameName) { foreach (PlayerCacheData value in _cache.Values) { if (!string.IsNullOrEmpty(value.InGameName) && string.Equals(value.InGameName, inGameName, StringComparison.OrdinalIgnoreCase)) { return value; } } return null; } public static List GetBannedPlayers() { List list = new List(); foreach (PlayerCacheData value in _cache.Values) { if (value.IsBanned) { list.Add(value); } } return list; } public static void RemovePlayerCache(ulong steamId) { if (_cache.ContainsKey(steamId)) { _cache.Remove(steamId); SaveData(); } } public unsafe static void RecordDisconnectedUser(User user) { //IL_0001: 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_003e: 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_00b3: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (user.PlatformId == 0) { return; } PlayerCacheData playerCacheData = GetPlayerCache(user.PlatformId); if (playerCacheData == null) { if (Plugin.onlyWhitelistEnable.Value) { return; } playerCacheData = GetOrCreatePlayerCache(user.PlatformId); } string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text) && playerCacheData.InGameName != text) { playerCacheData.InGameName = text; } playerCacheData.LastOnlineTicks = DateTime.UtcNow.Ticks; SaveNow(); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(65, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Disconnected] Player disconnected: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") | LastOnlineTicks updated"); } log.LogInfo(val); } public static TimeSpan GetTimeSinceLastOnline(long lastOnlineUtcTicks) { if (lastOnlineUtcTicks <= 0) { return TimeSpan.Zero; } try { DateTime dateTime = new DateTime(lastOnlineUtcTicks, DateTimeKind.Utc); TimeSpan timeSpan = DateTime.UtcNow - dateTime; if (timeSpan < TimeSpan.Zero) { return TimeSpan.Zero; } return timeSpan; } catch { return TimeSpan.Zero; } } public static bool TryFindPlayerCacheByPlayerName(string query, out PlayerCacheData cacheData, out List candidates) { cacheData = null; candidates = null; List source = _cache.Values.Where((PlayerCacheData c) => !string.IsNullOrWhiteSpace(c.InGameName)).ToList(); List list = source.Where((PlayerCacheData x) => string.Equals(x.InGameName, query, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 1) { cacheData = list[0]; return true; } List list2 = source.Where((PlayerCacheData x) => x.InGameName.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); if (list2.Count == 1) { cacheData = list2[0]; return true; } if (list2.Count > 1) { candidates = list2.Select((PlayerCacheData x) => x.InGameName).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string n) => n, StringComparer.OrdinalIgnoreCase) .ToList(); } return false; } public static bool TryFindPlayersCacheByKnownAs(string query, out List matchedProfiles, out List candidates) { matchedProfiles = null; candidates = null; List source = _cache.Values.Where((PlayerCacheData c) => !string.IsNullOrWhiteSpace(c.KnownAs)).ToList(); List list = (from x in source where string.Equals(x.KnownAs, query, StringComparison.OrdinalIgnoreCase) select x.KnownAs).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); if (list.Count == 1) { string exactName = list[0]; matchedProfiles = source.Where((PlayerCacheData x) => string.Equals(x.KnownAs, exactName, StringComparison.OrdinalIgnoreCase)).ToList(); return true; } List list2 = (from x in source where x.KnownAs.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0 select x.KnownAs).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); if (list2.Count == 1) { string partialName = list2[0]; matchedProfiles = source.Where((PlayerCacheData x) => string.Equals(x.KnownAs, partialName, StringComparison.OrdinalIgnoreCase)).ToList(); return true; } if (list2.Count > 1) { candidates = list2.OrderBy((string n) => n, StringComparer.OrdinalIgnoreCase).ToList(); } return false; } private static void LoadData() { _saveDisabledDueToLoadFailure = false; _skipBackupCopyOnNextSave = false; if (TryLoadPlayerData(CONFIG_FILE, out var data)) { _cache = data; return; } if (File.Exists(CONFIG_FILE)) { Core.Log.LogWarning((object)"[PlayerData] Failed to load player_data.json. Trying backup file."); } if (TryLoadPlayerData(BACKUP_FILE, out data)) { _cache = data; Core.Log.LogWarning((object)"[PlayerData] Loaded player data from player_data.json.bak."); _skipBackupCopyOnNextSave = !RestoreBackupToPrimaryFile(); } else if (File.Exists(CONFIG_FILE) || File.Exists(BACKUP_FILE)) { _saveDisabledDueToLoadFailure = true; Core.Log.LogError((object)"[PlayerData] Failed to load both player_data.json and player_data.json.bak. Automatic saving is disabled to avoid overwriting existing data."); } } private static bool TryLoadPlayerData(string path, out Dictionary data) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown data = null; if (!File.Exists(path)) { return false; } bool flag = default(bool); try { string json = File.ReadAllText(path); data = JsonSerializer.Deserialize>(json); if (data == null) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerData] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Path.GetFileName(path)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" contained no player data."); } log.LogWarning(val); return false; } return true; } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerData] Failed to read "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Path.GetFileName(path)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log2.LogWarning(val); return false; } } private static bool RestoreBackupToPrimaryFile() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); File.Copy(BACKUP_FILE, CONFIG_FILE, overwrite: true); Core.Log.LogWarning((object)"[PlayerData] Restored player_data.json from backup."); return true; } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(81, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerData] Loaded backup successfully, but failed to restore player_data.json: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return false; } } public static void SaveData() { if (_saveDisabledDueToLoadFailure) { Core.Log.LogError((object)"[PlayerData] Save skipped because player data failed to load. Fix player_data.json or player_data.json.bak, then restart or reload the plugin."); return; } try { Directory.CreateDirectory(CONFIG_DIR); JsonSerializerOptions options = new JsonSerializerOptions { WriteIndented = true }; string contents = JsonSerializer.Serialize(_cache, options); string text = CONFIG_FILE + ".tmp"; File.WriteAllText(text, contents); if (File.Exists(CONFIG_FILE) && !_skipBackupCopyOnNextSave) { File.Copy(CONFIG_FILE, BACKUP_FILE, overwrite: true); } else if (_skipBackupCopyOnNextSave) { Core.Log.LogWarning((object)"[PlayerData] Skipped backup copy this save because the primary file was not trusted after loading from backup."); } File.Move(text, CONFIG_FILE, overwrite: true); _skipBackupCopyOnNextSave = false; _profileDirty = false; _lastProfileSaveTime = DateTime.Now; } catch (Exception e) { Core.LogException(e, "SaveData"); } } private static void MarkProfileDirty() { _profileDirty = true; } private static void SaveProfileIfNeeded() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (_profileDirty && !(DateTime.Now - _lastProfileSaveTime < PROFILE_SAVE_INTERVAL)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerData] Saving scheduled player data for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_cache.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player(s)."); } log.LogInfo(val); SaveData(); } } public static void ForceSaveIfDirty() { if (_profileDirty) { SaveData(); } } public static void SaveNow() { SaveData(); } } internal static class PlayerInfoService { private const int MEMBERS_PER_REPLY = 4; public static bool TryGetPlayerInfo(ChatCommandContext ctx, string player) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.pisCommandEnabled.Value) { ctx.Reply("This command is currently disabled."); return false; } if (string.IsNullOrWhiteSpace(player) || player.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return false; } string text = player.Trim(); if (!Helper.TryFindUserByName(text, out var userEntity, out var user, out var candidates)) { if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many players found for " + text + ". Please enter a more specific name."); } else { ctx.Reply("Multiple players matched " + text + ": " + string.Join(", ", candidates)); } return false; } ctx.Reply("No player found matching " + text + ""); return false; } BuildPlayerInfo(ctx, userEntity, user); return true; } private unsafe static void BuildPlayerInfo(ChatCommandContext ctx, Entity userEntity, User user) { //IL_0008: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00b6: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); string targetName = Helper.TrimName(((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString()); PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(user.PlatformId); int maxLevel = playerCache?.MaxLevel ?? 0; int currentLevel = playerCache?.CurrentLevel ?? 0; Dictionary dictionary = playerCache?.CastleRegions; int castleCount = dictionary?.Values.Sum() ?? 0; bool isAdmin = ctx.Event.User.IsAdmin; bool showClanCastleInfo = Plugin.playerInfoShowClanCastleInfo.Value || isAdmin; bool showClanMemberLastOnline = Plugin.playerInfoShowClanMemberLastOnline.Value || isAdmin; if (((Entity)(ref entityOnServer)).Equals(Entity.Null)) { HandleSoloPlayer(ctx, user, targetName, maxLevel, currentLevel, castleCount, dictionary, showClanCastleInfo, showClanMemberLastOnline); } else { HandleClanPlayer(ctx, user, entityOnServer, targetName, maxLevel, currentLevel, castleCount, showClanCastleInfo, showClanMemberLastOnline); } } private static void HandleSoloPlayer(ChatCommandContext ctx, User user, string targetName, int maxLevel, int currentLevel, int castleCount, Dictionary castleRegions, bool showClanCastleInfo, bool showClanMemberLastOnline) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) string value = "" + targetName + " - Solo Player"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(value); string text = $"Max Level: {maxLevel} | Current Level: {currentLevel}"; if (showClanCastleInfo) { text += $" | Castles Owned: {castleCount}"; } stringBuilder.AppendLine(text); if (showClanCastleInfo) { stringBuilder.AppendLine(FormatRegionCounts(castleRegions, castleCount, isClan: false)); } stringBuilder.AppendLine(FormatUserLine(user, showClanMemberLastOnline)); ctx.Reply(stringBuilder.ToString()); } private unsafe static void HandleClanPlayer(ChatCommandContext ctx, User user, Entity clanEntity, string targetName, int maxLevel, int currentLevel, int castleCount, bool showClanCastleInfo, bool showClanMemberLastOnline) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0025: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) ClanTeam val = clanEntity.Read(); string text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(clanEntity, false); List<(Entity, User)> sortedClanMembers = GetSortedClanMembers(buffer); Dictionary dictionary = null; int totalCount = 0; if (showClanCastleInfo) { dictionary = CalculateClanCastleCounts(sortedClanMembers); totalCount = dictionary.Values.Sum(); } string value = $"{targetName} - Member of Clan {text}"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(value); string text2 = $"Max Level: {maxLevel} | Current Level: {currentLevel}"; if (showClanCastleInfo) { text2 += $" | Castles Owned: {castleCount}"; } stringBuilder.AppendLine(text2); if (showClanCastleInfo) { stringBuilder.AppendLine(FormatRegionCounts(dictionary, totalCount, isClan: true)); } StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(16, 1, stringBuilder2); handler.AppendLiteral("Clan Members ("); handler.AppendFormatted(sortedClanMembers.Count); handler.AppendLiteral("):"); stringBuilder2.AppendLine(ref handler); foreach (var item in sortedClanMembers.Take(4)) { stringBuilder.AppendLine(FormatUserLine(item.Item2, showClanMemberLastOnline)); } ctx.Reply(stringBuilder.ToString()); if (sortedClanMembers.Count > 4) { SendRemainingMembers(ctx, sortedClanMembers.Skip(4).ToList(), text, showClanMemberLastOnline); } } private static void SendRemainingMembers(ChatCommandContext ctx, List<(Entity userEnt, User usr)> remainingMembers, string clanName, bool showClanMemberLastOnline) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < remainingMembers.Count; i++) { if (i % 4 == 0) { StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(44, 1, stringBuilder2); handler.AppendLiteral("More Members of Clan "); handler.AppendFormatted(clanName); handler.AppendLiteral(""); stringBuilder2.AppendLine(ref handler); } stringBuilder.AppendLine(FormatUserLine(remainingMembers[i].usr, showClanMemberLastOnline)); if ((i + 1) % 4 == 0 || i == remainingMembers.Count - 1) { ctx.Reply(stringBuilder.ToString()); stringBuilder.Clear(); } } } private unsafe static string FormatUserLine(User usr, bool showClanMemberLastOnline) { //IL_001b: 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_0066: Unknown result type (might be due to invalid IL or missing references) string text = Helper.TrimName(((object)(*(FixedString64Bytes*)(&usr.CharacterName))/*cast due to .constrained prefix*/).ToString()); string value = (usr.IsConnected ? ("" + text + "") : ("" + text + "")); PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(usr.PlatformId); int value2 = playerCache?.MaxLevel ?? 0; string value3 = ""; if (!usr.IsConnected && showClanMemberLastOnline && playerCache != null && playerCache.LastOnlineTicks > 0) { TimeSpan timeSinceLastOnline = PlayerDataService.GetTimeSinceLastOnline(playerCache.LastOnlineTicks); value3 = " (" + FormatTimeAgo(timeSinceLastOnline) + ")"; } return $"[{value2}] {value}{value3}"; } private static string FormatTimeAgo(TimeSpan span) { List list = new List(); if (span.Days > 0) { list.Add($"{span.Days}d"); } if (span.Hours > 0) { list.Add($"{span.Hours}h"); } if (span.Minutes > 0) { list.Add($"{span.Minutes}m"); } return (list.Count == 0) ? "just now" : (string.Join(" ", list) + " ago"); } private static string FormatRegionCounts(Dictionary counts, int totalCount, bool isClan) { string value = ((totalCount == 1) ? "Castle" : "Castles"); string value2 = (isClan ? "Clan" : "Player"); string text = $"{value2} {value} ({totalCount}):"; if (counts == null || counts.Count == 0 || totalCount == 0) { return text + " (None)"; } IEnumerable values = counts.OrderBy, string>((KeyValuePair kv) => kv.Key, StringComparer.OrdinalIgnoreCase).Select(delegate(KeyValuePair kv) { string shortName = CastleTerritoryData.GetShortName(kv.Key); return $"{shortName} ({kv.Value})"; }); return text + " " + string.Join(", ", values); } private static List<(Entity userEnt, User usr)> GetSortedClanMembers(DynamicBuffer userBuffer) { //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) //IL_0019: 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_001c: 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) List<(Entity, User)> list = new List<(Entity, User)>(); for (int i = 0; i < userBuffer.Length; i++) { Entity userEntity = userBuffer[i].UserEntity; list.Add((userEntity, userEntity.Read())); } return (from m in list orderby m.usr.IsConnected descending, m.usr.TimeLastConnected descending select m).ToList(); } private static Dictionary CalculateClanCastleCounts(List<(Entity userEnt, User usr)> members) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var member in members) { PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(member.usr.PlatformId); if (playerCache == null || playerCache.CastleRegions == null) { continue; } foreach (KeyValuePair castleRegion in playerCache.CastleRegions) { dictionary.TryGetValue(castleRegion.Key, out var value); dictionary[castleRegion.Key] = value + castleRegion.Value; } } return dictionary; } } internal static class PlayerProfileService { public static void CheckByPlayerName(ChatCommandContext ctx, string targetInput) { if (TryGetPlayerCache(ctx, targetInput, out var cache)) { string value = (string.IsNullOrWhiteSpace(cache.KnownAs) ? "Not Set" : ("" + cache.KnownAs + "")); string value2 = (string.IsNullOrWhiteSpace(cache.InGameName) ? "Unknown" : ("" + cache.InGameName + "")); string value3 = (cache.IsBanned ? "Yes" : "No"); string value4 = (cache.IsWhitelisted ? "Yes" : "No"); StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(38, 1, stringBuilder2); handler.AppendLiteral("Player Profile: "); handler.AppendFormatted(value2); stringBuilder3.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(9, 1, stringBuilder2); handler.AppendLiteral("SteamID: "); handler.AppendFormatted(cache.SteamID); stringBuilder4.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(14, 1, stringBuilder2); handler.AppendLiteral("In-Game Name: "); handler.AppendFormatted(value2); stringBuilder5.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder6 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(10, 1, stringBuilder2); handler.AppendLiteral("Known As: "); handler.AppendFormatted(value); stringBuilder6.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder7 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(8, 1, stringBuilder2); handler.AppendLiteral("Banned: "); handler.AppendFormatted(value3); stringBuilder7.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder8 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(13, 1, stringBuilder2); handler.AppendLiteral("Whitelisted: "); handler.AppendFormatted(value4); stringBuilder8.AppendLine(ref handler); ctx.Reply(stringBuilder.ToString().TrimEnd()); } } public static void CheckByKnownAs(ChatCommandContext ctx, string knownAsQuery) { if (string.IsNullOrWhiteSpace(knownAsQuery) || knownAsQuery.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return; } knownAsQuery = knownAsQuery.Trim(); if (!PlayerDataService.TryFindPlayersCacheByKnownAs(knownAsQuery, out var matchedProfiles, out var candidates)) { if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many Known As found for " + knownAsQuery + ". Please enter a more specific name."); } else { ctx.Reply("Multiple Known As matched " + knownAsQuery + ": " + string.Join(", ", candidates)); } } else { ctx.Reply("No players found with Known As matching: " + knownAsQuery + ""); } return; } string knownAs = matchedProfiles[0].KnownAs; StringBuilder stringBuilder = new StringBuilder(); string value = ((matchedProfiles.Count == 1) ? "Player Profile" : "Player Profiles"); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(61, 3, stringBuilder2); handler.AppendLiteral(""); handler.AppendFormatted(value); handler.AppendLiteral(" ("); handler.AppendFormatted(matchedProfiles.Count); handler.AppendLiteral(") for Known As: "); handler.AppendFormatted(knownAs); handler.AppendLiteral(""); stringBuilder3.AppendLine(ref handler); int num = 1; foreach (PlayerCacheData item in matchedProfiles) { string value2 = (string.IsNullOrWhiteSpace(item.InGameName) ? "Unknown" : ("" + item.InGameName + "")); string text = ""; if (item.IsBanned) { text += " | Banned"; } if (item.IsWhitelisted) { text += " | Whitelisted"; } stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(72, 4, stringBuilder2); handler.AppendLiteral("["); handler.AppendFormatted(num); handler.AppendLiteral("] "); handler.AppendLiteral("SteamID: "); handler.AppendFormatted(item.SteamID); handler.AppendLiteral(" | "); handler.AppendLiteral("In-Game Name: "); handler.AppendFormatted(value2); handler.AppendFormatted(text); stringBuilder4.AppendLine(ref handler); num++; } ctx.Reply(stringBuilder.ToString().TrimEnd()); } public static void SetKnownAs(ChatCommandContext ctx, string targetInput, string knownAs) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if (TryGetPlayerCache(ctx, targetInput, out var cache, createIfMissing: true)) { cache.KnownAs = knownAs.Trim(); PlayerDataService.SaveData(); string text = (string.IsNullOrWhiteSpace(cache.InGameName) ? $"SteamID: {cache.SteamID}" : cache.InGameName); ctx.Reply($"Set Known As for {text} to {cache.KnownAs}."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerProfile] Set Known As for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(cache.KnownAs); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(cache.SteamID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } } public static void RemoveKnownAs(ChatCommandContext ctx, string targetInput) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if (TryGetPlayerCache(ctx, targetInput, out var cache)) { cache.KnownAs = string.Empty; if (string.IsNullOrWhiteSpace(cache.InGameName) && !cache.IsBanned && !cache.IsWhitelisted && cache.LastOnlineTicks == 0) { PlayerDataService.RemovePlayerCache(cache.SteamID); } else { PlayerDataService.SaveData(); } string text = (string.IsNullOrWhiteSpace(cache.InGameName) ? $"SteamID: {cache.SteamID}" : cache.InGameName); ctx.Reply("Removed Known As for " + text + "."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PlayerProfile] Removed Known As for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(cache.SteamID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } } private static bool TryGetPlayerCache(ChatCommandContext ctx, string query, out PlayerCacheData cache, bool createIfMissing = false) { cache = null; if (string.IsNullOrWhiteSpace(query) || query.Trim().Length < 2) { ctx.Reply("Please enter at least 2 characters."); return false; } query = query.Trim(); if (ulong.TryParse(query, out var result)) { cache = (createIfMissing ? PlayerDataService.GetOrCreatePlayerCache(result) : PlayerDataService.GetPlayerCache(result)); if (cache == null) { ctx.Reply("Player not found in history: " + query + ""); return false; } return true; } if (PlayerDataService.TryFindPlayerCacheByPlayerName(query, out cache, out var candidates)) { return true; } if (candidates != null && candidates.Count > 0) { if (candidates.Count > 10) { ctx.Reply("Too many players found for " + query + ". Please enter a more specific name."); } else { ctx.Reply("Multiple players matched " + query + ": " + string.Join(", ", candidates)); } } else { ctx.Reply("Player not found in history: " + query + ""); } return false; } public static void ReplyHelp(ChatCommandContext ctx) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Player Profile Commands:"); stringBuilder.AppendLine(".pls checkplayer "); stringBuilder.AppendLine(".pls checkknownas "); stringBuilder.AppendLine(".pls addknownas "); stringBuilder.AppendLine(".pls removeknownas "); ctx.Reply(stringBuilder.ToString().TrimEnd()); } } internal static class StarterKitService { public class StarterKitEntry { public int ItemPrefab { get; set; } public int Quantity { get; set; } } private static class CsvLogger { internal static void LogRow(ulong steamId, string playerName, string status) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); bool flag = !File.Exists(LOG_FILE); lock (LOG_LOCK) { using FileStream stream = new FileStream(LOG_FILE, FileMode.Append, FileAccess.Write, FileShare.Read); using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (flag) { streamWriter.WriteLine("time,steam_id,player_name,status"); } string value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); streamWriter.WriteLine($"{value},{steamId},{Helper.Csv(playerName)},{Helper.Csv(status)}"); } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Failed to write starterkit_log.csv: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string LOG_FILE = Path.Combine(CONFIG_DIR, "starterkit_log.csv"); private static readonly object LOG_LOCK = new object(); private static List _starterItems = new List(); public static void Initialize() { LoadConfig(); } public unsafe static void GiveKit(Entity userEntity, User user) { //IL_0019: 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_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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) if (!Plugin.starterKitEnabled.Value || user.PlatformId == 0) { return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(user.PlatformId); if (orCreatePlayerCache.HasReceivedStarterKit) { return; } EntityManager entityManager = Core.EntityManager; Entity entityOnServer = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (((Entity)(ref entityOnServer)).Equals(Entity.Null) || !((EntityManager)(ref entityManager)).Exists(entityOnServer) || _starterItems.Count == 0) { return; } int num = 0; PrefabGUID guid = default(PrefabGUID); foreach (StarterKitEntry starterItem in _starterItems) { if (starterItem.Quantity > 0) { try { ((PrefabGUID)(ref guid))..ctor(starterItem.ItemPrefab); Helper.AddItemToInventory(entityOnServer, guid, starterItem.Quantity); num++; } catch (Exception e) { Core.LogException(e, "GiveKit"); } } } string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); bool flag = default(bool); if (num > 0) { orCreatePlayerCache.HasReceivedStarterKit = true; PlayerDataService.SaveData(); Helper.NotifyUser(userEntity, "You have received your Starter Kit."); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Starter Kit auto-granted to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); CsvLogger.LogRow(user.PlatformId, text, "success_auto"); } else { Helper.NotifyUser(userEntity, "Failed to auto-grant the Starter Kit. Please try .pls sk to claim your Starter Kit."); ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(52, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StarterKit] Failed to auto-grant Starter Kit to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } log2.LogError(val2); CsvLogger.LogRow(user.PlatformId, text, "fail_auto"); } } public unsafe static void ClaimKit(ChatCommandContext ctx) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown if (!Plugin.starterKitEnabled.Value) { ctx.Reply("Starter kit feature is currently disabled."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); ulong platformId = val.PlatformId; string text = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(platformId); if (playerCache == null) { ctx.Reply("System is initializing your data. Please wait a few seconds and try again."); return; } if (playerCache.HasReceivedStarterKit) { ctx.Reply("You have already claimed your starter kit."); return; } if (_starterItems.Count == 0) { ctx.Reply("The starter kit is currently empty. Please contact an admin."); return; } int num = 0; PrefabGUID guid = default(PrefabGUID); foreach (StarterKitEntry starterItem in _starterItems) { if (starterItem.Quantity > 0) { try { ((PrefabGUID)(ref guid))..ctor(starterItem.ItemPrefab); Helper.AddItemToInventory(senderCharacterEntity, guid, starterItem.Quantity); num++; } catch (Exception e) { Core.LogException(e, "ClaimKit"); } } } if (num > 0) { playerCache.HasReceivedStarterKit = true; PlayerDataService.SaveData(); ctx.Reply("Successfully claimed your starter kit."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StarterKit] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" manually claimed the Starter Kit."); } log.LogInfo(val2); CsvLogger.LogRow(platformId, text, "success_manual"); } else { ctx.Reply("Failed to give the starter kit."); CsvLogger.LogRow(platformId, text, "fail_manual"); } } public static void AddKit(ChatCommandContext ctx, int prefabGuid, int quantity) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); return; } PrefabGUID guid = default(PrefabGUID); ((PrefabGUID)(ref guid))..ctor(prefabGuid); string text = ResolveItemLabel(guid, prefabGuid.ToString()); StarterKitEntry starterKitEntry = _starterItems.Find((StarterKitEntry i) => i.ItemPrefab == prefabGuid); bool flag = default(bool); if (starterKitEntry != null) { starterKitEntry.Quantity = quantity; ctx.Reply($"Updated starter kit item {text} to {quantity}."); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Updated starter kit item "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(quantity); } log.LogInfo(val); } else { _starterItems.Add(new StarterKitEntry { ItemPrefab = prefabGuid, Quantity = quantity }); ctx.Reply($"Added {text} ×{quantity} to the starter kit."); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Added "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(quantity); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to the starter kit."); } log2.LogInfo(val); } SaveToConfig(); } public static void RemoveKit(ChatCommandContext ctx, int prefabGuid) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown int num = _starterItems.RemoveAll((StarterKitEntry i) => i.ItemPrefab == prefabGuid); if (num > 0) { ctx.Reply($"Removed item {prefabGuid} from the starter kit."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Removed item "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(prefabGuid); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from the starter kit."); } log.LogInfo(val); SaveToConfig(); } else { ctx.Reply($"Item not found in the starter kit: {prefabGuid}"); } } public static void ListKit(ChatCommandContext ctx) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); string value = (Plugin.starterKitEnabled.Value ? "Enabled" : "Disabled"); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(20, 1, stringBuilder2); handler.AppendLiteral("Starter Kit Status: "); handler.AppendFormatted(value); stringBuilder2.AppendLine(ref handler); if (_starterItems.Count == 0) { stringBuilder.AppendLine("(Empty)"); ctx.Reply(stringBuilder.ToString().TrimEnd()); return; } int num = 0; PrefabGUID guid = default(PrefabGUID); foreach (StarterKitEntry starterItem in _starterItems) { ((PrefabGUID)(ref guid))..ctor(starterItem.ItemPrefab); string value2 = ResolveItemLabel(guid, ((PrefabGUID)(ref guid)).GuidHash.ToString()); string text = $"{value2} ×{starterItem.Quantity}"; if (stringBuilder.Length + text.Length + Environment.NewLine.Length > 509) { break; } stringBuilder.AppendLine(text); num++; } int num2 = _starterItems.Count - num; if (num2 > 0) { string text2 = $"...and {num2} more item(s)."; if (stringBuilder.Length + text2.Length + Environment.NewLine.Length <= 509) { stringBuilder.AppendLine(text2); } else { string text3 = "..."; if (stringBuilder.Length + text3.Length + Environment.NewLine.Length <= 509) { stringBuilder.AppendLine(text3); } } } ctx.Reply(stringBuilder.ToString().TrimEnd()); } private static string ResolveItemLabel(PrefabGUID guid, string fallbackInput) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { string text = guid.LookupName(); if (text != "GUID Not Found") { int num = text.IndexOf(" PrefabGuid", StringComparison.Ordinal); if (num > 0) { return text.Substring(0, num); } return text; } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Failed to resolve item label: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return string.IsNullOrWhiteSpace(fallbackInput) ? ((PrefabGUID)(ref guid)).GuidHash.ToString() : fallbackInput; } public static int ReloadConfig() { LoadConfig(); return _starterItems.Count; } private static void LoadConfig() { //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown _starterItems.Clear(); string value = Plugin.starterKitItems.Value; if (string.IsNullOrWhiteSpace(value)) { return; } string[] array = value.Split(','); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (string.IsNullOrWhiteSpace(text)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Invalid config entry at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": empty entry."); } log.LogWarning(val); continue; } string[] array2 = text.Split(':'); if (array2.Length != 2) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(88, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Invalid config entry at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\". Expected format: ItemPrefab:Quantity"); } log2.LogWarning(val); continue; } string text2 = array2[0].Trim(); string text3 = array2[1].Trim(); int result2; if (!int.TryParse(text2, out var result)) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Invalid item prefab at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"."); } log3.LogWarning(val); } else if (!int.TryParse(text3, out result2)) { ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Invalid quantity at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"."); } log4.LogWarning(val); } else if (result2 <= 0) { ManualLogSource log5 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(78, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StarterKit] Invalid quantity at position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i + 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Quantity must be greater than 0."); } log5.LogWarning(val); } else { _starterItems.Add(new StarterKitEntry { ItemPrefab = result, Quantity = result2 }); } } ManualLogSource log6 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StarterKit] Loaded "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_starterItems.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" item(s) from config."); } log6.LogInfo(val2); } private static void SaveToConfig() { List list = new List(); foreach (StarterKitEntry starterItem in _starterItems) { list.Add($"{starterItem.ItemPrefab}:{starterItem.Quantity}"); } Plugin.starterKitItems.Value = string.Join(",", list); ((ConfigEntryBase)Plugin.starterKitItems).ConfigFile.Save(); } } internal static class TeleportPointsService { private struct TeleportPoint { public float X { get; set; } public float Y { get; set; } public float Z { get; set; } public bool AdminOnly { get; set; } public string Description { get; set; } } private enum TeleportBlockMessageMode { BeforeStart, DuringDelay } private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "PlayerServices"); private static readonly string CONFIG_FILE = Path.Combine(CONFIG_DIR, "teleport_points.json"); private const float CHECK_INTERVAL = 1f; private const float MOVE_TOLERANCE_XZ = 0.2f; private const float MOVE_TOLERANCE_Y = 0.8f; private static readonly HashSet _pendingTeleports = new HashSet(); private static readonly Dictionary _points = new Dictionary(); private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions { WriteIndented = true }; private static EntityArchetype _netEventArchetype; private static bool _archetypeReady; private static bool _initialized; public static void Initialize() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!_initialized) { LoadConfig(); TryInitArchetype(); _initialized = true; ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Initialized and loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_points.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" point(s)."); } log.LogInfo(val); } } public static void Add(ChatCommandContext ctx, string slotToken, string adminOnlyToken, string description) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_006c: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); if (!TryParseSlot(ctx, slotToken, out var slot)) { return; } if (!bool.TryParse(adminOnlyToken, out var result)) { ctx.Reply("AdminOnly must be true or false."); return; } EntityManager entityManager = Core.EntityManager; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; if (senderCharacterEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(senderCharacterEntity) || !((EntityManager)(ref entityManager)).HasComponent(senderCharacterEntity)) { ctx.Reply("Cannot read your position right now."); return; } float3 value = ((EntityManager)(ref entityManager)).GetComponentData(senderCharacterEntity).Value; if (_points.ContainsKey(slot)) { ctx.Reply("That slot is already occupied."); return; } if (description == null) { description = string.Empty; } _points[slot] = new TeleportPoint { X = value.x, Y = value.y, Z = value.z, AdminOnly = result, Description = description }; Save(); string value2 = (string.IsNullOrWhiteSpace(description) ? string.Empty : (" [" + description + "]")); ctx.Reply($"Saved tp {slot} at [{value.x:0.0}, {value.y:0.0}, {value.z:0.0}] [AdminOnly: {result}]{value2}"); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Saved slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.x, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.y, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.z, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("], AdminOnly: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Description: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(description); } log.LogInfo(val); } public static void Remove(ChatCommandContext ctx, string slotToken) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown EnsureInitialized(); if (!TryParseSlot(ctx, slotToken, out var slot)) { return; } if (!_points.Remove(slot)) { ctx.Reply("No teleport point saved in that slot."); return; } Save(); ctx.Reply($"Removed tp {slot}."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Removed slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); } log.LogInfo(val); } public static void List(ChatCommandContext ctx) { EnsureInitialized(); if (_points.Count == 0) { ctx.Reply("No teleport points saved."); return; } StringBuilder stringBuilder = new StringBuilder(256); stringBuilder.AppendLine("Saved teleport points"); foreach (KeyValuePair point in _points) { int key = point.Key; TeleportPoint value = point.Value; stringBuilder.Append('[').Append(key).Append("] [") .Append(value.X.ToString("0.0")) .Append(", ") .Append(value.Y.ToString("0.0")) .Append(", ") .Append(value.Z.ToString("0.0")) .Append("]"); if (value.AdminOnly) { stringBuilder.Append(" [AdminOnly]"); } if (!string.IsNullOrWhiteSpace(value.Description)) { stringBuilder.Append(" [").Append(value.Description).Append(']'); } stringBuilder.AppendLine(); } ctx.Reply(stringBuilder.ToString().TrimEnd()); } public static void ReplyHelp(ChatCommandContext ctx) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); int value = Plugin.playerTeleportDelaySeconds?.Value ?? 0; bool value2 = Plugin.playerTeleportEnabled.Value; string value3 = (value2 ? "Enabled" : "Disabled"); StringBuilder stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler; if (value2) { stringBuilder.AppendLine("Teleport Commands:"); stringBuilder.AppendLine(".pls tp "); if (ctx.Event.User.IsAdmin) { stringBuilder.AppendLine(".pls addtp [true/false] [description]"); stringBuilder.AppendLine(".pls removetp "); stringBuilder.AppendLine(".pls listtp"); } stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(55, 1, stringBuilder2); handler.AppendLiteral("Player Teleport Delay: "); handler.AppendFormatted(value); handler.AppendLiteral(" second(s)"); stringBuilder3.AppendLine(ref handler); } stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(39, 1, stringBuilder2); handler.AppendLiteral("Teleport Status: "); handler.AppendFormatted(value3); stringBuilder4.AppendLine(ref handler); ctx.Reply(stringBuilder.ToString().TrimEnd()); } public unsafe static void Teleport(ChatCommandContext ctx, string slotToken) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Expected O, but got Unknown EnsureInitialized(); if (!TryParseSlot(ctx, slotToken, out var slot)) { return; } if (!_points.TryGetValue(slot, out var value)) { ctx.Reply("No teleport point saved in that slot."); return; } float3 target = default(float3); ((float3)(ref target))..ctor(value.X, value.Y, value.Z); bool flag = default(bool); if (ctx.Event.User.IsAdmin) { if (!TryTeleportSelf(ctx, target)) { ctx.Reply("Teleport failed."); return; } string value2 = (string.IsNullOrWhiteSpace(value.Description) ? string.Empty : (" " + value.Description + "")); ctx.Reply($"Teleported to slot {slot}{value2}."); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Admin: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ctx.Event.User.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" teleported to slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.X, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Y, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Z, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]"); } log.LogInfo(val); return; } ulong platformId = ctx.Event.User.PlatformId; if (platformId == 0) { ctx.Reply("Cannot read your SteamID right now."); return; } if (_pendingTeleports.Contains(platformId)) { ctx.Reply("Teleport is already in progress."); return; } if (!CanPlayerTeleport(ctx, value, out var reason)) { ctx.Reply(reason); return; } EntityManager entityManager = Core.EntityManager; Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; if (senderUserEntity == Entity.Null || senderCharacterEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(senderUserEntity) || !((EntityManager)(ref entityManager)).Exists(senderCharacterEntity) || !((EntityManager)(ref entityManager)).HasComponent(senderCharacterEntity)) { ctx.Reply("Cannot start teleport right now."); return; } float3 value3 = ((EntityManager)(ref entityManager)).GetComponentData(senderCharacterEntity).Value; User user = ctx.Event.User; string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); int value4 = Plugin.playerTeleportDelaySeconds.Value; if (value4 <= 0) { if (!TryTeleport(senderUserEntity, senderCharacterEntity, target)) { ctx.Reply("Teleport failed."); return; } string value5 = (string.IsNullOrWhiteSpace(value.Description) ? string.Empty : (" " + value.Description + "")); ctx.Reply($"Teleported to slot {slot}{value5}."); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(46, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" teleported to slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.X, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Y, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Z, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]"); } log2.LogInfo(val); } else { _pendingTeleports.Add(platformId); TryApplyTeleportWaitBuff(senderUserEntity, senderCharacterEntity, value4); ctx.Reply($"Teleporting in {value4} seconds."); Core.StartCoroutine(DelayedPlayerTeleportRoutine(senderUserEntity, senderCharacterEntity, platformId, text, slot, value4, value, target, value3)); } } private static bool CanPlayerTeleport(ChatCommandContext ctx, TeleportPoint point, out string reason) { //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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) reason = string.Empty; if (!Plugin.playerTeleportEnabled.Value) { reason = "Player teleport is currently disabled."; return false; } if (point.AdminOnly) { reason = "This teleport point is for admins only."; return false; } Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; if (!(senderCharacterEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(senderCharacterEntity)) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent(senderCharacterEntity)) { reason = "Cannot read your position right now."; return false; } if (HasTeleportBlockBuff(senderCharacterEntity, TeleportBlockMessageMode.BeforeStart, out reason)) { return false; } return true; } } reason = "Cannot read your character right now."; return false; } private static IEnumerator DelayedPlayerTeleportRoutine(Entity userEntity, Entity character, ulong steamId, string playerName, int slot, int delaySeconds, TeleportPoint point, float3 target, float3 startPosition) { //IL_0007: 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_000e: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) float elapsed = 0f; try { while (elapsed < (float)delaySeconds) { yield return (object)new WaitForSeconds(1f); elapsed += 1f; if (!IsDelayedTeleportStillValid(userEntity, character, startPosition, out var cancelMessage)) { NotifyTeleportUser(userEntity, cancelMessage); yield break; } cancelMessage = null; } if (!IsDelayedTeleportStillValid(userEntity, character, startPosition, out var finalCancelMessage)) { NotifyTeleportUser(userEntity, finalCancelMessage); yield break; } if (!TryTeleport(userEntity, character, target)) { NotifyTeleportUser(userEntity, "Teleport failed."); yield break; } string desc = (string.IsNullOrWhiteSpace(point.Description) ? string.Empty : (" " + point.Description + "")); NotifyTeleportUser(userEntity, $"Teleported to slot {slot}{desc}."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(46, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" teleported to slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(point.X, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(point.Y, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(point.Z, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]"); } log.LogInfo(val); } finally { _pendingTeleports.Remove(steamId); TryRemoveTeleportWaitBuff(character); } } private static bool IsDelayedTeleportStillValid(Entity userEntity, Entity character, float3 startPosition, out string cancelMessage) { //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_000f: 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_001c: 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_002b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007a: 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_00a7: 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) cancelMessage = string.Empty; try { EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).Exists(character)) { cancelMessage = "Teleport cancelled because your character is not available."; return false; } if (!((EntityManager)(ref entityManager)).HasComponent(userEntity)) { cancelMessage = "Teleport cancelled because your user data is not available."; return false; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); if (!componentData.IsConnected) { cancelMessage = "Teleport cancelled because you disconnected."; return false; } if (HasTeleportBlockBuff(character, TeleportBlockMessageMode.DuringDelay, out cancelMessage)) { return false; } if (HasMovedFromStart(character, startPosition)) { cancelMessage = "Teleport cancelled because you moved."; return false; } return true; } catch (Exception e) { Core.LogException(e, "IsDelayedTeleportStillValid"); cancelMessage = "Teleport cancelled because an error occurred."; return false; } } private static bool HasTeleportBlockBuff(Entity character, TeleportBlockMessageMode mode, out string reason) { //IL_0008: 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_000e: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0076: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00a9: 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_00d8: 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_00df: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) reason = string.Empty; EntityManager entityManager = Core.EntityManager; if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character)) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because your character is not available." : "Cannot read your character right now."); return true; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.Downed))) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you are downed." : "You cannot teleport while you are downed."); return true; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.Spiderform))) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you entered Spider Form." : "You cannot teleport while in Spider Form."); return true; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.Batform))) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you entered Bat Form." : "You cannot teleport while in Bat Form."); return true; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.Dominate))) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you entered Dominate." : "You cannot teleport while in Dominate."); return true; } if (BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.Golemform))) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you entered Golem Form." : "You cannot teleport while in Golem Form."); return true; } if (Helper.IsInCombat(character)) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because you entered combat." : "You cannot teleport while in combat."); return true; } if (Helper.IsRaidTime()) { reason = ((mode == TeleportBlockMessageMode.DuringDelay) ? "Teleport cancelled because Raid Time started." : "You cannot teleport during Raid Time."); return true; } return false; } private static bool HasMovedFromStart(Entity character, float3 startPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: 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_0020: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0053: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character) || !((EntityManager)(ref entityManager)).HasComponent(character)) { return true; } float3 value = ((EntityManager)(ref entityManager)).GetComponentData(character).Value; float num = value.x - startPosition.x; float num2 = value.z - startPosition.z; float num3 = num * num + num2 * num2; if (num3 > 0.040000003f) { return true; } float num4 = math.abs(value.y - startPosition.y); return num4 > 0.8f; } private static void TryApplyTeleportWaitBuff(Entity userEntity, Entity character, int delaySeconds) { //IL_000f: 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_001c: 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_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_0038: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) try { if (delaySeconds > 2 && !(userEntity == Entity.Null) && !(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).Exists(character)) { Buffs.AddBuff(userEntity, character, PrefabData.TeleportWaiting, -1, immortal: false); } } } catch (Exception e) { Core.LogException(e, "TryApplyTeleportWaitBuff"); } } private static void TryRemoveTeleportWaitBuff(Entity character) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0040: 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) try { if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && BuffUtility.HasBuff(entityManager, character, PrefabIdentifier.op_Implicit(PrefabData.TeleportWaiting))) { Buffs.RemoveBuff(character, PrefabData.TeleportWaiting); } } } catch (Exception e) { Core.LogException(e, "TryRemoveTeleportWaitBuff"); } } private static void NotifyTeleportUser(Entity userEntity, string message) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) try { EntityManager entityManager = Core.EntityManager; if (!(userEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).HasComponent(userEntity)) { Helper.NotifyUser(userEntity, message); } } catch (Exception e) { Core.LogException(e, "NotifyTeleportUser"); } } private static bool TryParseSlot(ChatCommandContext ctx, string slotToken, out int slot) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) slot = 0; if (!int.TryParse(slotToken, out slot) || slot <= 0) { if (ctx.Event.User.IsAdmin) { ctx.Reply("Admin usage:\n.pls tp \n.pls addtp [description]\n.pls removetp \n.pls listtp"); } else { ctx.Reply("Player usage: .pls tp Example: .pls tp 1"); } return false; } return true; } private static void EnsureInitialized() { if (!_initialized) { Initialize(); } } public static bool ReloadConfig(out int pointCount) { bool result = LoadConfig(); pointCount = _points.Count; return result; } private static bool LoadConfig() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown try { _points.Clear(); if (!File.Exists(CONFIG_FILE)) { return true; } string text = File.ReadAllText(CONFIG_FILE); if (string.IsNullOrWhiteSpace(text)) { return true; } Dictionary dictionary = JsonSerializer.Deserialize>(text, _jsonOptions); if (dictionary == null || dictionary.Count == 0) { return true; } foreach (KeyValuePair item in dictionary) { _points[item.Key] = item.Value; } return true; } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Failed to load teleport_points.json: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); _points.Clear(); return false; } } private static void Save() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown try { Directory.CreateDirectory(CONFIG_DIR); string contents = JsonSerializer.Serialize(_points, _jsonOptions); File.WriteAllText(CONFIG_FILE, contents); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Teleport] Failed to save teleport_points.json: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryTeleportSelf(ChatCommandContext ctx, float3 target) { //IL_0007: 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_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_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) Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; return TryTeleport(senderUserEntity, senderCharacterEntity, target); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryTeleport(Entity userEntity, Entity character, float3 target) { //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_0032: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0081: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) try { EntityManager entityManager = Core.EntityManager; if (!_archetypeReady) { TryInitArchetype(); if (!_archetypeReady) { return false; } } if (userEntity == Entity.Null || character == Entity.Null) { return false; } if (!((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).Exists(character)) { return false; } if (target.y < 0f) { target.y = 0f; } float3 position = target; position.y += 0.25f; Entity val = ((EntityManager)(ref entityManager)).CreateEntity(_netEventArchetype); ((EntityManager)(ref entityManager)).SetComponentData(val, new FromCharacter { User = userEntity, Character = character }); ((EntityManager)(ref entityManager)).SetComponentData(val, new PlayerTeleportDebugEvent { Position = position }); return true; } catch (Exception e) { Core.LogException(e, "TryTeleport"); return false; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void TryInitArchetype() { //IL_000e: 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_001e: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (_archetypeReady) { return; } try { EntityManager entityManager = Core.EntityManager; _netEventArchetype = ((EntityManager)(ref entityManager)).CreateArchetype((ComponentType[])(object)new ComponentType[3] { ComponentType.ReadWrite(), ComponentType.ReadWrite(), ComponentType.ReadWrite() }); _archetypeReady = true; } catch (Exception e) { _archetypeReady = false; Core.LogException(e, "TryInitArchetype"); } } } internal static class WebhookService { private const int TIMEOUT_SECONDS = 10; private static readonly HttpClient _http = new HttpClient(); public static bool IsEnabled => !string.IsNullOrWhiteSpace(Plugin.changeNameWebhookUrl?.Value); public static async Task<(bool ok, string error)> SendAsync(string message, CancellationToken ct = default(CancellationToken)) { try { if (!IsEnabled) { return (ok: false, error: "Webhook URL is empty or disabled."); } string url = Plugin.changeNameWebhookUrl.Value; message = (message ?? "").Trim(); if (message.Length == 0) { return (ok: false, error: "Message is empty."); } if (message.Length > 1990) { message = message.Substring(0, 1990) + "..."; } var payload = new { content = message, allowed_mentions = new { parse = Array.Empty() } }; using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(ct); linkedCts.CancelAfter(TimeSpan.FromSeconds(10.0)); string body = JsonSerializer.Serialize(payload); using StringContent content = new StringContent(body, Encoding.UTF8, "application/json"); using HttpResponseMessage response = await _http.PostAsync(url, content, linkedCts.Token).ConfigureAwait(continueOnCapturedContext: false); if (!response.IsSuccessStatusCode) { string responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false); return (ok: false, error: $"Discord returned {response.StatusCode} {response.ReasonPhrase}: {responseText}"); } return (ok: true, error: null); } catch (OperationCanceledException) { Core.Log.LogInfo((object)"[Webhook] Request timeout. The message should already be in Discord."); return (ok: true, error: "Timeout ignored"); } catch (Exception ex2) { Exception e = ex2; Core.LogException(e, "SendAsync"); return (ok: false, error: e.Message); } } } internal static class WelcomeService { private const float MESSAGE_DELAY_SECONDS = 2f; private static IEnumerator SendWelcomeMessageRoutine(Entity userEntity, ulong steamId) { //IL_0007: 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) yield return (object)new WaitForSeconds(2f); SendWelcomeMessage(userEntity, steamId); } public static void SendWelcomeMessageDelayed(Entity userEntity, User user) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Plugin.welcomeMessageEnabled.Value && user.PlatformId != 0) { Core.StartCoroutine(SendWelcomeMessageRoutine(userEntity, user.PlatformId)); } } private unsafe static void SendWelcomeMessage(Entity userEntity, ulong steamId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.welcomeMessageEnabled.Value) { return; } EntityManager entityManager = Core.EntityManager; if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity) || !((EntityManager)(ref entityManager)).HasComponent(userEntity)) { return; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); if (!componentData.IsConnected || componentData.PlatformId == 0L || componentData.PlatformId != steamId) { return; } PlayerCacheData playerCache = PlayerDataService.GetPlayerCache(componentData.PlatformId); if ((!Plugin.onlyWhitelistEnable.Value || (playerCache != null && playerCache.IsWhitelisted)) && (playerCache == null || !playerCache.IsBanned)) { string text = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(text)) { text = "Vampire"; } SendFormattedMessage(userEntity, Plugin.welcomeMessageText1.Value, text); SendFormattedMessage(userEntity, Plugin.welcomeMessageText2.Value, text); } } catch (Exception e) { Core.LogException(e, "SendWelcomeMessage"); } } private static void SendFormattedMessage(Entity userEntity, string message, string playerName) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (string.IsNullOrWhiteSpace(message)) { return; } message = message.Replace("#player#", playerName); if (message.Length > 509) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Welcome] Welcome message is too long ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(message.Length); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(509); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("). It has been trimmed."); } log.LogWarning(val); int num = 506; if (num <= 0) { return; } message = message.Substring(0, num) + "..."; } Helper.NotifyUser(userEntity, message); } } internal static class WhitelistService { public static void AddWhitelist(ChatCommandContext ctx, string steamIdInput, string knownAs) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown if (string.IsNullOrWhiteSpace(steamIdInput) || string.IsNullOrWhiteSpace(knownAs)) { ReplyWhitelistHelp(ctx); return; } knownAs = knownAs.Trim(); if (string.IsNullOrWhiteSpace(knownAs)) { ReplyWhitelistHelp(ctx); return; } if (!ulong.TryParse(steamIdInput, out var result) || result == 0) { ctx.Reply("Please provide a valid SteamID (numbers only)."); return; } PlayerCacheData orCreatePlayerCache = PlayerDataService.GetOrCreatePlayerCache(result); orCreatePlayerCache.KnownAs = knownAs; orCreatePlayerCache.IsWhitelisted = true; PlayerDataService.SaveData(); ctx.Reply($"Added player to the whitelist: {orCreatePlayerCache.KnownAs} ({result})."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Whitelist] Added player to the whitelist: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(orCreatePlayerCache.KnownAs); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } public static void RemoveWhitelist(ChatCommandContext ctx, string targetInput) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown if (!TryFindWhitelistTarget(ctx, targetInput, out var cache)) { return; } if (cache == null || !cache.IsWhitelisted) { ctx.Reply("" + targetInput + " is not in the whitelist."); return; } string whitelistDisplayName = GetWhitelistDisplayName(cache); cache.IsWhitelisted = false; PlayerDataService.SaveData(); if (Plugin.onlyWhitelistEnable.Value) { AccessControlService.KickIfOnline(cache.SteamID); } ctx.Reply($"Removed player from the whitelist: {whitelistDisplayName} ({cache.SteamID})."); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Whitelist] Removed player from the whitelist: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(whitelistDisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(cache.SteamID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } public static void ShowWhitelist(ChatCommandContext ctx) { List whitelistedPlayers = GetWhitelistedPlayers(); if (whitelistedPlayers.Count == 0) { ctx.Reply("The whitelist is empty."); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Whitelisted Players"); foreach (PlayerCacheData item in whitelistedPlayers) { string whitelistDisplayName = GetWhitelistDisplayName(item); if (stringBuilder.Length + whitelistDisplayName.Length + Environment.NewLine.Length > 509 && stringBuilder.Length > "Whitelisted Players".Length + Environment.NewLine.Length) { ctx.Reply(stringBuilder.ToString().TrimEnd()); stringBuilder.Clear(); stringBuilder.AppendLine("Whitelisted Players (continued)"); } stringBuilder.AppendLine(whitelistDisplayName); } if (stringBuilder.Length > "Whitelisted Players".Length + Environment.NewLine.Length) { ctx.Reply(stringBuilder.ToString().TrimEnd()); } } public static bool IsWhitelistedPlayer(PlayerCacheData cache) { return cache != null && cache.SteamID != 0L && cache.IsWhitelisted; } public static void ReplyWhitelistHelp(ChatCommandContext ctx) { StringBuilder stringBuilder = new StringBuilder(); string value = (Plugin.onlyWhitelistEnable.Value ? "Enabled" : "Disabled"); stringBuilder.AppendLine("Whitelist Commands:"); stringBuilder.AppendLine(".pls addwhitelist "); stringBuilder.AppendLine(".pls removewhitelist "); stringBuilder.AppendLine(".pls showwhitelist"); stringBuilder.AppendLine(".pls helpwhitelist"); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(43, 1, stringBuilder2); handler.AppendLiteral("Whitelist-only mode: "); handler.AppendFormatted(value); stringBuilder2.AppendLine(ref handler); ctx.Reply(stringBuilder.ToString().TrimEnd()); } private static List GetWhitelistedPlayers() { List list = new List(); foreach (PlayerCacheData allPlayerCache in PlayerDataService.GetAllPlayerCaches()) { if (IsWhitelistedPlayer(allPlayerCache)) { list.Add(allPlayerCache); } } list.Sort((PlayerCacheData a, PlayerCacheData b) => string.Compare(GetWhitelistDisplayName(a), GetWhitelistDisplayName(b), StringComparison.OrdinalIgnoreCase)); return list; } private static bool TryFindWhitelistTarget(ChatCommandContext ctx, string targetInput, out PlayerCacheData cache) { cache = null; if (string.IsNullOrWhiteSpace(targetInput)) { return false; } targetInput = targetInput.Trim(); if (ulong.TryParse(targetInput, out var result)) { cache = PlayerDataService.GetPlayerCache(result); return true; } List whitelistedPlayers = GetWhitelistedPlayers(); List list = whitelistedPlayers.Where((PlayerCacheData x) => string.Equals(x.KnownAs, targetInput, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 1) { cache = list[0]; return true; } if (list.Count > 1) { ctx.Reply($"Multiple whitelisted players use Known As {targetInput} ({list.Count} profiles). Please use SteamID instead."); return false; } List list2 = (from x in whitelistedPlayers where !string.IsNullOrWhiteSpace(x.KnownAs) && x.KnownAs.IndexOf(targetInput, StringComparison.OrdinalIgnoreCase) >= 0 select x.KnownAs).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string x) => x, StringComparer.OrdinalIgnoreCase).ToList(); if (list2.Count == 1) { string matchedKnownAs = list2[0]; List list3 = whitelistedPlayers.Where((PlayerCacheData x) => string.Equals(x.KnownAs, matchedKnownAs, StringComparison.OrdinalIgnoreCase)).ToList(); if (list3.Count == 1) { cache = list3[0]; return true; } ctx.Reply($"Multiple whitelisted players use Known As {matchedKnownAs} ({list3.Count} profiles). Please use SteamID instead."); return false; } if (list2.Count > 0) { if (list2.Count > 10) { ctx.Reply($"Multiple whitelisted Known As matched {targetInput} ({list2.Count} results). Please narrow your search or use SteamID."); return false; } ctx.Reply("Multiple whitelisted Known As matched " + targetInput + ": " + string.Join(", ", list2)); return false; } return true; } private static string GetWhitelistDisplayName(PlayerCacheData cache) { if (cache == null) { return "Unknown"; } if (!string.IsNullOrWhiteSpace(cache.KnownAs)) { return cache.KnownAs.Trim(); } if (!string.IsNullOrWhiteSpace(cache.InGameName)) { return cache.InGameName.Trim(); } return "Unknown"; } } } namespace PlayerServices.Patches { [HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")] public static class OnUserConnected_Patch { [HarmonyPostfix] public static void Postfix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId) { //IL_0029: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0049: 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) try { int num = default(int); if (__instance._NetEndPointToApprovedUserIndex.TryGetValue(netConnectionId, ref num)) { ServerClient val = ((Il2CppArrayBase)(object)__instance._ApprovedUsersLookup)[num]; Entity userEntity = val.UserEntity; EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); AccessControlService.CheckUserLogin(userEntity, componentData); WelcomeService.SendWelcomeMessageDelayed(userEntity, componentData); AuraService.RefreshOnConnect(userEntity, componentData); } } catch (Exception e) { Core.LogException(e, "Postfix"); } } } [HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserDisconnected")] public static class OnUserDisconnected_Patch { [HarmonyPrefix] private static void Prefix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId) { //IL_0029: 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_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0058: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: Unknown result type (might be due to invalid IL or missing references) try { int num = default(int); if (!__instance._NetEndPointToApprovedUserIndex.TryGetValue(netConnectionId, ref num)) { return; } ServerClient val = ((Il2CppArrayBase)(object)__instance._ApprovedUsersLookup)[num]; Entity userEntity = val.UserEntity; if (userEntity == Entity.Null) { return; } EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity)) { entityManager = ((ComponentSystemBase)__instance).EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(userEntity)) { entityManager = ((ComponentSystemBase)__instance).EntityManager; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); PlayerDataService.RecordDisconnectedUser(componentData); } } } catch (Exception e) { Core.LogException(e, "Prefix"); } } } [HarmonyPatch(typeof(Destroy_TravelBuffSystem), "OnUpdate")] public static class Destroy_TravelBuffSystem_Patch { [HarmonyPrefix] public unsafe static void Prefix(Destroy_TravelBuffSystem __instance) { //IL_0003: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0093: 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_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_00ba: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) NativeArray val = default(NativeArray); try { EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[4] { ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.ReadOnly() }); val = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); bool flag = default(bool); for (int i = 0; i < val.Length; i++) { Entity val3 = val[i]; PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData(val3); if (componentData != PrefabData.TombCoffinSpawn) { continue; } Entity owner = ((EntityManager)(ref entityManager)).GetComponentData(val3).Owner; if (((EntityManager)(ref entityManager)).HasComponent(owner)) { PlayerCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData(owner); Entity userEntity = componentData2.UserEntity; User componentData3 = ((EntityManager)(ref entityManager)).GetComponentData(userEntity); string text = ((object)(*(FixedString64Bytes*)(&componentData3.CharacterName))/*cast due to .constrained prefix*/).ToString(); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Created] Player created: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(componentData3.PlatformId); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")"); } log.LogInfo(val4); StarterKitService.GiveKit(userEntity, componentData3); } } } catch (Exception e) { Core.LogException(e, "Prefix"); } finally { if (val.IsCreated) { val.Dispose(); } } } } [HarmonyPatch(typeof(SceneSectionStreamingSystem), "ShutdownAsynchrnonousStreamingSupport")] public static class InitializationPatch { [HarmonyPostfix] public static void OneShot_AfterLoad_InitializationPatch() { if (Core.IsServer) { Core.InitializeAfterLoaded(); Harmony harmony = Plugin.Harmony; if (harmony != null) { harmony.Unpatch((MethodBase)typeof(SceneSectionStreamingSystem).GetMethod("ShutdownAsynchrnonousStreamingSupport"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch")); } } } } } namespace PlayerServices.Data { internal static class CastleTerritoryData { private class RegionDisplayInfo { public string FullName { get; } public string ShortName { get; } public RegionDisplayInfo(string fullName, string shortName) { FullName = fullName; ShortName = shortName; } } private static readonly Dictionary RegionMap = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "Strongblade", new RegionDisplayInfo("Oakveil Woodlands", "Oakveil") }, { "Gloomrot_North", new RegionDisplayInfo("Gloomrot North", "Gloomrot N") }, { "Gloomrot_South", new RegionDisplayInfo("Gloomrot South", "Gloomrot S") }, { "CursedForest", new RegionDisplayInfo("Cursed Forest", "Forest") }, { "DunleyFarmlands", new RegionDisplayInfo("Dunley Farmlands", "Dunley") }, { "HallowedMountains", new RegionDisplayInfo("Hallowed Mountains", "Hallowed") }, { "FarbaneWoods", new RegionDisplayInfo("Farbane Woods", "Farbane") }, { "SilverlightHills", new RegionDisplayInfo("Silverlight Hills", "Silverlight") } }; public static string GetFullName(string rawName) { if (RegionMap.TryGetValue(rawName, out var value)) { return value.FullName; } return "Unknown (" + rawName + ")"; } public static string GetShortName(string rawName) { if (RegionMap.TryGetValue(rawName, out var value)) { return value.ShortName; } return "Unknown (" + rawName + ")"; } } internal class PlayerCacheData { public ulong SteamID { get; set; } public string InGameName { get; set; } = string.Empty; public string KnownAs { get; set; } = string.Empty; public int CurrentLevel { get; set; } public int MaxLevel { get; set; } public Dictionary CastleRegions { get; set; } = new Dictionary(); public long LastOnlineTicks { get; set; } = 0L; public string LastDailyKitClaim { get; set; } = string.Empty; public bool HasReceivedStarterKit { get; set; } = false; public bool IsBanned { get; set; } = false; public bool IsWhitelisted { get; set; } = false; public List Auras { get; set; } = new List(); } internal class PlayerAuraData { public int PrefabGuid { get; set; } public bool Active { get; set; } = true; } internal static class PrefabData { public static readonly PrefabGUID TeleportWaiting = new PrefabGUID(-2061047741); public static readonly PrefabGUID Downed = new PrefabGUID(-1992158531); public static readonly PrefabGUID Spiderform = new PrefabGUID(124832551); public static readonly PrefabGUID Golemform = new PrefabGUID(914043867); public static readonly PrefabGUID Batform = new PrefabGUID(1205505492); public static readonly PrefabGUID Dominate = new PrefabGUID(-1447419822); public static readonly PrefabGUID Observe = new PrefabGUID(1880224358); public static readonly PrefabGUID TombCoffinSpawn = new PrefabGUID(722466953); public static readonly PrefabGUID SpellPowerPotion = new PrefabGUID(-1591827622); public static readonly PrefabGUID PhysicalPowerPotion = new PrefabGUID(-1591883586); public static readonly PrefabGUID HolyResistancePotion = new PrefabGUID(2099221856); public static readonly PrefabGUID FireResistancePotion = new PrefabGUID(-706770454); public static readonly PrefabGUID WranglerPotion = new PrefabGUID(387154469); public static readonly PrefabGUID SunResistancePotion = new PrefabGUID(112008974); public static readonly PrefabGUID MapIconPlayer = new PrefabGUID(-892362184); public static readonly PrefabGUID InCombatPvE = new PrefabGUID(581443919); public static readonly PrefabGUID InCombatPvP = new PrefabGUID(697095869); public static readonly PrefabGUID InCombatContest = new PrefabGUID(698151145); public static readonly HashSet CombatBuffs = new HashSet { InCombatPvE, InCombatPvP, InCombatContest }; public static readonly HashSet PotionBuff = new HashSet { SpellPowerPotion, PhysicalPowerPotion, HolyResistancePotion, FireResistancePotion, WranglerPotion, SunResistancePotion }; } } namespace PlayerServices.Commands { [CommandGroup("pls", null)] internal static class AdminCommands { [Command("observe", "ob", null, "Toggle admin observe mode.", null, true)] public static void ObserveCommand(ChatCommandContext ctx) { AdminService.ToggleObserve(ctx); } [Command("track", "tr", null, "Continuously track a player while in observe mode.", null, true)] public static void TrackCommand(ChatCommandContext ctx, string playerName = "") { if (string.IsNullOrWhiteSpace(playerName)) { ctx.Reply("Usage: .pls track "); } else { AdminService.TrackPlayer(ctx, playerName); } } [Command("untrack", "utr", null, "Stop tracking the current player.", null, true)] public static void UntrackCommand(ChatCommandContext ctx) { AdminService.UntrackPlayer(ctx); } [Command("buff", "bf", null, "Apply Potion Buffs to a target player or yourself.", null, true)] public static void PotionBuffCommand(ChatCommandContext ctx, string playerName = "") { AdminService.ApplyPotionBuffs(ctx, playerName); } [Command("reload", "rl", null, "Reload all PlayerServices configs.", null, true)] public static void ReloadCommand(ChatCommandContext ctx) { AdminService.ReloadAll(ctx); } } [CommandGroup("aura", null)] internal static class AuraCommands { [Command("on", null, null, "Turn an aura on.", null, false)] public static void AuraOnCommand(ChatCommandContext ctx, string id = "") { if (string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.SetAuraActive(ctx, id, active: true); } } [Command("off", null, null, "Turn an aura off.", null, false)] public static void AuraOffCommand(ChatCommandContext ctx, string id = "") { if (string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.SetAuraActive(ctx, id, active: false); } } [Command("preview", null, null, "Preview an aura for a short time before buying it.", null, false)] public static void AuraPreviewCommand(ChatCommandContext ctx, string id = "") { if (string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.PreviewAura(ctx, id); } } [Command("buy", null, null, "Buy an aura.", null, false)] public static void AuraBuyCommand(ChatCommandContext ctx, string id = "") { if (string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.BuyAura(ctx, id); } } [Command("list", null, null, "Show available auras, prices, and ownership status.", null, false)] public static void AuraListCommand(ChatCommandContext ctx) { AuraService.ListAuras(ctx); } [Command("help", null, null, "Show aura commands and feature status.", null, false)] public static void AuraHelpCommand(ChatCommandContext ctx) { AuraService.ReplyHelp(ctx); } [Command("add", null, null, "Grant an aura to a player.", null, true)] public static void AuraAddCommand(ChatCommandContext ctx, string playerName = "", string id = "") { if (string.IsNullOrWhiteSpace(playerName) || string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.AdminAddAura(ctx, playerName, id); } } [Command("remove", null, null, "Remove an aura from a player.", null, true)] public static void AuraRemoveCommand(ChatCommandContext ctx, string playerName = "", string id = "") { if (string.IsNullOrWhiteSpace(playerName) || string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.AdminRemoveAura(ctx, playerName, id); } } } [CommandGroup("buy", null)] internal static class AuraBuyCommands { [Command("aura", null, null, "Buy an aura.", null, false)] public static void BuyAuraCommand(ChatCommandContext ctx, string id = "") { if (string.IsNullOrWhiteSpace(id)) { AuraService.ReplyHelp(ctx); } else { AuraService.BuyAura(ctx, id); } } } [CommandGroup("pls", null)] internal static class BanCommands { [Command("ban", "b", null, "Ban a player by Name or SteamID and kick them.", null, true)] public static void BanCommand(ChatCommandContext ctx, string nameOrSteamId = "") { if (string.IsNullOrWhiteSpace(nameOrSteamId)) { BanService.ReplyBanHelp(ctx); } else { BanService.AddBan(ctx, nameOrSteamId); } } [Command("unban", "ub", null, "Unban a player by Name or SteamID.", null, true)] public static void UnbanCommand(ChatCommandContext ctx, string nameOrSteamId = "") { if (string.IsNullOrWhiteSpace(nameOrSteamId)) { BanService.ReplyBanHelp(ctx); } else { BanService.RemoveBan(ctx, nameOrSteamId); } } [Command("banlist", "bl", null, "Show all banned players.", null, true)] public static void ShowBanlistCommand(ChatCommandContext ctx) { BanService.ShowBanlist(ctx); } [Command("banhelp", "bh", null, "Show ban commands.", null, true)] public static void HelpBanCommand(ChatCommandContext ctx) { BanService.ReplyBanHelp(ctx); } } [CommandGroup("changename", "cn")] internal static class ChangeNameCommand { [Command("to", null, null, "Change your character name.", null, false)] public unsafe static void ChangeNameSelf(ChatCommandContext ctx, string newName = "") { //IL_0022: 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_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_0034: 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_004e: 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_0058: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(newName)) { ChangeNameService.ReplyHelp(ctx, "Please specify a new name."); return; } Entity senderUserEntity = ctx.Event.SenderUserEntity; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User val = senderUserEntity.Read(); string oldName = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); ulong platformId = val.PlatformId; ChangeNameService.ProcessRename(ctx, senderUserEntity, senderCharacterEntity, oldName, newName, platformId, isAdminOverride: false); } [Command("help", null, null, "Show help and info for change name command.", null, false)] public static void ChangeNameHelp(ChatCommandContext ctx) { ChangeNameService.ReplyHelp(ctx); } [Command("player", null, null, "Admin command to change a player's character name.", null, true)] public unsafe static void ChangeNameOther(ChatCommandContext ctx, string currentName = "", string newName = "") { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(currentName) || string.IsNullOrWhiteSpace(newName)) { ctx.Reply("Usage: .changename player "); return; } if (!ChangeNameService.TryFindUserByName(currentName, out var userEntity, out var charEntity, out var user)) { ctx.Reply("Player not found: " + currentName + ""); return; } string oldName = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); ulong platformId = user.PlatformId; ChangeNameService.ProcessRename(ctx, userEntity, charEntity, oldName, newName, platformId, isAdminOverride: true); } [Command("testwebhook", "tw", null, "Send a test message to Discord.", null, true)] public static void TestChangeNameWebhook(ChatCommandContext ctx) { if (string.IsNullOrWhiteSpace(Plugin.changeNameWebhookUrl?.Value)) { ctx.Reply("Webhook URL is empty in the config."); return; } string message = "Webhook test message from PlayerServices v1.0.0 by Del"; ctx.Reply("Sending a webhook test message."); WebhookService.SendAsync(message); } } [CommandGroup("clan", "c")] internal static class ClanCommands { [Command("forcecreate", "fc", null, "Force a player to create their own clan.", null, true)] public static void CreateClanCommand(ChatCommandContext ctx, string playerName = "") { if (string.IsNullOrWhiteSpace(playerName)) { ClanService.ReplyHelp(ctx); } else { ClanService.CreateClanForPlayer(ctx, playerName); } } [Command("forcejoin", "fj", null, "Force two players into the same clan.", null, true)] public static void JoinClanCommand(ChatCommandContext ctx, string playerAName = "", string playerBName = "") { if (string.IsNullOrWhiteSpace(playerAName) || string.IsNullOrWhiteSpace(playerBName)) { ClanService.ReplyHelp(ctx); } else { ClanService.JoinPlayerToPlayerClan(ctx, playerAName, playerBName); } } [Command("forceleave", "fl", null, "Force a player to leave their clan.", null, true)] public static void LeaveClanCommand(ChatCommandContext ctx, string playerName = "") { if (string.IsNullOrWhiteSpace(playerName)) { ClanService.ReplyHelp(ctx); } else { ClanService.LeaveClan(ctx, playerName); } } } [CommandGroup("pls", null)] internal static class DailyKitCommand { [Command("dailykit", "dk", null, "Claim your daily kit.", null, false)] public static void Claim(ChatCommandContext ctx) { DailyKitService.ClaimKit(ctx); } [Command("adddailykit", "adk", null, "Add or update an item in the daily kit.", null, true)] public static void Add(ChatCommandContext ctx, int prefabGuid, int quantity) { DailyKitService.AddKit(ctx, prefabGuid, quantity); } [Command("removedailykit", "rdk", null, "Remove an item from the daily kit.", null, true)] public static void Remove(ChatCommandContext ctx, int prefabGuid) { DailyKitService.RemoveKit(ctx, prefabGuid); } [Command("listdailykit", "ldk", null, "Show all daily kit items.", null, true)] public static void List(ChatCommandContext ctx) { DailyKitService.ListKit(ctx); } } [CommandGroup("pls", null)] internal static class GiveCommands { [Command("give", "g", null, "Give an item set to a specific player.", null, true)] public static void GivePlayerCommand(ChatCommandContext ctx, string playerName = "", string setName = "", int quantity = 1) { if (string.IsNullOrWhiteSpace(playerName) || string.IsNullOrWhiteSpace(setName)) { GiveService.ReplyHelp(ctx); } else if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); } else { GiveService.GiveToPlayer(ctx, playerName, setName, quantity); } } [Command("giveradius", "gr", null, "Give an item set to players within a radius.", null, true)] public static void GiveRadiusCommand(ChatCommandContext ctx, string radiusToken = "", string setName = "", int quantity = 1) { float result; if (string.IsNullOrWhiteSpace(radiusToken) || string.IsNullOrWhiteSpace(setName)) { GiveService.ReplyHelp(ctx); } else if (!float.TryParse(radiusToken, NumberStyles.Float, CultureInfo.InvariantCulture, out result)) { ctx.Reply("Invalid radius. It must be a number."); } else if (result <= 0f) { ctx.Reply("Radius must be greater than 0."); } else if (result > 50f) { ctx.Reply("Radius must be less than or equal to 50."); } else if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); } else { GiveService.GiveToRadius(ctx, result, setName, quantity); } } [Command("giveclan", "gc", null, "Give an item set to all online members of a player's clan.", null, true)] public static void GiveClanCommand(ChatCommandContext ctx, string playerName = "", string setName = "", int quantity = 1) { if (string.IsNullOrWhiteSpace(playerName) || string.IsNullOrWhiteSpace(setName)) { GiveService.ReplyHelp(ctx); } else if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); } else { GiveService.GiveToClan(ctx, playerName, setName, quantity); } } [Command("addgive", "ag", null, "Add an item to a give set.", null, true)] public static void AddCommand(ChatCommandContext ctx, string setName = "", string itemPrefab = "", int quantity = 1) { if (string.IsNullOrWhiteSpace(setName) || string.IsNullOrWhiteSpace(itemPrefab)) { GiveService.ReplyHelp(ctx); } else if (quantity <= 0) { ctx.Reply("Quantity must be greater than 0."); } else { GiveService.AddGiveItem(ctx, setName, itemPrefab, quantity); } } [Command("removegive", "rg", null, "Remove a give set.", null, true)] public static void RemoveCommand(ChatCommandContext ctx, string setName = "") { if (string.IsNullOrWhiteSpace(setName)) { GiveService.ReplyHelp(ctx); } else { GiveService.RemoveGiveSet(ctx, setName); } } [Command("listgive", "lg", null, "List all give sets.", null, true)] public static void ListCommand(ChatCommandContext ctx) { GiveService.ListGiveSets(ctx); } [Command("helpgive", "hg", null, "Show give command help.", null, true)] public static void HelpCommand(ChatCommandContext ctx) { GiveService.ReplyHelp(ctx); } } internal static class PlayerInfoCommands { [Command("pis", null, null, "Show player information.", null, false)] public static void Pis(ChatCommandContext ctx, string player = null) { PlayerInfoService.TryGetPlayerInfo(ctx, player ?? ""); } } [CommandGroup("pls", null)] internal static class PlayerProfileCommands { [Command("checkplayer", "cp", null, "Check a player profile by In-Game Name or SteamID.", null, true)] public static void CheckByPlayerNameCommand(ChatCommandContext ctx, string nameOrSteamId = "") { if (string.IsNullOrWhiteSpace(nameOrSteamId)) { PlayerProfileService.ReplyHelp(ctx); } else { PlayerProfileService.CheckByPlayerName(ctx, nameOrSteamId); } } [Command("checkknownas", "cka", null, "Find player profiles by Known As.", null, true)] public static void CheckByKnownAsCommand(ChatCommandContext ctx, string knownAs = "") { if (string.IsNullOrWhiteSpace(knownAs)) { PlayerProfileService.ReplyHelp(ctx); } else { PlayerProfileService.CheckByKnownAs(ctx, knownAs); } } [Command("addknownas", "aka", null, "Set a player's Known As.", null, true)] public static void SetKnownAsCommand(ChatCommandContext ctx, string nameOrSteamId = "", string knownAs = "") { if (string.IsNullOrWhiteSpace(nameOrSteamId) || string.IsNullOrWhiteSpace(knownAs)) { PlayerProfileService.ReplyHelp(ctx); } else { PlayerProfileService.SetKnownAs(ctx, nameOrSteamId, knownAs); } } [Command("removeknownas", "rka", null, "Remove Known As from a player profile.", null, true)] public static void RemoveKnownAsCommand(ChatCommandContext ctx, string nameOrSteamId = "") { if (string.IsNullOrWhiteSpace(nameOrSteamId)) { PlayerProfileService.ReplyHelp(ctx); } else { PlayerProfileService.RemoveKnownAs(ctx, nameOrSteamId); } } } [CommandGroup("pls", null)] internal static class StarterKitCommand { [Command("starterkit", "sk", null, "Claim your one-time starter kit if auto-grant fails.", null, false)] public static void Claim(ChatCommandContext ctx) { StarterKitService.ClaimKit(ctx); } [Command("addstarterkit", "ask", null, "Add or update an item in the starter kit.", null, true)] public static void Add(ChatCommandContext ctx, int prefabGuid, int quantity) { StarterKitService.AddKit(ctx, prefabGuid, quantity); } [Command("removestarterkit", "rsk", null, "Remove an item from the starter kit.", null, true)] public static void Remove(ChatCommandContext ctx, int prefabGuid) { StarterKitService.RemoveKit(ctx, prefabGuid); } [Command("liststarterkit", "lsk", null, "Show all items in the starter kit.", null, true)] public static void List(ChatCommandContext ctx) { StarterKitService.ListKit(ctx); } } [CommandGroup("pls", null)] internal static class TeleportPointsCommands { [Command("tp", null, null, "Teleport to a saved teleport point.", null, false)] public static void TeleportCommand(ChatCommandContext ctx, string slot = "") { if (string.IsNullOrWhiteSpace(slot)) { TeleportPointsService.ReplyHelp(ctx); } else { TeleportPointsService.Teleport(ctx, slot); } } [Command("helptp", "htp", null, "Show teleport point commands and feature status.", null, false)] public static void HelpTeleportCommand(ChatCommandContext ctx) { TeleportPointsService.ReplyHelp(ctx); } [Command("addtp", "atp", null, "Add a teleport point at your current position.", null, true)] public static void AddTeleportCommand(ChatCommandContext ctx, string slot = "", string adminOnly = "true", string description = "") { if (string.IsNullOrWhiteSpace(slot) || string.IsNullOrWhiteSpace(adminOnly)) { TeleportPointsService.ReplyHelp(ctx); } else { TeleportPointsService.Add(ctx, slot, adminOnly, description); } } [Command("removetp", "rtp", null, "Remove a teleport point.", null, true)] public static void RemoveTeleportCommand(ChatCommandContext ctx, string slot = "") { if (string.IsNullOrWhiteSpace(slot)) { TeleportPointsService.ReplyHelp(ctx); } else { TeleportPointsService.Remove(ctx, slot); } } [Command("listtp", "ltp", null, "List all teleport points.", null, true)] public static void ListTeleportCommand(ChatCommandContext ctx) { TeleportPointsService.List(ctx); } } [CommandGroup("pls", null)] internal static class WhitelistCommands { [Command("addwhitelist", "awl", null, "Pre-register a SteamID and Known As to the whitelist.", null, true)] public static void AddWhitelistCommand(ChatCommandContext ctx, string steamIdInput = "", string knownAs = "") { if (string.IsNullOrWhiteSpace(steamIdInput) || string.IsNullOrWhiteSpace(knownAs)) { WhitelistService.ReplyWhitelistHelp(ctx); } else { WhitelistService.AddWhitelist(ctx, steamIdInput, knownAs); } } [Command("removewhitelist", "rwl", null, "Remove a player from the whitelist by SteamID or Known As.", null, true)] public static void RemoveWhitelistCommand(ChatCommandContext ctx, string steamIdOrKnownAs = "") { if (string.IsNullOrWhiteSpace(steamIdOrKnownAs)) { WhitelistService.ReplyWhitelistHelp(ctx); } else { WhitelistService.RemoveWhitelist(ctx, steamIdOrKnownAs); } } [Command("showwhitelist", "swl", null, "Show all whitelisted players.", null, true)] public static void ShowWhitelistCommand(ChatCommandContext ctx) { WhitelistService.ShowWhitelist(ctx); } [Command("helpwhitelist", "hwl", null, "Show whitelist commands and feature status.", null, true)] public static void HelpWhitelistCommand(ChatCommandContext ctx) { WhitelistService.ReplyWhitelistHelp(ctx); } } }