Decompiled source of AdminCMDS v1.0.2

AdminCMDS.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AdminCMDS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AdminCMDS")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ebdb468-4d6a-4de4-8874-dc7664cd5224")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("AdminCMDS", "AdminCMDS", "1.0.2")]
public class DeathCommands : BaseUnityPlugin
{
	public static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Plugin AdminCMDS is loaded!");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		Log.LogInfo((object)"Harmony patches applied successfully!");
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "AdminCMDS";

	public const string PLUGIN_NAME = "AdminCMDS";

	public const string PLUGIN_VERSION = "1.0.2";
}
[HarmonyPatch(typeof(ChatBehaviour), "Send_ChatMessage")]
public class ChatPatch
{
	private static void Postfix(ChatBehaviour __instance, string __0)
	{
		DeathCommands.Log.LogDebug((object)("Received chat message: " + __0));
		switch (__0)
		{
		default:
			if (!(__0 == "/reset"))
			{
				if (__0.StartsWith("/givepoints"))
				{
					ProcessGivePointsCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/setpoints"))
				{
					ProcessSetPointsCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/setexp"))
				{
					ProcessSetExpCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/setlevel"))
				{
					ProcessSetLevelCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/setskillpoints"))
				{
					ProcessSetSkillPointsCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/setmoney"))
				{
					ProcessSetMoneyCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/speed"))
				{
					ProcessSpeedCommand(__instance, __0);
					break;
				}
				if (__0.StartsWith("/maxjumps"))
				{
					ProcessMaxJumpsCommand(__instance, __0);
					break;
				}
				switch (__0)
				{
				case "/heal":
					ProcessHealCommand(__instance);
					break;
				case "/debugstats":
					DebugPlayerStats(__instance);
					break;
				default:
					if (!(__0 == "/commands"))
					{
						break;
					}
					goto case "/help";
				case "/help":
					ShowHelp(__instance);
					break;
				}
				break;
			}
			goto case "/kill";
		case "/kill":
		case "/die":
		case "/r":
			KillPlayer(__instance);
			break;
		}
	}

	private static void ShowHelp(ChatBehaviour chatInstance)
	{
		SendChatMessage(chatInstance, "<color=yellow>=== Available Commands ===</color>");
		SendChatMessage(chatInstance, "<color=white>/kill, /die, /r, /reset</color> - Suicide");
		SendChatMessage(chatInstance, "<color=white>/givepoints <amount></color> - Add attribute points");
		SendChatMessage(chatInstance, "<color=white>/setpoints <amount></color> - Set exact attribute points");
		SendChatMessage(chatInstance, "<color=white>/setexp <amount></color> - Set exact experience");
		SendChatMessage(chatInstance, "<color=white>/setlevel <level></color> - Set exact level");
		SendChatMessage(chatInstance, "<color=white>/setskillpoints <amount></color> - Set exact skill points");
		SendChatMessage(chatInstance, "<color=white>/setmoney <amount></color> - Set exact money");
		SendChatMessage(chatInstance, "<color=white>/speed <multiplier></color> - Set speed multiplier (0.1-5.0, default: 1)");
		SendChatMessage(chatInstance, "<color=white>/maxjumps <number></color> - Set max jumps (1-10, default: 2)");
		SendChatMessage(chatInstance, "<color=white>/heal</color> - Fully restore health and mana");
		SendChatMessage(chatInstance, "<color=white>/debugstats</color> - Show all stats");
	}

	private static void ProcessHealCommand(ChatBehaviour chatInstance)
	{
		try
		{
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (HealPlayer(playerComponent))
			{
				SendChatMessage(chatInstance, "<color=green>Health and mana fully restored!</color>");
				DeathCommands.Log.LogInfo((object)"Player healed successfully");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to heal player!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessHealCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing heal command!</color>");
		}
	}

	private static bool HealPlayer(Component playerComponent)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_statusEntity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				DeathCommands.Log.LogError((object)"_statusEntity field not found in Player!");
				return false;
			}
			object value = field.GetValue(playerComponent);
			if (value == null)
			{
				DeathCommands.Log.LogError((object)"StatusEntity is null!");
				return false;
			}
			Type type2 = value.GetType();
			FieldInfo field2 = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 == null)
			{
				DeathCommands.Log.LogError((object)"_pStats field not found!");
				return false;
			}
			object value2 = field2.GetValue(playerComponent);
			Type type3 = value2.GetType();
			FieldInfo field3 = type3.GetField("_statStruct", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field3 == null)
			{
				DeathCommands.Log.LogError((object)"_statStruct field not found!");
				return false;
			}
			object value3 = field3.GetValue(value2);
			Type type4 = value3.GetType();
			FieldInfo field4 = type4.GetField("_maxHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field4 == null)
			{
				DeathCommands.Log.LogError((object)"_maxHealth field not found!");
				return false;
			}
			int num = (int)field4.GetValue(value3);
			FieldInfo field5 = type4.GetField("_maxMana", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field5 == null)
			{
				DeathCommands.Log.LogError((object)"_maxMana field not found!");
				return false;
			}
			int num2 = (int)field5.GetValue(value3);
			FieldInfo field6 = type2.GetField("_currentHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field6 != null)
			{
				field6.SetValue(value, num);
				DeathCommands.Log.LogInfo((object)$"Set _currentHealth to {num}");
			}
			else
			{
				string[] array = new string[4] { "_currentHealth", "currentHealth", "_health", "health" };
				string[] array2 = array;
				foreach (string text in array2)
				{
					FieldInfo field7 = type2.GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field7 != null && field7.FieldType == typeof(int))
					{
						field7.SetValue(value, num);
						DeathCommands.Log.LogInfo((object)$"Set {text} to {num}");
						break;
					}
				}
			}
			FieldInfo field8 = type2.GetField("_currentMana", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field8 != null)
			{
				field8.SetValue(value, num2);
				DeathCommands.Log.LogInfo((object)$"Set _currentMana to {num2}");
			}
			else
			{
				string[] array3 = new string[4] { "_currentMana", "currentMana", "_mana", "mana" };
				string[] array4 = array3;
				foreach (string text2 in array4)
				{
					FieldInfo field9 = type2.GetField(text2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field9 != null && field9.FieldType == typeof(int))
					{
						field9.SetValue(value, num2);
						DeathCommands.Log.LogInfo((object)$"Set {text2} to {num2}");
						break;
					}
				}
			}
			FieldInfo field10 = type4.GetField("_maxStamina", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field10 != null)
			{
				int num3 = (int)field10.GetValue(value3);
				FieldInfo field11 = type2.GetField("_currentStamina", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field11 != null)
				{
					field11.SetValue(value, num3);
					DeathCommands.Log.LogInfo((object)$"Set _currentStamina to {num3}");
				}
				else
				{
					string[] array5 = new string[4] { "_currentStamina", "currentStamina", "_stamina", "stamina" };
					string[] array6 = array5;
					foreach (string text3 in array6)
					{
						FieldInfo field12 = type2.GetField(text3, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field12 != null && field12.FieldType == typeof(int))
						{
							field12.SetValue(value, num3);
							DeathCommands.Log.LogInfo((object)$"Set {text3} to {num3}");
							break;
						}
					}
				}
			}
			return true;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in HealPlayer: {arg}");
			return false;
		}
	}

	private static void ProcessMaxJumpsCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /maxjumps <number></color>");
				SendChatMessage(chatInstance, "<color=yellow>Max jumps: 1 to 10 (default: 2)</color>");
				return;
			}
			if (!int.TryParse(array[1], out var result))
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid number!</color>");
				return;
			}
			result = Mathf.Clamp(result, 1, 10);
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetMaxJumps(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Max jumps set to: {result}</color>");
				DeathCommands.Log.LogInfo((object)$"Player max jumps set to: {result}");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set max jumps!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessMaxJumpsCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing max jumps command!</color>");
		}
	}

	private static bool SetMaxJumps(Component playerComponent, int maxJumps)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			object playerMoveComponent = GetPlayerMoveComponent(playerComponent);
			if (playerMoveComponent == null)
			{
				DeathCommands.Log.LogError((object)"PlayerMove component not found!");
				return false;
			}
			Type type2 = playerMoveComponent.GetType();
			FieldInfo field = type2.GetField("_maxJumps", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				int num = (int)field.GetValue(playerMoveComponent);
				field.SetValue(playerMoveComponent, maxJumps);
				DeathCommands.Log.LogInfo((object)$"Set _maxJumps: {num} -> {maxJumps}");
				return true;
			}
			DeathCommands.Log.LogError((object)"_maxJumps field not found in PlayerMove!");
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetMaxJumps: {arg}");
			return false;
		}
	}

	private static void ProcessSpeedCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /speed <multiplier></color>");
				SendChatMessage(chatInstance, "<color=yellow>Multiplier: 0.1 to 5.0 (1 = normal speed)</color>");
				return;
			}
			if (!float.TryParse(array[1], out var result))
			{
				result = 1f;
			}
			result = Mathf.Clamp(result, 0.1f, 5f);
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetPlayerSpeed(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Speed multiplier set to: {result}x</color>");
				DeathCommands.Log.LogInfo((object)$"Player speed set to: {result}x");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set speed!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSpeedCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing speed command!</color>");
		}
	}

	private static bool SetPlayerSpeed(Component playerComponent, float speedMultiplier)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			object playerMoveComponent = GetPlayerMoveComponent(playerComponent);
			if (playerMoveComponent == null)
			{
				DeathCommands.Log.LogError((object)"PlayerMove component not found!");
				return false;
			}
			Type type2 = playerMoveComponent.GetType();
			float baseMoveSpeed = GetBaseMoveSpeed();
			FieldInfo field = type2.GetField("_movSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				float num = baseMoveSpeed * speedMultiplier;
				field.SetValue(playerMoveComponent, num);
				DeathCommands.Log.LogInfo((object)$"Set _movSpeed: {baseMoveSpeed} * {speedMultiplier} = {num}");
				return true;
			}
			DeathCommands.Log.LogError((object)"_movSpeed field not found in PlayerMove!");
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetPlayerSpeed: {arg}");
			return false;
		}
	}

	private static float GetBaseMoveSpeed()
	{
		try
		{
			Type typeFromHandle = typeof(GameManager);
			FieldInfo field = typeFromHandle.GetField("_current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				object value = field.GetValue(null);
				if (value != null)
				{
					FieldInfo field2 = typeFromHandle.GetField("_statLogics", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field2 != null)
					{
						object value2 = field2.GetValue(value);
						Type type = value2.GetType();
						FieldInfo field3 = type.GetField("_baseMoveSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field3 != null)
						{
							return (float)field3.GetValue(value2);
						}
					}
				}
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error getting base move speed: {arg}");
		}
		return 8f;
	}

	private static object GetPlayerMoveComponent(Component playerComponent)
	{
		try
		{
			PropertyInfo property = ((object)playerComponent).GetType().GetProperty("transform", BindingFlags.Instance | BindingFlags.Public);
			if (property != null)
			{
				object value = property.GetValue(playerComponent);
				if (value != null)
				{
					PropertyInfo property2 = value.GetType().GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public);
					if (property2 != null)
					{
						object value2 = property2.GetValue(value);
						if (value2 != null)
						{
							MethodInfo method = value2.GetType().GetMethod("GetComponent", new Type[1] { typeof(Type) });
							if (method != null)
							{
								object obj = method.Invoke(value2, new object[1] { typeof(Component) });
								if (obj != null && obj.GetType().Name == "PlayerMove")
								{
									return obj;
								}
							}
							MethodInfo method2 = value2.GetType().GetMethod("GetComponents", new Type[1] { typeof(Type) });
							if (method2 != null)
							{
								Component[] array = (Component[])method2.Invoke(value2, new object[1] { typeof(Component) });
								Component[] array2 = array;
								foreach (Component val in array2)
								{
									if (((object)val).GetType().Name == "PlayerMove")
									{
										return val;
									}
								}
							}
						}
					}
				}
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in GetPlayerMoveComponent: {arg}");
		}
		return null;
	}

	private static void ProcessGivePointsCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /givepoints <amount></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result <= 0)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid positive number!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				DeathCommands.Log.LogError((object)"Player component not found!");
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (AddAttributePoints(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully added {result} attribute points!</color>");
				DeathCommands.Log.LogInfo((object)$"Added {result} attribute points to player");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to add attribute points!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessGivePointsCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void ProcessSetPointsCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /setpoints <amount></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result < 0)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid number (0 or higher)!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetAttributePoints(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully set attribute points to {result}!</color>");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set attribute points!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSetPointsCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void ProcessSetExpCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /setexp <amount></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result < 0)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid number (0 or higher)!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetExperience(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully set experience to {result}!</color>");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set experience!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSetExpCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void ProcessSetLevelCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /setlevel <level></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result < 1)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid level (1 or higher)!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetLevel(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully set level to {result}!</color>");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set level!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSetLevelCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void ProcessSetSkillPointsCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /setskillpoints <amount></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result < 0)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid number (0 or higher)!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetSkillPoints(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully set skill points to {result}!</color>");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set skill points!</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSetSkillPointsCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void ProcessSetMoneyCommand(ChatBehaviour chatInstance, string message)
	{
		try
		{
			string[] array = message.Split(new char[1] { ' ' });
			if (array.Length < 2)
			{
				SendChatMessage(chatInstance, "<color=red>Usage: /setmoney <amount></color>");
				return;
			}
			if (!int.TryParse(array[1], out var result) || result < 0)
			{
				SendChatMessage(chatInstance, "<color=red>Please enter a valid number (0 or higher)!</color>");
				return;
			}
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Error: Player not found!</color>");
			}
			else if (SetMoney(playerComponent, result))
			{
				SendChatMessage(chatInstance, $"<color=green>Successfully set money to {result}!</color>");
			}
			else
			{
				SendChatMessage(chatInstance, "<color=red>Failed to set money! Try /debugstats to find correct field name.</color>");
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in ProcessSetMoneyCommand: {arg}");
			SendChatMessage(chatInstance, "<color=red>Error processing command!</color>");
		}
	}

	private static void DebugPlayerStats(ChatBehaviour chatInstance)
	{
		try
		{
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				SendChatMessage(chatInstance, "<color=red>Player not found!</color>");
				return;
			}
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				SendChatMessage(chatInstance, "<color=red>PlayerStats not found!</color>");
				return;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo[] fields = type2.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			SendChatMessage(chatInstance, "<color=yellow>=== PlayerStats Fields ===</color>");
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				if (fieldInfo.FieldType == typeof(int) || fieldInfo.FieldType == typeof(float))
				{
					try
					{
						object value2 = fieldInfo.GetValue(value);
						SendChatMessage(chatInstance, $"<color=white>{fieldInfo.Name}: {value2}</color>");
					}
					catch
					{
					}
				}
			}
			FieldInfo field2 = type.GetField("_pInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				object value3 = field2.GetValue(playerComponent);
				Type type3 = value3.GetType();
				FieldInfo[] fields2 = type3.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				SendChatMessage(chatInstance, "<color=yellow>=== PlayerInventory Fields ===</color>");
				FieldInfo[] array2 = fields2;
				foreach (FieldInfo fieldInfo2 in array2)
				{
					if (fieldInfo2.FieldType == typeof(int) || fieldInfo2.FieldType == typeof(float))
					{
						try
						{
							object value4 = fieldInfo2.GetValue(value3);
							SendChatMessage(chatInstance, $"<color=white>{fieldInfo2.Name}: {value4}</color>");
						}
						catch
						{
						}
					}
				}
			}
			object playerMoveComponent = GetPlayerMoveComponent(playerComponent);
			if (playerMoveComponent != null)
			{
				Type type4 = playerMoveComponent.GetType();
				SendChatMessage(chatInstance, "<color=yellow>=== PlayerMove Stats ===</color>");
				FieldInfo field3 = type4.GetField("_movSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field3 != null)
				{
					float num = (float)field3.GetValue(playerMoveComponent);
					SendChatMessage(chatInstance, $"<color=white>_movSpeed: {num}</color>");
					float baseMoveSpeed = GetBaseMoveSpeed();
					SendChatMessage(chatInstance, $"<color=white>Base Move Speed: {baseMoveSpeed}</color>");
					SendChatMessage(chatInstance, $"<color=white>Current Multiplier: {num / baseMoveSpeed}x</color>");
				}
				FieldInfo field4 = type4.GetField("_maxJumps", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field4 != null)
				{
					int num2 = (int)field4.GetValue(playerMoveComponent);
					SendChatMessage(chatInstance, $"<color=white>_maxJumps: {num2}</color>");
				}
				FieldInfo field5 = type4.GetField("_currentJumps", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field5 != null)
				{
					int num3 = (int)field5.GetValue(playerMoveComponent);
					SendChatMessage(chatInstance, $"<color=white>_currentJumps: {num3}</color>");
				}
			}
			DeathCommands.Log.LogInfo((object)"Debug stats completed");
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Debug error: {arg}");
			SendChatMessage(chatInstance, "<color=red>Debug error!</color>");
		}
	}

	private static bool AddAttributePoints(Component playerComponent, int points)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				DeathCommands.Log.LogError((object)"_pStats field not found!");
				return false;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo field2 = type2.GetField("_currentAttributePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 == null)
			{
				DeathCommands.Log.LogError((object)"_currentAttributePoints field not found!");
				return false;
			}
			int num = (int)field2.GetValue(value);
			field2.SetValue(value, num + points);
			DeathCommands.Log.LogInfo((object)$"Updated _currentAttributePoints: {num} -> {num + points}");
			return true;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in AddAttributePoints: {arg}");
			return false;
		}
	}

	private static bool SetAttributePoints(Component playerComponent, int points)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo field2 = type2.GetField("_currentAttributePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				int num = (int)field2.GetValue(value);
				field2.SetValue(value, points);
				DeathCommands.Log.LogInfo((object)$"Set _currentAttributePoints: {num} -> {points}");
				return true;
			}
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetAttributePoints: {arg}");
			return false;
		}
	}

	private static bool SetExperience(Component playerComponent, int exp)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo field2 = type2.GetField("_currentExp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				int num = (int)field2.GetValue(value);
				field2.SetValue(value, exp);
				DeathCommands.Log.LogInfo((object)$"Set _currentExp: {num} -> {exp}");
				return true;
			}
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetExperience: {arg}");
			return false;
		}
	}

	private static bool SetLevel(Component playerComponent, int level)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo field2 = type2.GetField("_currentLevel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				int num = (int)field2.GetValue(value);
				field2.SetValue(value, level);
				DeathCommands.Log.LogInfo((object)$"Set _currentLevel: {num} -> {level}");
				return true;
			}
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetLevel: {arg}");
			return false;
		}
	}

	private static bool SetSkillPoints(Component playerComponent, int points)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			object value = field.GetValue(playerComponent);
			Type type2 = value.GetType();
			FieldInfo field2 = type2.GetField("_currentSkillPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				int num = (int)field2.GetValue(value);
				field2.SetValue(value, points);
				DeathCommands.Log.LogInfo((object)$"Set _currentSkillPoints: {num} -> {points}");
				return true;
			}
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetSkillPoints: {arg}");
			return false;
		}
	}

	private static bool SetMoney(Component playerComponent, int money)
	{
		try
		{
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_pInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				object value = field.GetValue(playerComponent);
				Type type2 = value.GetType();
				string[] array = new string[9] { "_heldCurrency", "_currency", "currency", "_money", "money", "_coins", "coins", "_gold", "gold" };
				string[] array2 = array;
				foreach (string text in array2)
				{
					FieldInfo field2 = type2.GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field2 != null && (field2.FieldType == typeof(int) || field2.FieldType == typeof(float)))
					{
						int num = Convert.ToInt32(field2.GetValue(value));
						field2.SetValue(value, money);
						DeathCommands.Log.LogInfo((object)$"Set {text}: {num} -> {money}");
						return true;
					}
				}
			}
			FieldInfo field3 = type.GetField("_pStats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field3 != null)
			{
				object value2 = field3.GetValue(playerComponent);
				Type type3 = value2.GetType();
				string[] array3 = new string[5] { "_heldCurrency", "_currency", "currency", "_money", "money" };
				string[] array4 = array3;
				foreach (string text2 in array4)
				{
					FieldInfo field4 = type3.GetField(text2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field4 != null && (field4.FieldType == typeof(int) || field4.FieldType == typeof(float)))
					{
						int num2 = Convert.ToInt32(field4.GetValue(value2));
						field4.SetValue(value2, money);
						DeathCommands.Log.LogInfo((object)$"Set {text2}: {num2} -> {money}");
						return true;
					}
				}
			}
			return false;
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in SetMoney: {arg}");
			return false;
		}
	}

	private static Component GetPlayerComponent(ChatBehaviour chatInstance)
	{
		try
		{
			PropertyInfo property = ((object)chatInstance).GetType().GetProperty("transform", BindingFlags.Instance | BindingFlags.Public);
			if (property != null)
			{
				object value = property.GetValue(chatInstance);
				if (value != null)
				{
					PropertyInfo property2 = value.GetType().GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public);
					if (property2 != null)
					{
						object value2 = property2.GetValue(value);
						if (value2 != null)
						{
							MethodInfo method = value2.GetType().GetMethod("GetComponents", new Type[1] { typeof(Type) });
							if (method != null)
							{
								Component[] array = (Component[])method.Invoke(value2, new object[1] { typeof(Component) });
								Component[] array2 = array;
								foreach (Component val in array2)
								{
									if (((object)val).GetType().Name == "Player")
									{
										return val;
									}
								}
							}
						}
					}
				}
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in GetPlayerComponent: {arg}");
		}
		return null;
	}

	private static void KillPlayer(ChatBehaviour chatInstance)
	{
		try
		{
			Component playerComponent = GetPlayerComponent(chatInstance);
			if ((Object)(object)playerComponent == (Object)null)
			{
				DeathCommands.Log.LogError((object)"Player component not found!");
				return;
			}
			Type type = ((object)playerComponent).GetType();
			FieldInfo field = type.GetField("_playerZoneType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field.GetValue(playerComponent)?.ToString() == "Safe")
			{
				SendChatMessage(chatInstance, "<color=red>Cannot die in safe zone! Go to dangerous area.</color>");
				DeathCommands.Log.LogInfo((object)"Player tried to die in safe zone");
				return;
			}
			FieldInfo field2 = type.GetField("_statusEntity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				object value = field2.GetValue(playerComponent);
				if (value != null)
				{
					Type type2 = value.GetType();
					FieldInfo field3 = type2.GetField("_currentHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field3 != null)
					{
						int num = (int)field3.GetValue(value);
						if (num <= 0)
						{
							SendChatMessage(chatInstance, "<color=red>You are already dead! Use /respawn</color>");
							return;
						}
					}
				}
			}
			MethodInfo method = type.GetMethod("Player_OnDeath", BindingFlags.Instance | BindingFlags.Public);
			if (method != null)
			{
				method.Invoke(playerComponent, null);
				DeathCommands.Log.LogInfo((object)"Player_OnDeath method called successfully");
			}
			if (field2 != null)
			{
				object value2 = field2.GetValue(playerComponent);
				if (value2 != null)
				{
					SetHealthToZero(value2);
				}
			}
			SendChatMessage(chatInstance, "<color=red>You have chosen death...</color>");
			DeathCommands.Log.LogInfo((object)"Player used death command successfully");
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Error in KillPlayer: {arg}");
		}
	}

	private static void SendChatMessage(ChatBehaviour chatInstance, string message)
	{
		try
		{
			MethodInfo method = typeof(ChatBehaviour).GetMethod("New_ChatMessage", BindingFlags.Instance | BindingFlags.Public);
			if (method != null)
			{
				method.Invoke(chatInstance, new object[1] { message });
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Failed to send chat message: {arg}");
		}
	}

	private static void SetHealthToZero(object statusEntity)
	{
		try
		{
			Type type = statusEntity.GetType();
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				if (fieldInfo.Name.ToLower().Contains("health") && fieldInfo.FieldType == typeof(int))
				{
					fieldInfo.SetValue(statusEntity, 0);
					DeathCommands.Log.LogDebug((object)("Set health to 0 via field: " + fieldInfo.Name));
					break;
				}
			}
		}
		catch (Exception arg)
		{
			DeathCommands.Log.LogError((object)$"Failed to set health: {arg}");
		}
	}
}