Decompiled source of ScarletRCON v1.1.6

ScarletRCON.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Net.Sockets;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using RCONServerLib;
using ScarletRCON.CommandSystem;
using ScarletRCON.Data;
using ScarletRCON.Services;
using ScarletRCON.Systems;
using ScarletRCON.Utils;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("markvaaz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("V Rising RCON Command Framework")]
[assembly: AssemblyFileVersion("1.1.6.0")]
[assembly: AssemblyInformationalVersion("1.1.6+8835d69826d4081834644d21d7a525acd1d08d3a")]
[assembly: AssemblyProduct("ScarletRCON")]
[assembly: AssemblyTitle("ScarletRCON")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScarletRCON
{
	public static class CommandExecutor
	{
		private static readonly Queue<(Func<object> func, TaskCompletionSource<object> tcs)> _queue = new Queue<(Func<object>, TaskCompletionSource<object>)>();

		public static int Count
		{
			get
			{
				lock (_queue)
				{
					return _queue.Count;
				}
			}
		}

		public static string Enqueue(Func<object> func)
		{
			TaskCompletionSource<object> taskCompletionSource = new TaskCompletionSource<object>();
			lock (_queue)
			{
				_queue.Enqueue((func, taskCompletionSource));
			}
			return taskCompletionSource.Task.GetAwaiter().GetResult()?.ToString();
		}

		public static void ProcessQueue()
		{
			while (true)
			{
				(Func<object>, TaskCompletionSource<object>) tuple;
				lock (_queue)
				{
					if (_queue.Count == 0)
					{
						break;
					}
					tuple = _queue.Dequeue();
				}
				try
				{
					object result = tuple.Item1();
					tuple.Item2.SetResult(result);
				}
				catch (Exception exception)
				{
					tuple.Item2.SetException(exception);
				}
			}
		}
	}
	internal static class Core
	{
		public static bool hasInitialized;

		public static World Server => GetServerWorld() ?? throw new Exception("There is no Server world (yet)...");

		public static EntityManager EntityManager => Server.EntityManager;

		public static ServerGameManager GameManager => Server.GetExistingSystemManaged<ServerScriptMapper>().GetServerGameManager();

		public static ServerBootstrapSystem ServerBootstrapSystem => Server.GetExistingSystemManaged<ServerBootstrapSystem>();

		public static AdminAuthSystem AdminAuthSystem => Server.GetExistingSystemManaged<AdminAuthSystem>();

		public static KickBanSystem_Server KickBanSystem => Server.GetExistingSystemManaged<KickBanSystem_Server>();

		public static UnitSpawnerUpdateSystem UnitSpawnerUpdateSystem => Server.GetExistingSystemManaged<UnitSpawnerUpdateSystem>();

		public static EntityCommandBufferSystem EntityCommandBufferSystem => Server.GetExistingSystemManaged<EntityCommandBufferSystem>();

		public static DebugEventsSystem DebugEventsSystem => Server.GetExistingSystemManaged<DebugEventsSystem>();

		public static TriggerPersistenceSaveSystem TriggerPersistenceSaveSystem => Server.GetExistingSystemManaged<TriggerPersistenceSaveSystem>();

		public static ManualLogSource Log => Plugin.LogInstance;

		public static void Initialize()
		{
			if (!hasInitialized)
			{
				hasInitialized = true;
			}
		}

		private static World GetServerWorld()
		{
			return ((IEnumerable<World>)World.s_AllWorlds.ToArray()).FirstOrDefault((Func<World, bool>)((World world) => world.Name == "Server"));
		}
	}
	public static class ECSExtensions
	{
		public static EntityManager EntityManager => Core.Server.EntityManager;

		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		public static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
			Marshal.Copy(intPtr, array, 0, num);
			Marshal.FreeHGlobal(intPtr);
			return array;
		}

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//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_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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static bool Has<T>(this Entity entity)
		{
			//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_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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static void Add<T>(this Entity entity)
		{
			//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_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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//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_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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static float3 GetPosition(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0010: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			if (!((EntityManager)(ref entityManager)).HasComponent<Translation>(entity))
			{
				return float3.zero;
			}
			entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).GetComponentData<Translation>(entity).Value;
		}
	}
	[BepInPlugin("markvaaz.ScarletRCON", "ScarletRCON", "1.1.6")]
	public class Plugin : BasePlugin
	{
		private static Harmony _harmony;

		public static Harmony Harmony => _harmony;

		public static Plugin Instance { get; private set; }

		public static ManualLogSource LogInstance { get; private set; }

		public override void Load()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			Instance = this;
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("markvaaz.ScarletRCON");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.6");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			_harmony = new Harmony("markvaaz.ScarletRCON");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

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

		public const string PLUGIN_NAME = "ScarletRCON";

		public const string PLUGIN_VERSION = "1.1.6";
	}
}
namespace ScarletRCON.Utils
{
	public static class StringExtensions
	{
		public static string HighlightColor = "#a963ff";

		public static string HighlightErrorColor = "#ff4040";

		public static string HighlightWarningColor = "#ffff00";

		public static string TextColor = "#ffffff";

		public static string ErrorTextColor = "#ff8f8f";

		public static string WarningTextColor = "#ffff9e";

		public static string Bold(this string text)
		{
			return "<b>" + text + "</b>";
		}

		public static string Italic(this string text)
		{
			return "<i>" + text + "</i>";
		}

		public static string Underline(this string text)
		{
			return "<u>" + text + "</u>";
		}

		public static string Red(this string text)
		{
			return "<color=red>" + text + "</color>";
		}

		public static string Green(this string text)
		{
			return "<color=green>" + text + "</color>";
		}

		public static string Blue(this string text)
		{
			return "<color=blue>" + text + "</color>";
		}

		public static string Yellow(this string text)
		{
			return "<color=yellow>" + text + "</color>";
		}

		public static string White(this string text)
		{
			return "<color=white>" + text + "</color>";
		}

		public static string Black(this string text)
		{
			return "<color=black>" + text + "</color>";
		}

		public static string Orange(this string text)
		{
			return "<color=orange>" + text + "</color>";
		}

		public static string Lime(this string text)
		{
			return "<color=#00FF00>" + text + "</color>";
		}

		public static string Gray(this string text)
		{
			return "<color=#cccccc>" + text + "</color>";
		}

		public static string Hex(this string hex, string text)
		{
			return $"<color={hex}>{text}</color>";
		}

		public static string Format(this string text, List<string> highlightColors = null)
		{
			if (highlightColors == null)
			{
				highlightColors = new List<string>(1) { HighlightColor };
			}
			return ApplyFormatting(text, TextColor, highlightColors);
		}

		public static string FormatError(this string text)
		{
			return ApplyFormatting(text, ErrorTextColor, new List<string>(1) { HighlightErrorColor });
		}

		public static string FormatWarning(this string text)
		{
			return ApplyFormatting(text, WarningTextColor, new List<string>(1) { HighlightWarningColor });
		}

		private static string ApplyFormatting(string text, string baseColor, List<string> highlightColors)
		{
			string pattern = "\\*\\*(.*?)\\*\\*";
			string pattern2 = "\\*(.*?)\\*";
			string pattern3 = "__(.*?)__";
			string pattern4 = "~(.*?)~";
			string input = Regex.Replace(text, pattern, (Match m) => m.Groups[1].Value.Bold());
			input = Regex.Replace(input, pattern2, (Match m) => m.Groups[1].Value.Italic());
			input = Regex.Replace(input, pattern3, (Match m) => m.Groups[1].Value.Underline());
			int highlightIndex = 0;
			input = Regex.Replace(input, pattern4, delegate(Match m)
			{
				string text2 = ((highlightIndex < highlightColors.Count) ? highlightColors[highlightIndex] : HighlightColor);
				if (text2 == null)
				{
					text2 = HighlightColor;
				}
				highlightIndex++;
				return text2.Hex(m.Groups[1].Value);
			});
			return baseColor.Hex(input);
		}
	}
}
namespace ScarletRCON.Systems
{
	public static class BuffUtilitySystem
	{
		public static bool TryApplyBuff(Entity entity, PrefabGUID prefabGUID, float duration = -1f)
		{
			//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_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_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_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_002a: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_0056: 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_005e: 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_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00aa: 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_00ba: 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)
			try
			{
				ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
				val.BuffPrefabGUID = prefabGUID;
				ApplyBuffDebugEvent val2 = val;
				FromCharacter val3 = default(FromCharacter);
				val3.Character = entity;
				val3.User = entity;
				FromCharacter val4 = val3;
				Core.DebugEventsSystem.ApplyBuff(val4, val2);
				Entity entity2 = default(Entity);
				if (!BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, entity, PrefabIdentifier.op_Implicit(prefabGUID), ref entity2))
				{
					return false;
				}
				if (entity2.Has<CreateGameplayEventsOnSpawn>())
				{
					entity2.Remove<CreateGameplayEventsOnSpawn>();
				}
				if (entity2.Has<GameplayEventListeners>())
				{
					entity2.Remove<GameplayEventListeners>();
				}
				if (duration != -1f)
				{
					LifeTime componentData = entity2.Read<LifeTime>();
					componentData.Duration = duration;
					componentData.EndAction = (LifeTimeEndAction)2;
					entity2.Write<LifeTime>(componentData);
				}
				if (duration == -1f && entity2.Has<LifeTime>())
				{
					LifeTime componentData2 = entity2.Read<LifeTime>();
					componentData2.EndAction = (LifeTimeEndAction)0;
					entity2.Write<LifeTime>(componentData2);
				}
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("An error occurred while applying buff: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val5);
				return false;
			}
		}

		public static bool HasBuff(Entity entity, PrefabGUID prefabGUID)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			return BuffUtility.HasBuff<EntityManager>(Core.EntityManager, entity, PrefabIdentifier.op_Implicit(prefabGUID));
		}

		public static void RemoveBuff(Entity entity, PrefabGUID prefabGUID)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, entity, PrefabIdentifier.op_Implicit(prefabGUID), ref val))
			{
				DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
			}
		}
	}
	public static class EntitySpawnerSystem
	{
		private static Entity _entity;

		public static void Spawn(PrefabGUID prefabGUID, float3 position, int count = 1, int minRange = 1, int maxRange = 8, float lifeTime = 10f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Core.UnitSpawnerUpdateSystem.SpawnUnit(_entity, prefabGUID, position, count, (float)minRange, (float)maxRange, lifeTime);
		}
	}
	public static class SystemMessages
	{
		public static void Send(User user, string message)
		{
			//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)
			FixedString512Bytes val = default(FixedString512Bytes);
			((FixedString512Bytes)(ref val))..ctor(message.Format());
			ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, user, ref val);
		}

		public static void SendAll(string message)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			FixedString512Bytes val = default(FixedString512Bytes);
			((FixedString512Bytes)(ref val))..ctor(message.Format());
			ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val);
		}
	}
	internal class TeleportSystem
	{
		public static void TeleportToEntity(Entity entity, Entity target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			float3 position = target.GetPosition();
			TeleportToPosition(entity, position);
		}

		public static void TeleportToPosition(Entity entity, float3 position)
		{
			//IL_0000: 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_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_000e: 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_0018: 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_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_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_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_005a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_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)
			//IL_006b: 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)
			//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_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_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_0091: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Has<SpawnTransform>())
			{
				SpawnTransform componentData = entity.Read<SpawnTransform>();
				componentData.Position = position;
				entity.Write<SpawnTransform>(componentData);
			}
			if (entity.Has<Height>())
			{
				Height componentData2 = entity.Read<Height>();
				componentData2.LastPosition = position;
				entity.Write<Height>(componentData2);
			}
			if (entity.Has<LocalTransform>())
			{
				LocalTransform componentData3 = entity.Read<LocalTransform>();
				componentData3.Position = position;
				entity.Write<LocalTransform>(componentData3);
			}
			if (entity.Has<Translation>())
			{
				Translation componentData4 = entity.Read<Translation>();
				componentData4.Value = position;
				entity.Write<Translation>(componentData4);
			}
			if (entity.Has<LastTranslation>())
			{
				LastTranslation componentData5 = entity.Read<LastTranslation>();
				componentData5.Value = position;
				entity.Write<LastTranslation>(componentData5);
			}
		}
	}
}
namespace ScarletRCON.Services
{
	public static class AdminService
	{
		public static void AddAdmin(ulong playerId)
		{
			//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_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_0030: 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_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_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_0057: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerService.TryGetById(playerId, out var playerData))
			{
				EntityManager entityManager = Core.EntityManager;
				((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadWrite<FromCharacter>(),
					ComponentType.ReadWrite<AdminAuthEvent>()
				}).Write<FromCharacter>(new FromCharacter
				{
					Character = playerData.CharacterEntity,
					User = playerData.UserEntity
				});
			}
			Core.AdminAuthSystem._LocalAdminList.Add(playerId);
			Core.AdminAuthSystem._LocalAdminList.Save();
			Core.AdminAuthSystem._LocalAdminList.Refresh(false);
		}

		public static void RemoveAdmin(ulong playerId)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_0061: 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_0071: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerService.TryGetById(playerId, out var playerData))
			{
				if (playerData.UserEntity.Has<AdminUser>())
				{
					playerData.UserEntity.Remove<AdminUser>();
				}
				playerData.UserEntity.Write<User>(playerData.UserEntity.Read<User>());
				EntityManager entityManager = Core.EntityManager;
				((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadWrite<FromCharacter>(),
					ComponentType.ReadWrite<DeauthAdminEvent>()
				}).Write<FromCharacter>(new FromCharacter
				{
					Character = playerData.CharacterEntity,
					User = playerData.UserEntity
				});
			}
			Core.AdminAuthSystem._LocalAdminList.Remove(playerId);
			Core.AdminAuthSystem._LocalAdminList.Save();
			Core.AdminAuthSystem._LocalAdminList.Refresh(false);
		}

		public static bool IsAdmin(ulong platformID)
		{
			return Core.AdminAuthSystem._LocalAdminList.Contains(platformID);
		}
	}
	public class InventoryService
	{
		private static ServerGameManager GameManager = Core.GameManager;

		private static EntityManager EntityManager = Core.EntityManager;

		public static void AddItemToInventory(Entity entity, PrefabGUID guid, int amount)
		{
			//IL_0005: 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_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_001a: Unknown result type (might be due to invalid IL or missing references)
			if (((ServerGameManager)(ref GameManager)).HasFullInventory(entity))
			{
				return;
			}
			try
			{
				ServerGameManager gameManager = Core.GameManager;
				((ServerGameManager)(ref gameManager)).TryAddInventoryItem(entity, guid, amount);
			}
			catch (Exception ex)
			{
				Core.Log.LogError((object)ex);
			}
		}

		public static List<InventoryBuffer> GetInventoryItems(Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0027: Unknown result type (might be due to invalid IL or missing references)
			int inventorySize = InventoryUtilities.GetInventorySize<EntityManager>(EntityManager, entity);
			List<InventoryBuffer> list = new List<InventoryBuffer>();
			InventoryBuffer item = default(InventoryBuffer);
			for (int i = 0; i < inventorySize; i++)
			{
				if (InventoryUtilities.TryGetItemAtSlot<EntityManager>(EntityManager, entity, i, ref item))
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static int GetInventorySize(Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return InventoryUtilities.GetInventorySize<EntityManager>(EntityManager, entity);
		}

		public static int GetItemAmount(Entity entity, PrefabGUID guid)
		{
			//IL_0000: 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_0024: 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)
			int inventorySize = GetInventorySize(entity);
			int num = 0;
			InventoryBuffer val = default(InventoryBuffer);
			for (int i = 0; i < inventorySize; i++)
			{
				if (InventoryUtilities.TryGetItemAtSlot<EntityManager>(EntityManager, entity, i, ref val) && ((PrefabGUID)(ref val.ItemType)).Equals(guid))
				{
					num += val.Amount;
				}
			}
			return num;
		}

		public static bool IsFull(Entity entity)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return ((ServerGameManager)(ref GameManager)).HasFullInventory(entity);
		}

		public static bool HasAmount(Entity entity, PrefabGUID guid, int amount)
		{
			//IL_0005: 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 ((ServerGameManager)(ref GameManager)).GetInventoryItemCount(entity, guid) >= amount;
		}

		public static bool RemoveItemFromInventory(Entity entity, PrefabGUID guid, int amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			Entity val = default(Entity);
			if (!InventoryUtilities.TryGetInventoryEntity<EntityManager>(EntityManager, entity, ref val, 0))
			{
				return false;
			}
			if (GetItemAmount(entity, guid) < amount)
			{
				return false;
			}
			((ServerGameManager)(ref GameManager)).TryRemoveInventoryItem(val, guid, amount);
			return true;
		}

		internal static void AddItemToInventory(object localCharacter, PrefabGUID prefab, int quantidade)
		{
			throw new NotImplementedException();
		}
	}
	public static class KickBanService
	{
		public static void AddBan(ulong platformID)
		{
			//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_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_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_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerService.TryGetById(platformID, out var playerData) || playerData.IsOnline)
			{
				EntityManager entityManager = Core.EntityManager;
				((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadWrite<FromCharacter>(),
					ComponentType.ReadWrite<BanEvent>()
				}).Write<FromCharacter>(new FromCharacter
				{
					Character = playerData.CharacterEntity,
					User = playerData.UserEntity
				});
			}
			Core.KickBanSystem._LocalBanList.Add(platformID);
			Core.KickBanSystem._LocalBanList.Save();
			Core.KickBanSystem._LocalBanList.Refresh(false);
		}

		public static void RemoveBan(ulong platformID)
		{
			Core.KickBanSystem._LocalBanList.Remove(platformID);
			Core.KickBanSystem._LocalBanList.Save();
			Core.KickBanSystem._LocalBanList.Refresh(false);
		}

		public static bool IsBanned(ulong platformID)
		{
			return Core.KickBanSystem.IsBanned(platformID);
		}

		public static void Kick(ulong platformID, int userIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_003a: 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_0050: 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)
			EntityManager entityManager = Core.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<NetworkEventType>(),
				ComponentType.ReadOnly<SendEventToUser>(),
				ComponentType.ReadOnly<KickEvent>()
			});
			entity.Write<KickEvent>(new KickEvent
			{
				PlatformId = platformID
			});
			entity.Write<NetworkEventType>(new NetworkEventType
			{
				EventId = NetworkEvents.EventId_KickEvent,
				IsAdminEvent = false,
				IsDebugEvent = false
			});
		}
	}
	public static class PlayerService
	{
		public static readonly Dictionary<string, PlayerData> PlayerNames = new Dictionary<string, PlayerData>();

		public static readonly Dictionary<ulong, PlayerData> PlayerIds = new Dictionary<ulong, PlayerData>();

		private static readonly List<PlayerData> UnnamedPlayers = new List<PlayerData>();

		public static readonly List<PlayerData> AllPlayers = new List<PlayerData>();

		public static void Initialize()
		{
			//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_0019: 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_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_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_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)
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			ClearCache();
			EntityQueryBuilder val = default(EntityQueryBuilder);
			((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly<User>());
			((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2);
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val);
			try
			{
				Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
				while (enumerator.MoveNext())
				{
					SetPlayerCache(enumerator.Current);
				}
			}
			catch (Exception ex)
			{
				Core.Log.LogError((object)ex);
			}
			finally
			{
				((EntityQuery)(ref val2)).Dispose();
				((EntityQueryBuilder)(ref val)).Dispose();
			}
		}

		public static void ClearCache()
		{
			PlayerNames.Clear();
			PlayerIds.Clear();
		}

		public static void SetPlayerCache(Entity userEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0080: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			User val = userEntity.Read<User>();
			string text = ((object)(FixedString64Bytes)(ref val.CharacterName)).ToString();
			if (!PlayerIds.ContainsKey(val.PlatformId))
			{
				PlayerData playerData = new PlayerData();
				if (string.IsNullOrEmpty(text))
				{
					UnnamedPlayers.Add(playerData);
				}
				else
				{
					PlayerNames[text.ToLower()] = playerData;
					playerData.SetName(text);
				}
				PlayerIds[val.PlatformId] = playerData;
				AllPlayers.Add(playerData);
			}
			PlayerData playerData2 = PlayerIds[val.PlatformId];
			playerData2.UserEntity = userEntity;
			if (!string.IsNullOrEmpty(playerData2.Name) && playerData2.Name != text)
			{
				PlayerNames.Remove(playerData2.Name.ToLower());
				playerData2.SetName(text);
				PlayerNames[text.ToLower()] = playerData2;
			}
		}

		public static void ClearOfflinePlayers()
		{
			AllPlayers.RemoveAll(delegate(PlayerData p)
			{
				bool result = !p.IsOnline;
				PlayerIds.Remove(p.PlatformId);
				PlayerNames.Remove(p.Name.ToLower());
				return result;
			});
		}

		public static List<PlayerData> GetAdmins()
		{
			List<PlayerData> list = new List<PlayerData>();
			list.AddRange(AllPlayers.Where((PlayerData p) => p.IsAdmin));
			return list;
		}

		public static List<PlayerData> GetAllConnected()
		{
			List<PlayerData> list = new List<PlayerData>();
			list.AddRange(AllPlayers.Where((PlayerData p) => p.IsOnline));
			return list;
		}

		public static bool TryGetById(ulong platformId, out PlayerData playerData)
		{
			return PlayerIds.TryGetValue(platformId, out playerData);
		}

		public static bool TryGetByName(string name, out PlayerData playerData)
		{
			if (PlayerNames.TryGetValue(name.ToLower(), out playerData))
			{
				return true;
			}
			if (UnnamedPlayers.Count == 0)
			{
				return false;
			}
			playerData = UnnamedPlayers.FirstOrDefault((PlayerData p) => p.Name.ToLower() == name.ToLower());
			bool num = playerData != null;
			if (num)
			{
				PlayerNames[name.ToLower()] = playerData;
				UnnamedPlayers.Remove(playerData);
			}
			return num;
		}
	}
}
namespace ScarletRCON.Patches
{
	[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
	public static class InitializationPatch
	{
		[HarmonyPostfix]
		public static void OneShot_AfterLoad_InitializationPatch()
		{
			Core.Initialize();
			Plugin.Harmony.Unpatch((MethodBase)typeof(SpawnTeamSystem_OnPersistenceLoad).GetMethod("OnUpdate"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch"));
		}
	}
	[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")]
	public static class OnUserConnected_Patch
	{
		public static void Postfix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//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_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_003a: 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)
			if (!Core.hasInitialized)
			{
				Core.Initialize();
			}
			try
			{
				int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
				ServerClient val = ((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num];
				Entity userEntity = val.UserEntity;
				if (val != null)
				{
					Entity userEntity2 = val.UserEntity;
					if (!((Entity)(ref userEntity2)).Equals(Entity.Null))
					{
						PlayerService.SetPlayerCache(userEntity);
						return;
					}
				}
				Core.Log.LogWarning((object)"Failed to get user entity.");
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("An error occurred while connecting player: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val2);
			}
		}
	}
	[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserDisconnected")]
	public static class OnUserDisconnected_Patch
	{
		private static void Prefix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId, ConnectionStatusChangeReason connectionStatusReason)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!Core.hasInitialized)
			{
				Core.Initialize();
			}
			if ((int)connectionStatusReason == 5)
			{
				return;
			}
			try
			{
				int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
				PlayerService.SetPlayerCache(((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num].UserEntity);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(46, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("An error occurred while disconnecting player: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
			}
		}
	}
	[HarmonyPatch(typeof(RconListenerSystem), "OnCreate")]
	internal class RconInitializePatch
	{
		private static RemoteConServer server;

		private static void Postfix(RconListenerSystem __instance)
		{
			server = __instance._Server;
			CommandEventHandler val = DelegateSupport.ConvertDelegate<CommandEventHandler>((Delegate)new Action<string, IList<string>>(OnCommandReceived));
			server.UseCustomCommandHandler = true;
			CommandHandler.Initialize();
			server.OnCommandReceived += val;
			server.TimeoutSeconds = 900;
			server.MaxPasswordTries = 3u;
			server.BanMinutes = 30;
			server.MaxConnections = 1u;
		}

		public static Socket GetSocket()
		{
			Enumerator<TcpClient> enumerator = server._clients.GetEnumerator();
			while (enumerator.MoveNext())
			{
				TcpClient current = enumerator.Current;
				if (current.Connected)
				{
					return current.GetStream()._streamSocket;
				}
			}
			return null;
		}

		private static void OnCommandReceived(string cmd, IList<string> args)
		{
			try
			{
				List<string> list = new List<string>();
				int num = 0;
				while (true)
				{
					try
					{
						string text = args[num];
						if (text == null)
						{
							break;
						}
						list.Add(text);
						num++;
						continue;
					}
					catch
					{
					}
					break;
				}
				Send(CommandHandler.HandleCommand(cmd.ToLower(), list));
			}
			catch (Exception value)
			{
				Console.WriteLine($"RCON command error: {value}");
			}
		}

		public static void Send(string message)
		{
			Socket socket = GetSocket();
			if (socket != null)
			{
				SendRconPacket(socket, message);
			}
		}

		private static void SendRconPacket(Socket socket, string payload)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(payload);
			int num = 8 + bytes.Length + 2;
			byte[] array = new byte[4 + num];
			BitConverter.GetBytes(num).CopyTo(array, 0);
			BitConverter.GetBytes(0).CopyTo(array, 4);
			BitConverter.GetBytes(0).CopyTo(array, 8);
			Array.Copy(bytes, 0, array, 12, bytes.Length);
			array[12 + bytes.Length] = 0;
			array[13 + bytes.Length] = 0;
			Il2CppStructArray<byte> val = new Il2CppStructArray<byte>((long)array.Length);
			for (int i = 0; i < array.Length; i++)
			{
				((Il2CppArrayBase<byte>)(object)val)[i] = array[i];
			}
			socket.Send(val, 0, array.Length, (SocketFlags)0);
		}
	}
	[HarmonyPatch(typeof(RconListenerSystem), "OnUpdate")]
	internal class RconUpdatePatch
	{
		private static void Postfix()
		{
			if (CommandExecutor.Count != 0)
			{
				CommandExecutor.ProcessQueue();
			}
		}
	}
	internal static class StringExtensions
	{
		public static IntPtr ToIntPtr(this string str)
		{
			return IL2CPP.ManagedStringToIl2Cpp(str);
		}
	}
}
namespace ScarletRCON.Data
{
	public class PlayerData
	{
		public Entity UserEntity;

		private string _name;

		public User User => UserEntity.Read<User>();

		public string Name
		{
			get
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (string.IsNullOrEmpty(_name))
				{
					User user = User;
					_name = ((object)(FixedString64Bytes)(ref user.CharacterName)).ToString();
				}
				return _name;
			}
		}

		public Entity CharacterEntity => User.LocalCharacter._Entity;

		public ulong PlatformId => User.PlatformId;

		public bool IsOnline => User.IsConnected;

		public bool IsAdmin => User.IsAdmin;

		public DateTime ConnectedSince => DateTimeOffset.FromUnixTimeSeconds(User.TimeLastConnected).DateTime;

		public void SetName(string name)
		{
			_name = name;
		}
	}
}
namespace ScarletRCON.Commands
{
	[RconCommandCategory("Help")]
	public static class HelpCommand
	{
		[RconCommand("help", "Show info about a specific command.", null)]
		public static string Help(string commandName)
		{
			if (CommandHandler.TryGetCommands(commandName, out var commands))
			{
				string value = "\u001b[97m";
				string text = "\u001b[90m";
				string text2 = "\u001b[0m";
				string text3 = "";
				{
					foreach (RconCommandDefinition item in commands)
					{
						text3 += $"{value}{item.Name}{text2}: {text}{item.Description}{text2}\n";
						text3 = ((!string.IsNullOrEmpty(item.Usage)) ? (text3 + $"{text}- usage: {item.Usage}{text2}\n") : (text3 + text + "- this command has no parameters" + text2 + "\n"));
					}
					return text3;
				}
			}
			return "Unknown command '" + commandName + "'";
		}

		[RconCommand("help", "List all commands.", null)]
		public static string ListAll()
		{
			string text = "";
			foreach (KeyValuePair<string, List<RconCommandDefinition>> orderedCategory in GetOrderedCategories())
			{
				text = text + "\n\u001b[97m" + orderedCategory.Key + "\u001b[0m:\n";
				foreach (RconCommandDefinition item in orderedCategory.Value.OrderBy<RconCommandDefinition, string>((RconCommandDefinition c) => c.Name, StringComparer.OrdinalIgnoreCase))
				{
					text += $"\u001b[37m- {item.Name}\u001b[0m:\u001b[90m{(string.IsNullOrEmpty(item.Usage) ? "" : (" " + item.Usage))} - {item.Description}\u001b[0m\n";
				}
			}
			return text + "\nTotal commands: " + CommandHandler.Commands.Count;
		}

		public static IEnumerable<KeyValuePair<string, List<RconCommandDefinition>>> GetOrderedCategories()
		{
			Dictionary<string, List<RconCommandDefinition>> dictionary = new Dictionary<string, List<RconCommandDefinition>>(StringComparer.OrdinalIgnoreCase);
			foreach (KeyValuePair<string, List<RconCommandDefinition>> commandCategory in CommandHandler.CommandCategories)
			{
				string key = commandCategory.Key;
				List<RconCommandDefinition> value = commandCategory.Value;
				List<RconCommandDefinition> list = new List<RconCommandDefinition>(value.Count);
				list.AddRange(value);
				dictionary[key] = list;
			}
			foreach (KeyValuePair<string, List<RconCommandDefinition>> customCommandCategory in CommandHandler.CustomCommandCategories)
			{
				if (dictionary.TryGetValue(customCommandCategory.Key, out var value2))
				{
					value2.AddRange(customCommandCategory.Value);
					continue;
				}
				string key2 = customCommandCategory.Key;
				List<RconCommandDefinition> value = customCommandCategory.Value;
				List<RconCommandDefinition> list2 = new List<RconCommandDefinition>(value.Count);
				list2.AddRange(value);
				dictionary[key2] = list2;
			}
			return dictionary.OrderBy<KeyValuePair<string, List<RconCommandDefinition>>, string>((KeyValuePair<string, List<RconCommandDefinition>> x) => x.Key, StringComparer.OrdinalIgnoreCase);
		}
	}
	[RconCommandCategory("Inventory Management")]
	public static class InventoryCommands
	{
		[RconCommand("giveitem", "Give an item to a connected player.", null)]
		public static string Give(string playerName, string prefabGUID, int amount)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			PrefabGUID guid = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID, ref guid))
			{
				return "Invalid PrefabGUID.";
			}
			if (InventoryService.IsFull(playerData.CharacterEntity))
			{
				return "Player '" + playerName + "' has a full inventory.";
			}
			InventoryService.AddItemToInventory(playerData.CharacterEntity, guid, amount);
			return $"Given {amount} {((PrefabGUID)(ref guid)).GuidHash} to {playerName}.";
		}

		[RconCommand("giveitemall", "Give an item to all connected players.", null)]
		public static string GiveAll(int prefabGUID, int amount)
		{
			//IL_0034: 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_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)
			PrefabGUID val = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref val))
			{
				return "Invalid Prefab GUID.";
			}
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				if (allPlayer.IsOnline && !InventoryService.IsFull(allPlayer.CharacterEntity))
				{
					InventoryService.AddItemToInventory(allPlayer.CharacterEntity, val, amount);
				}
			}
			return $"Given {amount} {val} to all players.";
		}

		[RconCommand("removeitem", "Remove an item from a connected player's inventory.", null)]
		public static string RemoveItem(string playerName, string prefabGUID, int amount)
		{
			//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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			PrefabGUID guid = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID, ref guid))
			{
				return "Invalid PrefabGUID.";
			}
			if (InventoryService.HasAmount(playerData.CharacterEntity, guid, amount))
			{
				InventoryService.RemoveItemFromInventory(playerData.CharacterEntity, guid, amount);
				return $"Removed {amount} {((PrefabGUID)(ref guid)).GuidHash} from {playerName}'s inventory.";
			}
			return $"Player '{playerName}' does not have {amount} {((PrefabGUID)(ref guid)).GuidHash} in their inventory.";
		}

		[RconCommand("removeitemall", "Remove an item from all connected players' inventories.", null)]
		public static string RemoveItemAll(int prefabGUID, int amount)
		{
			//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_0095: 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)
			PrefabGUID val = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref val))
			{
				return "Invalid Prefab GUID.";
			}
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				if (allPlayer.IsOnline && InventoryService.HasAmount(allPlayer.CharacterEntity, val, amount))
				{
					InventoryService.RemoveItemFromInventory(allPlayer.CharacterEntity, val, amount);
				}
			}
			return $"Removed {amount} {val} from all players' inventories.";
		}
	}
	[RconCommandCategory("Messaging")]
	public static class MessagingCommands
	{
		[RconCommand("announce", "Send a message to all connected players.", "<message>")]
		public static string Announce(List<string> args)
		{
			string text = string.Join(" ", args);
			SystemMessages.SendAll(text);
			return "Sent announcement: " + text;
		}

		[RconCommand("announcerestart", "Announce server restart in X minutes.", "<minutes>")]
		public static string AnnounceRestart(int minutes)
		{
			string text = $"The server will restart in {minutes} minutes!";
			SystemMessages.SendAll(text);
			return "Sent announcement: " + text;
		}

		[RconCommand("private", "Send a private message to a connected player.", "<playerName> <message>")]
		public static string PrivateMessage(string playerName, string message)
		{
			//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)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			SystemMessages.Send(playerData.UserEntity.Read<User>(), message);
			return "Sent private message to " + playerData.Name + ": " + message;
		}
	}
	[RconCommandCategory("Player Administration")]
	public static class PlayerCommand
	{
		private static PrefabGUID FreezeBuffGUID = new PrefabGUID(-1527408583);

		private static PrefabGUID WoundedBuffGUID = new PrefabGUID(-1992158531);

		[RconCommand("playerinfo", "Show info about a connected player.", null)]
		public static string PlayerInfo(string playerName)
		{
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			string text = "- Character Name: " + playerData.Name + "\n";
			text += $"- Steam ID: {playerData.PlatformId}\n";
			text += $"- Profile URL: https://steamcommunity.com/profiles/{playerData.PlatformId}\n";
			if (playerData.IsOnline)
			{
				text += $"- Connected Since: {playerData.ConnectedSince}\n";
			}
			return text + "- " + (playerData.IsOnline ? "Online" : "Offline") + "\n";
		}

		[RconCommand("kick", "Kick a connected player.", null)]
		public static string Kick(string playerName)
		{
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			SystemMessages.SendAll(playerData.Name + " got ~kicked~ by an admin.");
			KickBanService.Kick(playerData.PlatformId, playerData.UserEntity.Index);
			return "Kicked " + playerName + ".";
		}

		[RconCommand("ban", " Ban a player by ID.", null)]
		public static string BanById(ulong playerId)
		{
			if (!KickBanService.IsBanned(playerId))
			{
				KickBanService.AddBan(playerId);
				return $"Banned {playerId} by ID.";
			}
			return $"Player '{playerId}' is already banned.";
		}

		[RconCommand("ban", "Ban a connected player by name.", null)]
		public static string BanByName(string playerName)
		{
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.\nTry using the ID instead.";
			}
			if (KickBanService.IsBanned(playerData.PlatformId))
			{
				return "Player '" + playerName + "' is already banned.";
			}
			SystemMessages.SendAll(playerData.Name + " got ~banned~ by an admin.");
			KickBanService.AddBan(playerData.PlatformId);
			return "Banned " + playerName + " by name.";
		}

		[RconCommand("unban", "Unban a player by ID.", null)]
		public static string Unban(ulong playerId)
		{
			if (KickBanService.IsBanned(playerId))
			{
				KickBanService.RemoveBan(playerId);
				return $"Unbanned {playerId}.";
			}
			return $"Player '{playerId}' is not banned.";
		}

		[RconCommand("addadmin", "Add a player as admin by ID.", null)]
		public static string AddAdmin(ulong playerId)
		{
			if (!AdminService.IsAdmin(playerId))
			{
				AdminService.AddAdmin(playerId);
				return $"Added {playerId} as admin.";
			}
			return $"Player '{playerId}' is already an admin.";
		}

		[RconCommand("addadmin", "Add a connected player as admin.", null)]
		public static string AddAdmin(string playerName)
		{
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			if (playerData.IsAdmin)
			{
				return "Player '" + playerName + "' is already an admin.";
			}
			AdminService.AddAdmin(playerData.PlatformId);
			return "Added " + playerName + " as admin.";
		}

		[RconCommand("removeadmin", "Remove a player as admin by ID.", null)]
		public static string RemoveAdmin(ulong playerId)
		{
			if (AdminService.IsAdmin(playerId))
			{
				AdminService.RemoveAdmin(playerId);
				return $"Removed {playerId} as admin.";
			}
			return $"Player '{playerId}' is not an admin.";
		}

		[RconCommand("removeadmin", "Remove a connected player as admin.", null)]
		public static string RemoveAdmin(string playerName)
		{
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			if (!playerData.IsAdmin)
			{
				return "Player '" + playerName + "' is not an admin.";
			}
			AdminService.RemoveAdmin(playerData.PlatformId);
			return "Removed " + playerName + " as admin.";
		}

		[RconCommand("buff", "Apply a buff to a connected player.", null)]
		public static string BuffPlayer(string playerName, string prefabGUID, int duration)
		{
			//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_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)
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			PrefabGUID prefabGUID2 = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID, ref prefabGUID2))
			{
				return "Invalid PrefabGUID.";
			}
			if (!BuffUtilitySystem.HasBuff(playerData.CharacterEntity, prefabGUID2))
			{
				if (BuffUtilitySystem.TryApplyBuff(playerData.CharacterEntity, prefabGUID2, duration))
				{
					return $"Applied buff {prefabGUID} to {playerName} for {duration} seconds.";
				}
				return $"Failed to apply buff {prefabGUID} to {playerName}.";
			}
			return $"Player {playerName} already has buff {((PrefabGUID)(ref prefabGUID2)).GuidHash}.";
		}

		[RconCommand("debuff", "Remove a buff from a connected player.", null)]
		public static string RemoveBuff(string playerName, string prefabGUID)
		{
			//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_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)
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			PrefabGUID prefabGUID2 = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID, ref prefabGUID2))
			{
				return "Invalid PrefabGUID.";
			}
			if (BuffUtilitySystem.HasBuff(playerData.CharacterEntity, prefabGUID2))
			{
				BuffUtilitySystem.RemoveBuff(playerData.CharacterEntity, prefabGUID2);
				return $"Removed buff {prefabGUID} from {playerName}.";
			}
			return $"Player {playerName} does not have buff {((PrefabGUID)(ref prefabGUID2)).GuidHash}.";
		}

		[RconCommand("freeze", "Freeze a connected player for x seconds.", null)]
		public static string Freeze(string playerName, int duration)
		{
			//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_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_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)
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			if (BuffUtilitySystem.HasBuff(playerData.CharacterEntity, FreezeBuffGUID))
			{
				return "Player " + playerName + " is already frozen.";
			}
			if (!BuffUtilitySystem.TryApplyBuff(playerData.CharacterEntity, FreezeBuffGUID, duration))
			{
				return "Failed to freeze " + playerName + ".";
			}
			SystemMessages.Send(playerData.UserEntity.Read<User>(), $"You’ve been ~frozen~ in place for ~{duration}~ seconds by an admin!");
			return "Frozen " + playerName + ".";
		}

		[RconCommand("unfreeze", "Unfreeze a connected player.", null)]
		public static string Unfreeze(string playerName)
		{
			//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_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_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)
			if (!PlayerService.TryGetByName(playerName, out var playerData))
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			if (!BuffUtilitySystem.HasBuff(playerData.CharacterEntity, FreezeBuffGUID))
			{
				return "Player " + playerName + " is not frozen.";
			}
			BuffUtilitySystem.RemoveBuff(playerData.CharacterEntity, FreezeBuffGUID);
			SystemMessages.Send(playerData.UserEntity.Read<User>(), "You have been ~unfrozen~ by an admin!");
			return "Unfroze " + playerName + ".";
		}

		[RconCommand("heal", "Full heal a connected player.", "<playerName>")]
		public static string Heal(string playerName)
		{
			//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_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)
			//IL_0033: 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_0054: 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)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			Entity characterEntity = playerData.CharacterEntity;
			Health val = characterEntity.Read<Health>();
			val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
			val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
			characterEntity.Write<Health>(val);
			SystemMessages.Send(playerData.UserEntity.Read<User>(), "You have been ~healed~ by an admin!");
			return "Healed " + playerData.Name + ".";
		}

		[RconCommand("wound", "Wound a connected player.", "<playerName>")]
		public static string Wound(string playerName)
		{
			//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_004c: 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)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			if (!BuffUtilitySystem.TryApplyBuff(playerData.CharacterEntity, WoundedBuffGUID))
			{
				return "Failed to wound " + playerName + ".";
			}
			SystemMessages.Send(playerData.UserEntity.Read<User>(), "You have been ~wounded~ by an admin!");
			return "Healed " + playerData.Name + ".";
		}

		[RconCommand("kill", "Kill a connected player.", "<playerName>")]
		public static string Kill(string playerName)
		{
			//IL_0023: 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_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_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)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			StatChangeUtility.KillEntity(Core.EntityManager, playerData.CharacterEntity, playerData.CharacterEntity, Core.GameManager.ServerTime, (StatChangeReason)1, true);
			SystemMessages.Send(playerData.UserEntity.Read<User>(), "You have been ~killed~ by an admin!");
			return "Healed " + playerData.Name + ".";
		}

		[RconCommand("revive", "Revive a connected player.", "<playerName>")]
		public static string Revive(string playerName)
		{
			//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_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_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_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_0084: 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_005b: 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_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_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_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_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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00c7: 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_00cc: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			Entity characterEntity = playerData.CharacterEntity;
			Health val = characterEntity.Read<Health>();
			Entity val2 = default(Entity);
			if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val2))
			{
				DestroyUtility.Destroy(Core.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0);
				val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
				val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
				characterEntity.Write<Health>(val);
			}
			if (val.IsDead)
			{
				LocalToWorld val3 = characterEntity.Read<LocalToWorld>();
				float3 position = ((LocalToWorld)(ref val3)).Position;
				EntityCommandBuffer val4 = Core.EntityCommandBufferSystem.CreateCommandBuffer();
				Core.ServerBootstrapSystem.RespawnCharacter(val4, playerData.UserEntity, new Nullable_Unboxed<float3>
				{
					value = position
				}, characterEntity, default(Entity), -1);
			}
			SystemMessages.Send(playerData.UserEntity.Read<User>(), "You've been ~revived~ by an admin");
			return "Revived " + playerData.Name + ".";
		}

		[RconCommand("reviveall", "Revive all connected players.", null)]
		public static string ReviveAll()
		{
			//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_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_007a: 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_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_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_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_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_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_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_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00bf: 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_00c8: 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)
			Entity val2 = default(Entity);
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				Entity characterEntity = allPlayer.CharacterEntity;
				Health val = characterEntity.Read<Health>();
				if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val2))
				{
					DestroyUtility.Destroy(Core.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0);
					val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
					val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
					characterEntity.Write<Health>(val);
				}
				if (val.IsDead)
				{
					LocalToWorld val3 = characterEntity.Read<LocalToWorld>();
					float3 position = ((LocalToWorld)(ref val3)).Position;
					EntityCommandBuffer val4 = Core.EntityCommandBufferSystem.CreateCommandBuffer();
					Core.ServerBootstrapSystem.RespawnCharacter(val4, allPlayer.UserEntity, new Nullable_Unboxed<float3>
					{
						value = position
					}, characterEntity, default(Entity), -1);
				}
				SystemMessages.Send(allPlayer.UserEntity.Read<User>(), "You've been ~revived~ by an admin");
			}
			return "Revived all players.";
		}

		[RconCommand("reviveradius", "Revive all connected players within a radius.", null)]
		public static string ReviveRadius(int x, int y, int z, int radius)
		{
			//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_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_002a: 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_0044: 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_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ba: 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_0081: 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_0090: 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_00b2: 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_0113: 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_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)
			//IL_00c9: 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_00d9: 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_00e5: 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_00ef: 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_00f9: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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)
			Entity val2 = default(Entity);
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				Entity characterEntity = allPlayer.CharacterEntity;
				float3 position = allPlayer.CharacterEntity.GetPosition();
				if (!(math.distance(new float3((float)x, 0f, (float)z), new float3(position.x, 0f, position.z)) > (float)radius))
				{
					Health val = characterEntity.Read<Health>();
					if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val2))
					{
						DestroyUtility.Destroy(Core.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0);
						val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
						val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
						characterEntity.Write<Health>(val);
					}
					if (val.IsDead)
					{
						LocalToWorld val3 = characterEntity.Read<LocalToWorld>();
						float3 position2 = ((LocalToWorld)(ref val3)).Position;
						EntityCommandBuffer val4 = Core.EntityCommandBufferSystem.CreateCommandBuffer();
						Core.ServerBootstrapSystem.RespawnCharacter(val4, allPlayer.UserEntity, new Nullable_Unboxed<float3>
						{
							value = position2
						}, characterEntity, default(Entity), -1);
					}
					SystemMessages.Send(allPlayer.UserEntity.Read<User>(), "You've been ~revived~ by an admin");
				}
			}
			return "Revived all players.";
		}

		[RconCommand("reviveradius", "Revive all connected players within a player's radius.", null)]
		public static string ReviveRadius(string playerName, int radius)
		{
			//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_002e: 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_005a: 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_0067: 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_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_0096: 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_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_00f8: 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_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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0153: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_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_011d: 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_0127: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_0149: 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)
			if (!PlayerService.TryGetByName(playerName, out var playerData) || !playerData.IsOnline)
			{
				return "Player '" + playerName + "' was not found or is not connected.";
			}
			float3 position = playerData.CharacterEntity.GetPosition();
			Entity val2 = default(Entity);
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				Entity characterEntity = allPlayer.CharacterEntity;
				float3 position2 = allPlayer.CharacterEntity.GetPosition();
				if (!(math.distance(new float3(position.x, 0f, position.z), new float3(position2.x, 0f, position2.z)) > (float)radius))
				{
					Health val = characterEntity.Read<Health>();
					if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val2))
					{
						DestroyUtility.Destroy(Core.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0);
						val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
						val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
						characterEntity.Write<Health>(val);
					}
					if (val.IsDead)
					{
						LocalToWorld val3 = characterEntity.Read<LocalToWorld>();
						float3 position3 = ((LocalToWorld)(ref val3)).Position;
						EntityCommandBuffer val4 = Core.EntityCommandBufferSystem.CreateCommandBuffer();
						Core.ServerBootstrapSystem.RespawnCharacter(val4, allPlayer.UserEntity, new Nullable_Unboxed<float3>
						{
							value = position3
						}, characterEntity, default(Entity), -1);
					}
					SystemMessages.Send(allPlayer.UserEntity.Read<User>(), "You've been ~revived~ by an admin");
				}
			}
			return "Revived all players.";
		}
	}
	[RconCommandCategory("Server Administration")]
	public static class ServerCommands
	{
		[RconCommand("save", "Save the game", null)]
		public static string Save()
		{
			//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)
			string text = "Save_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".save";
			Core.TriggerPersistenceSaveSystem.TriggerSave((SaveReason)1, FixedString128Bytes.op_Implicit(text), GetServerRuntimeSettings());
			return "Game saved as '" + text + "'.";
		}

		[RconCommand("serverstats", "Show server statistics.", null)]
		public static string ServerStats()
		{
			List<PlayerData> allConnected = PlayerService.GetAllConnected();
			TimeSpan value = DateTime.Now - Process.GetCurrentProcess().StartTime;
			Process currentProcess = Process.GetCurrentProcess();
			return string.Concat(string.Concat("Server Stats\n" + $"- Players Online: {allConnected.Count}\n", $"- Uptime: {value:hh\\:mm\\:ss}\n"), $"- Memory Usage: {currentProcess.WorkingSet64 / 1048576} MB\n");
		}

		[RconCommand("settings", "Live-updates a server setting. Does not persist after restart at the moment. This is an experimental feature, use at your own risk.", null)]
		public static string Settings(string settingsPath, string settingsValue)
		{
			object obj = null;
			if (settingsPath.StartsWith("serverhostsettings.", StringComparison.OrdinalIgnoreCase))
			{
				obj = SettingsManager.ServerHostSettings;
				string text = settingsPath;
				int length = "serverhostsettings.".Length;
				settingsPath = text.Substring(length, text.Length - length);
			}
			else
			{
				if (!settingsPath.StartsWith("servergamesettings.", StringComparison.OrdinalIgnoreCase))
				{
					return "Invalid root setting: must start with 'serverhostsettings.' or 'servergamesettings.'";
				}
				obj = SettingsManager.ServerGameSettings;
				string text = settingsPath;
				int length = "servergamesettings.".Length;
				settingsPath = text.Substring(length, text.Length - length);
			}
			string[] array = settingsPath.Split('.');
			object obj2 = obj;
			PropertyInfo propertyInfo = null;
			for (int i = 0; i < array.Length; i++)
			{
				Type type = obj2.GetType();
				propertyInfo = type.GetProperty(array[i], BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
				if (propertyInfo == null)
				{
					return $"Invalid property: '{array[i]}' not found in '{type.Name}'";
				}
				if (i < array.Length - 1)
				{
					obj2 = propertyInfo.GetValue(obj2);
					if (obj2 == null)
					{
						return "Null reference: '" + array[i] + "' is null.";
					}
				}
			}
			try
			{
				object value = Convert.ChangeType(settingsValue, propertyInfo.PropertyType);
				propertyInfo.SetValue(obj2, value);
				return $"Setting '{settingsPath}' changed to '{settingsValue}'";
			}
			catch (Exception ex)
			{
				return "Failed to set property: " + ex.Message;
			}
		}

		[RconCommand("settings", "Get the value of a server setting.", null)]
		public static string GetSettings(string settingsPath)
		{
			object obj;
			if (settingsPath.StartsWith("serverhostsettings.", StringComparison.OrdinalIgnoreCase))
			{
				obj = SettingsManager.ServerHostSettings;
				string text = settingsPath;
				int length = "serverhostsettings.".Length;
				settingsPath = text.Substring(length, text.Length - length);
			}
			else
			{
				if (!settingsPath.StartsWith("servergamesettings.", StringComparison.OrdinalIgnoreCase))
				{
					return "Invalid root setting: must start with 'serverhostsettings.' or 'servergamesettings.'";
				}
				obj = SettingsManager.ServerGameSettings;
				string text = settingsPath;
				int length = "servergamesettings.".Length;
				settingsPath = text.Substring(length, text.Length - length);
			}
			string[] array = settingsPath.Split('.');
			object obj2 = obj;
			for (int i = 0; i < array.Length; i++)
			{
				Type type = obj2.GetType();
				PropertyInfo property = type.GetProperty(array[i], BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
				if (property == null)
				{
					return $"Invalid property: '{array[i]}' not found in '{type.Name}'";
				}
				obj2 = property.GetValue(obj2);
				if (obj2 == null)
				{
					return "Null reference: '" + array[i] + "' is null.";
				}
			}
			return $"Setting '{settingsPath}' is '{obj2}'";
		}

		[RconCommand("listadmins", "List all connected admins.", null)]
		public static string ListAdmins()
		{
			List<PlayerData> admins = PlayerService.GetAdmins();
			string text = "";
			int num = 0;
			foreach (PlayerData item in admins)
			{
				if (item.IsOnline)
				{
					num++;
					text += $"- \u001b[97m{item.Name}\u001b[0m \u001b[90m({item.PlatformId})\u001b[0m\n";
				}
			}
			return text + $"Total connected admins: {num}";
		}

		[RconCommand("listplayers", "List all connected players.", null)]
		public static string ListAllPlayers()
		{
			string text = "";
			int num = 0;
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				if (allPlayer.IsOnline)
				{
					num++;
					text += $"- \u001b[97m{allPlayer.Name}\u001b[0m \u001b[90m({allPlayer.PlatformId})\u001b[0m\n";
				}
			}
			return text + $"Total connected players: {num}";
		}

		[Rcon