Decompiled source of BestGearGuard v2.0.0

BestGearGuard.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BestGearGuard.Services;
using BestGearGuard.Utils;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Irozer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Only the best of the best")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a1b1724f2754d9a04c10f3f882770aa8f779c8d9")]
[assembly: AssemblyProduct("BestGearGuard")]
[assembly: AssemblyTitle("BestGearGuard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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 BestGearGuard
{
	public static class Core
	{
		public static bool hasInitialized = false;

		public static World Server { get; } = GetWorld("Server") ?? throw new Exception("Server World not found. Did you install the mod on the server?");


		public static EntityManager EntityManager => Server.EntityManager;

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

		public static PrefabCollectionSystem PrefabCollection { get; } = Server.GetExistingSystemManaged<PrefabCollectionSystem>();


		private static World GetWorld(string name)
		{
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return current;
				}
			}
			return null;
		}

		public static void LogException(Exception e, [CallerMemberName] string caller = null)
		{
			Debug.LogError(Object.op_Implicit($"[BestGearGuard] Exception in {caller}: {e.Message}\n{e.StackTrace}"));
		}
	}
	public static class GearGuardSettings
	{
		private static ConfigFile _config;

		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<int> MaxTierDifference;

		public static ConfigEntry<bool> DebuffEnabled;

		public static void Init(string configPath)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			_config = new ConfigFile(Path.Combine(configPath, "gearguard.cfg"), true);
			Enabled = _config.Bind<bool>("General", "Enabled", true, "Enable or disable the gear tier enforcement.");
			MaxTierDifference = _config.Bind<int>("General", "MaxTierDifference", 1, "Maximum allowed tier difference between equipped items.");
			DebuffEnabled = _config.Bind<bool>("General", "DebuffEnabled", true, "Apply a debuff to players who violate the gear tier rule.");
		}

		public static void Reload()
		{
			ConfigFile config = _config;
			if (config != null)
			{
				config.Reload();
			}
		}
	}
	[BepInPlugin("com.tonpseudo.bestgearguard", "BestGearGuard", "1.0.0")]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		public static ManualLogSource Logger;

		public static Plugin Instance { get; private set; }

		public override void Load()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			Logger = ((BasePlugin)this).Log;
			string text = Path.Combine(Paths.ConfigPath, "BestGearGuard");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			GearGuardSettings.Init(text);
			CommandRegistry.RegisterAll();
			_harmony = new Harmony("com.tonpseudo.bestgearguard");
			_harmony.PatchAll();
			((BasePlugin)this).Log.LogInfo((object)"BestGearGuard loaded and ready!");
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return ((BasePlugin)this).Unload();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "aa.BestGearGuard";

		public const string PLUGIN_NAME = "BestGearGuard";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BestGearGuard.Utils
{
	public static class VWorld
	{
		public static World Server
		{
			get
			{
				Enumerator<World> enumerator = World.All.GetEnumerator();
				while (enumerator.MoveNext())
				{
					World current = enumerator.Current;
					if (current.Name == "Server")
					{
						return current;
					}
				}
				return null;
			}
		}

		public static EntityManager ServerEntityManager => Server.EntityManager;
	}
}
namespace BestGearGuard.Services
{
	public static class GearCheckerService
	{
		private static readonly EquipmentType[] ArmorSlots;

		private static readonly EquipmentType[] WeaponSlots;

		public static bool CheckViolation(EntityManager em, Entity characterEntity, out int armorMaxTier, out int weaponMaxTier)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			armorMaxTier = 0;
			weaponMaxTier = 0;
			if (!((EntityManager)(ref em)).HasComponent<Equipment>(characterEntity))
			{
				return false;
			}
			Equipment componentData = ((EntityManager)(ref em)).GetComponentData<Equipment>(characterEntity);
			int num = 99;
			armorMaxTier = 0;
			bool flag = false;
			EquipmentType[] armorSlots = ArmorSlots;
			foreach (EquipmentType val in armorSlots)
			{
				PrefabGUID equipmentItemId = ((Equipment)(ref componentData)).GetEquipmentItemId(val);
				if (((PrefabGUID)(ref equipmentItemId)).GuidHash != 0 && TierDatabase.TryGetTier(equipmentItemId, out var tier))
				{
					flag = true;
					if (tier > armorMaxTier)
					{
						armorMaxTier = tier;
					}
					if (tier < num)
					{
						num = tier;
					}
				}
			}
			bool flag2 = false;
			armorSlots = WeaponSlots;
			foreach (EquipmentType val2 in armorSlots)
			{
				PrefabGUID equipmentItemId2 = ((Equipment)(ref componentData)).GetEquipmentItemId(val2);
				if (((PrefabGUID)(ref equipmentItemId2)).GuidHash != 0 && TierDatabase.TryGetTier(equipmentItemId2, out var tier2))
				{
					flag2 = true;
					if (tier2 > weaponMaxTier)
					{
						weaponMaxTier = tier2;
					}
				}
			}
			if (!flag)
			{
				return false;
			}
			int value = GearGuardSettings.MaxTierDifference.Value;
			if (flag && armorMaxTier - num > value)
			{
				return true;
			}
			if (flag2 && weaponMaxTier > armorMaxTier + value)
			{
				return true;
			}
			return false;
		}

		static GearCheckerService()
		{
			EquipmentType[] array = new EquipmentType[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			ArmorSlots = (EquipmentType[])(object)array;
			WeaponSlots = (EquipmentType[])(object)new EquipmentType[2]
			{
				(EquipmentType)2,
				(EquipmentType)3
			};
		}
	}
	public static class GearDebuffService
	{
		public static readonly PrefabGUID DebuffPrefab = new PrefabGUID(-1315531444);

		public static void ApplyDebuff(EntityManager em, Entity characterEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_000f: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00ca: 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_00e7: 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_00fa: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Entity val = default(Entity);
				if (characterEntity == Entity.Null || !((EntityManager)(ref em)).Exists(characterEntity) || BuffUtility.TryGetBuff<EntityManager>(em, characterEntity, PrefabIdentifier.op_Implicit(DebuffPrefab), ref val))
				{
					return;
				}
				Entity userEntity = GetUserEntity(em, characterEntity);
				if (userEntity == Entity.Null)
				{
					return;
				}
				DebugEventsSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>();
				ApplyBuffDebugEvent val2 = new ApplyBuffDebugEvent
				{
					BuffPrefabGUID = DebuffPrefab
				};
				FromCharacter val3 = new FromCharacter
				{
					Character = characterEntity,
					User = userEntity
				};
				existingSystemManaged.ApplyBuff(val3, val2);
				Entity val4 = default(Entity);
				if (BuffUtility.TryGetBuff<EntityManager>(em, characterEntity, PrefabIdentifier.op_Implicit(DebuffPrefab), ref val4))
				{
					if (((EntityManager)(ref em)).HasComponent<SunDamageDebuff>(val4))
					{
						SunDamageDebuff componentData = ((EntityManager)(ref em)).GetComponentData<SunDamageDebuff>(val4);
						componentData.DamageFactorPerTick = 0.01f;
						((EntityManager)(ref em)).SetComponentData<SunDamageDebuff>(val4, componentData);
					}
					if (((EntityManager)(ref em)).HasComponent<LifeTime>(val4))
					{
						((EntityManager)(ref em)).RemoveComponent<LifeTime>(val4);
					}
					if (((EntityManager)(ref em)).HasComponent<RemoveBuffOnGameplayEvent>(val4))
					{
						((EntityManager)(ref em)).RemoveComponent<RemoveBuffOnGameplayEvent>(val4);
					}
					if (((EntityManager)(ref em)).HasComponent<RemoveBuffOnGameplayEventEntry>(val4))
					{
						((EntityManager)(ref em)).RemoveComponent<RemoveBuffOnGameplayEventEntry>(val4);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[GearDebuffService] ApplyDebuff error: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val5);
			}
		}

		public static void RemoveDebuff(EntityManager em, Entity characterEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Entity val = default(Entity);
				if (!(characterEntity == Entity.Null) && ((EntityManager)(ref em)).Exists(characterEntity) && BuffUtility.TryGetBuff<EntityManager>(em, characterEntity, PrefabIdentifier.op_Implicit(DebuffPrefab), ref val) && ((EntityManager)(ref em)).Exists(val))
				{
					DestroyUtility.Destroy(em, val, (DestroyDebugReason)0, (string)null, 0);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[GearDebuffService] RemoveDebuff error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val2);
			}
		}

		private static Entity GetUserEntity(EntityManager em, Entity characterEntity)
		{
			//IL_0002: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (((EntityManager)(ref em)).HasComponent<PlayerCharacter>(characterEntity))
			{
				return ((EntityManager)(ref em)).GetComponentData<PlayerCharacter>(characterEntity).UserEntity;
			}
			return Entity.Null;
		}
	}
	public static class NameDatabase
	{
		private static readonly Dictionary<int, string> _names = new Dictionary<int, string>
		{
			{ 711062517, "Item_Boots_T01_Bone" },
			{ 1241831522, "Item_Boots_T02_BoneReinforced" },
			{ -1354920908, "Item_Boots_T03_Cloth" },
			{ -1359494169, "Item_Boots_T04_Copper_Brute" },
			{ 1101206623, "Item_Boots_T04_Copper_Rogue" },
			{ 1204352435, "Item_Boots_T04_Copper_Scholar" },
			{ -15390086, "Item_Boots_T04_Copper_Warrior" },
			{ -1837769884, "Item_Boots_T05_Cotton" },
			{ -1329744719, "Item_Boots_T06_Iron_Brute" },
			{ 51576788, "Item_Boots_T06_Iron_Rogue" },
			{ 138060378, "Item_Boots_T06_Iron_Scholar" },
			{ 666433583, "Item_Boots_T06_Iron_Warrior" },
			{ 560446510, "Item_Boots_T07_Silk" },
			{ -1023762087, "Item_Boots_T08_DarkSilver_Brute" },
			{ -1921018689, "Item_Boots_T08_DarkSilver_Rogue" },
			{ 1469185034, "Item_Boots_T08_DarkSilver_Scholar" },
			{ 1395895315, "Item_Boots_T08_DarkSilver_Warrior" },
			{ 1400688919, "Item_Boots_T09_Dracula" },
			{ 1646489863, "Item_Boots_T09_Dracula_Brute" },
			{ 1855323424, "Item_Boots_T09_Dracula_Rogue" },
			{ 1531721602, "Item_Boots_T09_Dracula_Scholar" },
			{ -382349289, "Item_Boots_T09_Dracula_Warrior" },
			{ 329301090, "Item_Chest_T01_Bone" },
			{ -958936382, "Item_Chest_T02_BoneReinforced" },
			{ -957963240, "Item_Chest_T03_Cloth" },
			{ -112921782, "Item_Chest_T04_Copper_Brute" },
			{ 763326246, "Item_Chest_T04_Copper_Rogue" },
			{ -2100321922, "Item_Chest_T04_Copper_Scholar" },
			{ 1809631067, "Item_Chest_T04_Copper_Warrior" },
			{ -604941435, "Item_Chest_T05_Cotton" },
			{ -1641042717, "Item_Chest_T06_Iron_Brute" },
			{ -69916288, "Item_Chest_T06_Iron_Rogue" },
			{ -2127687996, "Item_Chest_T06_Iron_Scholar" },
			{ -2102875089, "Item_Chest_T06_Iron_Warrior" },
			{ -930514044, "Item_Chest_T07_Silk" },
			{ -1279475298, "Item_Chest_T08_DarkSilver_Brute" },
			{ 1871735757, "Item_Chest_T08_DarkSilver_Rogue" },
			{ -919709436, "Item_Chest_T08_DarkSilver_Scholar" },
			{ 750788905, "Item_Chest_T08_DarkSilver_Warrior" },
			{ 1055898174, "Item_Chest_T09_Dracula" },
			{ 1033753207, "Item_Chest_T09_Dracula_Brute" },
			{ 933057100, "Item_Chest_T09_Dracula_Rogue" },
			{ 114259912, "Item_Chest_T09_Dracula_Scholar" },
			{ 1392314162, "Item_Chest_T09_Dracula_Warrior" },
			{ -1819786494, "Item_Cloak_Main_T01_Travelers" },
			{ 786585343, "Item_Cloak_Main_T02_Hunter" },
			{ -227965303, "Item_Cloak_Main_T03_Phantom" },
			{ -168044197, "Item_Cloak_T01_ChaosArcher" },
			{ 1284160983, "Item_Cloak_T01_Dracula" },
			{ -24337506, "Item_Cloak_T01_FrostArrow" },
			{ 1261174372, "Item_Cloak_T01_Jade" },
			{ -1514540144, "Item_Cloak_T01_PlagueMaster" },
			{ -766642494, "Item_Cloak_T01_Razer" },
			{ -305440546, "Item_Cloak_T01_UndeadMage" },
			{ 1335546377, "Item_Cloak_T01_VampireHunter" },
			{ 150621304, "Item_Cloak_T01_ZealousCultist" },
			{ -1768698241, "Item_Cloak_T02_Cardinal" },
			{ -1067360120, "Item_Cloak_T02_Dracula" },
			{ 1677983904, "Item_Cloak_T02_HarpyMatriarch" },
			{ -2091288477, "Item_Cloak_T02_HolyPaladin" },
			{ 2147390246, "Item_Cloak_T02_MilitiaMonk" },
			{ 1275572025, "Item_Cloak_T02_PatchedCloak" },
			{ -1324340002, "Item_Cloak_T02_PlagueMaster" },
			{ -589858836, "Item_Cloak_T02_Poloma" },
			{ 1410262258, "Item_Cloak_T02_Razer" },
			{ -2081646636, "Item_Cloak_T02_Tailor" },
			{ 707710831, "Item_Cloak_T02_TornRags" },
			{ 239338934, "Item_Cloak_T02_WildlingBlue" },
			{ -1023114892, "Item_Cloak_T02_WildlingRed" },
			{ -1755568324, "Item_Cloak_T03_CrimsonWard" },
			{ -1814109557, "Item_Cloak_T03_Dracula" },
			{ 379281083, "Item_Cloak_T03_Jester" },
			{ 821609569, "Item_Cloak_T03_PlagueMaster" },
			{ 136740861, "Item_Cloak_T03_Razer" },
			{ 584164197, "Item_Cloak_T03_Royal" },
			{ 1863126275, "Item_Cloak_T03_UnholyShroud" },
			{ -2029933415, "Item_Gloves_T01_Bone" },
			{ 1746537832, "Item_Gloves_T02_BoneReinforced" },
			{ -1183157751, "Item_Gloves_T03_Cloth" },
			{ -258808647, "Item_Gloves_T04_Copper_Brute" },
			{ 181112381, "Item_Gloves_T04_Copper_Rogue" },
			{ -399521517, "Item_Gloves_T04_Copper_Scholar" },
			{ -752418019, "Item_Gloves_T04_Copper_Warrior" },
			{ -406808302, "Item_Gloves_T05_Cotton" },
			{ -327754127, "Item_Gloves_T06_Iron_Brute" },
			{ 322804535, "Item_Gloves_T06_Iron_Rogue" },
			{ 1247389106, "Item_Gloves_T06_Iron_Scholar" },
			{ 1067300584, "Item_Gloves_T06_Iron_Warrior" },
			{ 2055058719, "Item_Gloves_T07_Silk" },
			{ 998240678, "Item_Gloves_T08_DarkSilver_Brute" },
			{ -1752332712, "Item_Gloves_T08_DarkSilver_Rogue" },
			{ 1508214166, "Item_Gloves_T08_DarkSilver_Scholar" },
			{ -1296203752, "Item_Gloves_T08_DarkSilver_Warrior" },
			{ -204401621, "Item_Gloves_T09_Dracula" },
			{ 1039083725, "Item_Gloves_T09_Dracula_Brute" },
			{ -1826382550, "Item_Gloves_T09_Dracula_Rogue" },
			{ -1899539896, "Item_Gloves_T09_Dracula_Scholar" },
			{ 1982551454, "Item_Gloves_T09_Dracula_Warrior" },
			{ 1355823667, "Item_Legs_T01_Bone" },
			{ -2036196416, "Item_Legs_T02_BoneReinforced" },
			{ 1925394440, "Item_Legs_T03_Cloth" },
			{ -2095610608, "Item_Legs_T04_Copper_Brute" },
			{ -90702575, "Item_Legs_T04_Copper_Rogue" },
			{ 1458279255, "Item_Legs_T04_Copper_Scholar" },
			{ -1993947781, "Item_Legs_T04_Copper_Warrior" },
			{ 12127911, "Item_Legs_T05_Cotton" },
			{ 680112231, "Item_Legs_T06_Iron_Brute" },
			{ 744344540, "Item_Legs_T06_Iron_Rogue" },
			{ -454576348, "Item_Legs_T06_Iron_Scholar" },
			{ 206495029, "Item_Legs_T06_Iron_Warrior" },
			{ -1555051415, "Item_Legs_T07_Silk" },
			{ -1385786654, "Item_Legs_T08_DarkSilver_Brute" },
			{ -262114802, "Item_Legs_T08_DarkSilver_Rogue" },
			{ 703230071, "Item_Legs_T08_DarkSilver_Scholar" },
			{ -481041545, "Item_Legs_T08_DarkSilver_Warrior" },
			{ 125611165, "Item_Legs_T09_Dracula" },
			{ 993033515, "Item_Legs_T09_Dracula_Brute" },
			{ -345596442, "Item_Legs_T09_Dracula_Rogue" },
			{ 1592149279, "Item_Legs_T09_Dracula_Scholar" },
			{ 205207385, "Item_Legs_T09_Dracula_Warrior" },
			{ 1655869633, "Item_MagicSource_BloodKey_T01" },
			{ 1557814269, "Item_MagicSource_General_T01_BoneRing" },
			{ -652069131, "Item_MagicSource_General_T02_BloodBoneRing" },
			{ -1588051702, "Item_MagicSource_General_T03_GravediggerRing" },
			{ -809059551, "Item_MagicSource_General_T04_Duskwatcher" },
			{ 50824544, "Item_MagicSource_General_T04_EmberChain" },
			{ 336922685, "Item_MagicSource_General_T04_FrozenEye" },
			{ -886916793, "Item_MagicSource_General_T04_MistSignet" },
			{ 341837267, "Item_MagicSource_General_T04_RubyRing" },
			{ -1184863500, "Item_MagicSource_General_T04_SorcererRing" },
			{ -650855520, "Item_MagicSource_General_T05_Relic" },
			{ 199425997, "Item_MagicSource_General_T06_AmethystPendant" },
			{ -1046748791, "Item_MagicSource_General_T06_EmeraldNecklace" },
			{ 1012837641, "Item_MagicSource_General_T06_MistStoneNecklace" },
			{ -425306671, "Item_MagicSource_General_T06_RubyPendant" },
			{ -651554566, "Item_MagicSource_General_T06_SapphirePendant" },
			{ 610958202, "Item_MagicSource_General_T06_TopazAmulet" },
			{ 991396285, "Item_MagicSource_General_T07_BloodwineAmulet" },
			{ -104934480, "Item_MagicSource_General_T08_Blood" },
			{ -175650376, "Item_MagicSource_General_T08_Chaos" },
			{ 1380368392, "Item_MagicSource_General_T08_Frost" },
			{ -1306155896, "Item_MagicSource_General_T08_Illusion" },
			{ -296161379, "Item_MagicSource_General_T08_Storm" },
			{ -1004351840, "Item_MagicSource_General_T08_Unholy" },
			{ 666638454, "Item_MagicSource_SoulShard_Dracula" },
			{ -1260254082, "Item_MagicSource_SoulShard_Manticore" },
			{ -1581189572, "Item_MagicSource_SoulShard_Monster" },
			{ 1286615355, "Item_MagicSource_SoulShard_Morgana" },
			{ -21943750, "Item_MagicSource_SoulShard_Solarus" },
			{ 1259464735, "Item_Weapon_Axe_Legendary_T06" },
			{ -102830349, "Item_Weapon_Axe_Legendary_T08" },
			{ -1958888844, "Item_Weapon_Axe_T01_Bone" },
			{ -1391446205, "Item_Weapon_Axe_T02_Bone_Reinforced" },
			{ 1541522788, "Item_Weapon_Axe_T02_WoodCutter" },
			{ 518802008, "Item_Weapon_Axe_T03_Copper" },
			{ -491969324, "Item_Weapon_Axe_T04_Copper_Reinforced" },
			{ -1579575933, "Item_Weapon_Axe_T05_Iron" },
			{ 198951695, "Item_Weapon_Axe_T06_Iron_Reinforced" },
			{ -1130238142, "Item_Weapon_Axe_T07_DarkSilver" },
			{ -2044057823, "Item_Weapon_Axe_T08_Sanguine" },
			{ 2100090213, "Item_Weapon_Axe_T09_ShadowMatter" },
			{ 1239564213, "Item_Weapon_Axe_Unique_T08_Variation01" },
			{ -2060572315, "Item_Weapon_Claws_Legendary_T06" },
			{ -27238530, "Item_Weapon_Claws_Legendary_T08" },
			{ -1333849822, "Item_Weapon_Claws_T05_Iron" },
			{ 1748886117, "Item_Weapon_Claws_T06_Iron_Reinforced" },
			{ -1470260175, "Item_Weapon_Claws_T07_DarkSilver" },
			{ -1777908217, "Item_Weapon_Claws_T08_Sanguine" },
			{ -996999913, "Item_Weapon_Claws_Unique_T08_Variation01" },
			{ -517906196, "Item_Weapon_Crossbow_Legendary_T06" },
			{ 935392085, "Item_Weapon_Crossbow_Legendary_T08" },
			{ -20041991, "Item_Weapon_Crossbow_T01_Bone" },
			{ 898159697, "Item_Weapon_Crossbow_T02_Bone_Reinforced" },
			{ -1277074895, "Item_Weapon_Crossbow_T03_Copper" },
			{ -1636801169, "Item_Weapon_Crossbow_T04_Copper_Reinforced" },
			{ 836066667, "Item_Weapon_Crossbow_T05_Iron" },
			{ 1221976097, "Item_Weapon_Crossbow_T06_Iron_Reinforced" },
			{ -814739263, "Item_Weapon_Crossbow_T07_DarkSilver" },
			{ 1389040540, "Item_Weapon_Crossbow_T08_Sanguine" },
			{ 1957540013, "Item_Weapon_Crossbow_T09_ShadowMatter" },
			{ -1401104184, "Item_Weapon_Crossbow_Unique_T08_Variation01" },
			{ -1276458869, "Item_Weapon_Daggers_Legendary_T06" },
			{ 140761255, "Item_Weapon_Daggers_Legendary_T08" },
			{ 1296724931, "Item_Weapon_Daggers_T05_Iron" },
			{ 703783407, "Item_Weapon_Daggers_T06_Iron_Reinforced" },
			{ -211034148, "Item_Weapon_Daggers_T07_DarkSilver" },
			{ 1031107636, "Item_Weapon_Daggers_T08_Sanguine" },
			{ -1961050884, "Item_Weapon_Daggers_T09_ShadowMatter" },
			{ -1873605364, "Item_Weapon_Daggers_Unique_T08_Variation01" },
			{ 869276797, "Item_Weapon_GreatSword_Legendary_T06" },
			{ -1173681254, "Item_Weapon_GreatSword_Legendary_T08" },
			{ -768054337, "Item_Weapon_GreatSword_T05_Iron" },
			{ 82781195, "Item_Weapon_GreatSword_T06_Iron_Reinforced" },
			{ 674704033, "Item_Weapon_GreatSword_T07_DarkSilver" },
			{ 147836723, "Item_Weapon_GreatSword_T08_Sanguine" },
			{ 1322254792, "Item_Weapon_GreatSword_T09_ShadowMatter" },
			{ 820408138, "Item_Weapon_GreatSword_Unique_T08_Variation01" },
			{ -1003309553, "Item_Weapon_Longbow_Legendary_T06" },
			{ 1177453385, "Item_Weapon_Longbow_Legendary_T08" },
			{ 532033005, "Item_Weapon_Longbow_T03_Copper" },
			{ 352247730, "Item_Weapon_Longbow_T04_Copper_Reinforced" },
			{ -1993708658, "Item_Weapon_Longbow_T05_Iron" },
			{ 1951565953, "Item_Weapon_Longbow_T06_Iron_Reinforced" },
			{ -1830162796, "Item_Weapon_Longbow_T07_DarkSilver" },
			{ 1860352606, "Item_Weapon_Longbow_T08_Sanguine" },
			{ 1283345494, "Item_Weapon_Longbow_T09_ShadowMatter" },
			{ -557203874, "Item_Weapon_Longbow_Unique_T08_Variation01" },
			{ 1177597629, "Item_Weapon_Mace_Legendary_T06" },
			{ 1994084762, "Item_Weapon_Mace_Legendary_T08" },
			{ 1588258447, "Item_Weapon_Mace_T01_Bone" },
			{ -1998017941, "Item_Weapon_Mace_T02_Bone_Reinforced" },
			{ -687294429, "Item_Weapon_Mace_T02_Miners" },
			{ -331345186, "Item_Weapon_Mace_T03_Copper" },
			{ 343324920, "Item_Weapon_Mace_T04_Copper_Reinforced" },
			{ -1714012261, "Item_Weapon_Mace_T05_Iron" },
			{ -276593802, "Item_Weapon_Mace_T06_Iron_Reinforced" },
			{ -184713893, "Item_Weapon_Mace_T07_DarkSilver" },
			{ -126076280, "Item_Weapon_Mace_T08_Sanguine" },
			{ 160471982, "Item_Weapon_Mace_T09_ShadowMatter" },
			{ 675187526, "Item_Weapon_Mace_Unique_T08_Variation01" },
			{ 14297698, "Item_Weapon_Pistols_Legendary_T06" },
			{ -944318126, "Item_Weapon_Pistols_Legendary_T08" },
			{ 769603740, "Item_Weapon_Pistols_T05_Iron" },
			{ 1850870666, "Item_Weapon_Pistols_T06_Iron_Reinforced" },
			{ 674407758, "Item_Weapon_Pistols_T07_DarkSilver" },
			{ 1071656850, "Item_Weapon_Pistols_T08_Sanguine" },
			{ -1265586439, "Item_Weapon_Pistols_T09_ShadowMatter" },
			{ 1759077469, "Item_Weapon_Pistols_Unique_T08_Variation01" },
			{ -922125625, "Item_Weapon_Reaper_Legendary_T06" },
			{ -105026635, "Item_Weapon_Reaper_Legendary_T08" },
			{ -152327780, "Item_Weapon_Reaper_T01_Bone" },
			{ 1402953369, "Item_Weapon_Reaper_T02_Bone_Reinforced" },
			{ 1522792650, "Item_Weapon_Reaper_T03_Copper" },
			{ 1048518929, "Item_Weapon_Reaper_T04_Copper_Reinforced" },
			{ -2081286944, "Item_Weapon_Reaper_T05_Iron" },
			{ 1778128946, "Item_Weapon_Reaper_T06_Iron_Reinforced" },
			{ 1887724512, "Item_Weapon_Reaper_T06_Iron_UndeadGeneral" },
			{ 6711686, "Item_Weapon_Reaper_T07_DarkSilver" },
			{ -2053917766, "Item_Weapon_Reaper_T08_Sanguine" },
			{ -465491217, "Item_Weapon_Reaper_T09_ShadowMatter" },
			{ -859437190, "Item_Weapon_Reaper_Unique_T08_Variation01" },
			{ 1930526079, "Item_Weapon_Slashers_Legendary_T06" },
			{ 821410795, "Item_Weapon_Slashers_Legendary_T08" },
			{ -588909332, "Item_Weapon_Slashers_T01_Bone" },
			{ 926722036, "Item_Weapon_Slashers_T02_Bone_Reinforced" },
			{ 1499160417, "Item_Weapon_Slashers_T03_Copper" },
			{ -1042299347, "Item_Weapon_Slashers_T04_Copper_Reinforced" },
			{ -314614708, "Item_Weapon_Slashers_T05_Iron" },
			{ 866934844, "Item_Weapon_Slashers_T06_Iron_Reinforced" },
			{ 633666898, "Item_Weapon_Slashers_T07_DarkSilver" },
			{ 1322545846, "Item_Weapon_Slashers_T08_Sanguine" },
			{ 506082542, "Item_Weapon_Slashers_T09_ShadowMatter" },
			{ -2068145306, "Item_Weapon_Slashers_Unique_T08_Variation01" },
			{ 1570363331, "Item_Weapon_Slashers_Unique_T08_Variation02" },
			{ 2001389164, "Item_Weapon_Spear_Legendary_T06" },
			{ -1931117134, "Item_Weapon_Spear_Legendary_T08" },
			{ 2038011836, "Item_Weapon_Spear_T01_Bone" },
			{ 1244180446, "Item_Weapon_Spear_T02_Bone_Reinforced" },
			{ 1370755976, "Item_Weapon_Spear_T03_Copper" },
			{ 790210443, "Item_Weapon_Spear_T04_Copper_Reinforced" },
			{ 1853029976, "Item_Weapon_Spear_T05_Iron" },
			{ 1065194820, "Item_Weapon_Spear_T06_Iron_Reinforced" },
			{ -352704566, "Item_Weapon_Spear_T07_DarkSilver" },
			{ -850142339, "Item_Weapon_Spear_T08_Sanguine" },
			{ 1307774440, "Item_Weapon_Spear_T09_ShadowMatter" },
			{ -1674680373, "Item_Weapon_Spear_Unique_T08_Variation01" },
			{ 1637216050, "Item_Weapon_Sword_Legendary_T06" },
			{ 195858450, "Item_Weapon_Sword_Legendary_T08" },
			{ -2085919458, "Item_Weapon_Sword_T01_Bone" },
			{ -796306296, "Item_Weapon_Sword_T02_Bone_Reinforced" },
			{ -2037272000, "Item_Weapon_Sword_T03_Copper" },
			{ -1219959051, "Item_Weapon_Sword_T04_Copper_Reinforced" },
			{ -903587404, "Item_Weapon_Sword_T05_Iron" },
			{ -435501075, "Item_Weapon_Sword_T06_Iron_Reinforced" },
			{ -1455388114, "Item_Weapon_Sword_T07_DarkSilver" },
			{ -774462329, "Item_Weapon_Sword_T08_Sanguine" },
			{ -1215982687, "Item_Weapon_Sword_T09_ShadowMatter" },
			{ 2106567892, "Item_Weapon_Sword_Unique_T08_Variation01" },
			{ -1634108038, "Item_Weapon_TwinBlades_Legendary_T06" },
			{ 152014105, "Item_Weapon_TwinBlades_Legendary_T08" },
			{ -1122389049, "Item_Weapon_TwinBlades_T05_Iron" },
			{ -1651990235, "Item_Weapon_TwinBlades_T06_Iron_Reinforced" },
			{ -1595292245, "Item_Weapon_TwinBlades_T07_DarkSilver" },
			{ -297349982, "Item_Weapon_TwinBlades_T08_Sanguine" },
			{ -699863795, "Item_Weapon_TwinBlades_T09_ShadowMatter" },
			{ 601169005, "Item_Weapon_TwinBlades_Unique_T08_Variation01" },
			{ 1705984031, "Item_Weapon_Whip_Legendary_T06" },
			{ 429323760, "Item_Weapon_Whip_Legendary_T08" },
			{ -847062445, "Item_Weapon_Whip_T05_Iron" },
			{ 1393113320, "Item_Weapon_Whip_T06_Iron_Reinforced" },
			{ -960205578, "Item_Weapon_Whip_T07_DarkSilver" },
			{ -655095317, "Item_Weapon_Whip_T08_Sanguine" },
			{ 567413754, "Item_Weapon_Whip_T09_ShadowMatter" },
			{ -671246832, "Item_Weapon_Whip_Unique_T08_Variation01" }
		};

		public static string GetName(int guidHash)
		{
			if (!_names.TryGetValue(guidHash, out var value))
			{
				return null;
			}
			return value;
		}
	}
	public static class TierDatabase
	{
		private static readonly Dictionary<int, int> _tiers = new Dictionary<int, int>
		{
			{ 711062517, 1 },
			{ 329301090, 1 },
			{ -1819786494, 1 },
			{ -168044197, 1 },
			{ 1284160983, 1 },
			{ -24337506, 1 },
			{ 1261174372, 1 },
			{ -1514540144, 1 },
			{ -766642494, 1 },
			{ -305440546, 1 },
			{ 1335546377, 1 },
			{ 150621304, 1 },
			{ -2029933415, 1 },
			{ 1355823667, 1 },
			{ 1655869633, 1 },
			{ 1557814269, 1 },
			{ -1958888844, 1 },
			{ -20041991, 1 },
			{ 1588258447, 1 },
			{ -152327780, 1 },
			{ -588909332, 1 },
			{ 2038011836, 1 },
			{ -2085919458, 1 },
			{ 1241831522, 2 },
			{ -958936382, 2 },
			{ 786585343, 2 },
			{ -1768698241, 2 },
			{ -1067360120, 2 },
			{ 1677983904, 2 },
			{ -2091288477, 2 },
			{ 2147390246, 2 },
			{ 1275572025, 2 },
			{ -1324340002, 2 },
			{ -589858836, 2 },
			{ 1410262258, 2 },
			{ -2081646636, 2 },
			{ 707710831, 2 },
			{ 239338934, 2 },
			{ -1023114892, 2 },
			{ 1746537832, 2 },
			{ -2036196416, 2 },
			{ -652069131, 2 },
			{ -1391446205, 2 },
			{ 1541522788, 2 },
			{ 898159697, 2 },
			{ -1998017941, 2 },
			{ -687294429, 2 },
			{ 1402953369, 2 },
			{ 926722036, 2 },
			{ 1244180446, 2 },
			{ -796306296, 2 },
			{ -1354920908, 3 },
			{ -957963240, 3 },
			{ -227965303, 3 },
			{ -1755568324, 3 },
			{ -1814109557, 3 },
			{ 379281083, 3 },
			{ 821609569, 3 },
			{ 136740861, 3 },
			{ 584164197, 3 },
			{ 1863126275, 3 },
			{ -1183157751, 3 },
			{ 1925394440, 3 },
			{ -1588051702, 3 },
			{ 518802008, 3 },
			{ -1277074895, 3 },
			{ 532033005, 3 },
			{ -331345186, 3 },
			{ 1522792650, 3 },
			{ 1499160417, 3 },
			{ 1370755976, 3 },
			{ -2037272000, 3 },
			{ -1359494169, 4 },
			{ 1101206623, 4 },
			{ 1204352435, 4 },
			{ -15390086, 4 },
			{ -112921782, 4 },
			{ 763326246, 4 },
			{ -2100321922, 4 },
			{ 1809631067, 4 },
			{ -258808647, 4 },
			{ 181112381, 4 },
			{ -399521517, 4 },
			{ -752418019, 4 },
			{ -2095610608, 4 },
			{ -90702575, 4 },
			{ 1458279255, 4 },
			{ -1993947781, 4 },
			{ -809059551, 4 },
			{ 50824544, 4 },
			{ 336922685, 4 },
			{ -886916793, 4 },
			{ 341837267, 4 },
			{ -1184863500, 4 },
			{ -491969324, 4 },
			{ -1636801169, 4 },
			{ 352247730, 4 },
			{ 343324920, 4 },
			{ 1048518929, 4 },
			{ -1042299347, 4 },
			{ 790210443, 4 },
			{ -1219959051, 4 },
			{ -1837769884, 5 },
			{ -604941435, 5 },
			{ -406808302, 5 },
			{ 12127911, 5 },
			{ -650855520, 5 },
			{ -1579575933, 5 },
			{ -1333849822, 5 },
			{ 836066667, 5 },
			{ 1296724931, 5 },
			{ -768054337, 5 },
			{ -1993708658, 5 },
			{ -1714012261, 5 },
			{ 769603740, 5 },
			{ -2081286944, 5 },
			{ -314614708, 5 },
			{ 1853029976, 5 },
			{ -903587404, 5 },
			{ -1122389049, 5 },
			{ -847062445, 5 },
			{ -1329744719, 6 },
			{ 51576788, 6 },
			{ 138060378, 6 },
			{ 666433583, 6 },
			{ -1641042717, 6 },
			{ -69916288, 6 },
			{ -2127687996, 6 },
			{ -2102875089, 6 },
			{ -327754127, 6 },
			{ 322804535, 6 },
			{ 1247389106, 6 },
			{ 1067300584, 6 },
			{ 680112231, 6 },
			{ 744344540, 6 },
			{ -454576348, 6 },
			{ 206495029, 6 },
			{ 199425997, 6 },
			{ -1046748791, 6 },
			{ 1012837641, 6 },
			{ -425306671, 6 },
			{ -651554566, 6 },
			{ 610958202, 6 },
			{ 198951695, 6 },
			{ 1748886117, 6 },
			{ 1221976097, 6 },
			{ 703783407, 6 },
			{ 82781195, 6 },
			{ 1951565953, 6 },
			{ -276593802, 6 },
			{ 1850870666, 6 },
			{ 1778128946, 6 },
			{ 1887724512, 6 },
			{ 866934844, 6 },
			{ 1065194820, 6 },
			{ -435501075, 6 },
			{ -1651990235, 6 },
			{ 1393113320, 6 },
			{ 560446510, 7 },
			{ -930514044, 7 },
			{ 2055058719, 7 },
			{ -1555051415, 7 },
			{ 991396285, 7 },
			{ -1130238142, 7 },
			{ -1470260175, 7 },
			{ -814739263, 7 },
			{ -211034148, 7 },
			{ 674704033, 7 },
			{ -1830162796, 7 },
			{ -184713893, 7 },
			{ 674407758, 7 },
			{ 6711686, 7 },
			{ 633666898, 7 },
			{ -352704566, 7 },
			{ -1455388114, 7 },
			{ -1595292245, 7 },
			{ -960205578, 7 },
			{ -1023762087, 8 },
			{ -1921018689, 8 },
			{ 1469185034, 8 },
			{ 1395895315, 8 },
			{ -1279475298, 8 },
			{ 1871735757, 8 },
			{ -919709436, 8 },
			{ 750788905, 8 },
			{ 998240678, 8 },
			{ -1752332712, 8 },
			{ 1508214166, 8 },
			{ -1296203752, 8 },
			{ -1385786654, 8 },
			{ -262114802, 8 },
			{ 703230071, 8 },
			{ -481041545, 8 },
			{ -104934480, 8 },
			{ -175650376, 8 },
			{ 1380368392, 8 },
			{ -1306155896, 8 },
			{ -296161379, 8 },
			{ -1004351840, 8 },
			{ -2044057823, 8 },
			{ -1777908217, 8 },
			{ 1389040540, 8 },
			{ 1031107636, 8 },
			{ 147836723, 8 },
			{ 1860352606, 8 },
			{ -126076280, 8 },
			{ 1071656850, 8 },
			{ -2053917766, 8 },
			{ 1322545846, 8 },
			{ -850142339, 8 },
			{ -774462329, 8 },
			{ -297349982, 8 },
			{ -655095317, 8 },
			{ 666638454, 8 },
			{ -1260254082, 8 },
			{ -1581189572, 8 },
			{ 1286615355, 8 },
			{ -21943750, 8 },
			{ 1259464735, 7 },
			{ -2060572315, 7 },
			{ -517906196, 7 },
			{ -1276458869, 7 },
			{ 869276797, 7 },
			{ -1003309553, 7 },
			{ 1177597629, 7 },
			{ 14297698, 7 },
			{ -922125625, 7 },
			{ 1930526079, 7 },
			{ 2001389164, 7 },
			{ 1637216050, 7 },
			{ -1634108038, 7 },
			{ 1705984031, 7 },
			{ -102830349, 9 },
			{ 1239564213, 9 },
			{ -27238530, 9 },
			{ -996999913, 9 },
			{ 935392085, 9 },
			{ -1401104184, 9 },
			{ 140761255, 9 },
			{ -1873605364, 9 },
			{ -1173681254, 9 },
			{ 820408138, 9 },
			{ 1177453385, 9 },
			{ -557203874, 9 },
			{ 1994084762, 9 },
			{ 675187526, 9 },
			{ -944318126, 9 },
			{ 1759077469, 9 },
			{ -105026635, 9 },
			{ -859437190, 9 },
			{ 821410795, 9 },
			{ -2068145306, 9 },
			{ 1570363331, 9 },
			{ -1931117134, 9 },
			{ -1674680373, 9 },
			{ 195858450, 9 },
			{ 2106567892, 9 },
			{ 152014105, 9 },
			{ 601169005, 9 },
			{ 429323760, 9 },
			{ -671246832, 9 },
			{ 1400688919, 9 },
			{ 1646489863, 9 },
			{ 1855323424, 9 },
			{ 1531721602, 9 },
			{ -382349289, 9 },
			{ 1055898174, 9 },
			{ 1033753207, 9 },
			{ 933057100, 9 },
			{ 114259912, 9 },
			{ 1392314162, 9 },
			{ -204401621, 9 },
			{ 1039083725, 9 },
			{ -1826382550, 9 },
			{ -1899539896, 9 },
			{ 1982551454, 9 },
			{ 125611165, 9 },
			{ 993033515, 9 },
			{ -345596442, 9 },
			{ 1592149279, 9 },
			{ 205207385, 9 },
			{ 2100090213, 9 },
			{ 1957540013, 9 },
			{ -1961050884, 9 },
			{ 1322254792, 9 },
			{ 1283345494, 9 },
			{ 160471982, 9 },
			{ -1265586439, 9 },
			{ -465491217, 9 },
			{ 506082542, 9 },
			{ 1307774440, 9 },
			{ -1215982687, 9 },
			{ -699863795, 9 },
			{ 567413754, 9 }
		};

		public static bool TryGetTier(PrefabGUID guid, out int tier)
		{
			return _tiers.TryGetValue(((PrefabGUID)(ref guid)).GuidHash, out tier);
		}
	}
}
namespace BestGearGuard.Patches
{
	[HarmonyPatch]
	public static class GearCheckPatch
	{
		private static readonly HashSet<ulong> _warned = new HashSet<ulong>();

		[HarmonyPatch(typeof(ArmorLevelSystem_Spawn), "OnUpdate")]
		[HarmonyPostfix]
		public static void ArmorPostfix(ArmorLevelSystem_Spawn __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			CheckAllPlayers(((ComponentSystemBase)__instance).EntityManager);
		}

		[HarmonyPatch(typeof(WeaponLevelSystem_Spawn), "OnUpdate")]
		[HarmonyPostfix]
		public static void WeaponPostfix(WeaponLevelSystem_Spawn __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			CheckAllPlayers(((ComponentSystemBase)__instance).EntityManager);
		}

		[HarmonyPatch(typeof(EquipItemFromInventorySystem), "OnUpdate")]
		[HarmonyPostfix]
		public static void EquipFromInventoryPostfix(EquipItemFromInventorySystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			CheckAllPlayers(((ComponentSystemBase)__instance).EntityManager);
		}

		[HarmonyPatch(typeof(EquipItemSystem), "OnUpdate")]
		[HarmonyPostfix]
		public static void EquipPostfix(EquipItemSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			CheckAllPlayers(((ComponentSystemBase)__instance).EntityManager);
		}

		private static void CheckAllPlayers(EntityManager em)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0034: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00a0: 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_00db: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!GearGuardSettings.Enabled.Value)
			{
				return;
			}
			EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					User componentData = ((EntityManager)(ref em)).GetComponentData<User>(current);
					if (!componentData.IsConnected)
					{
						continue;
					}
					Entity entity = componentData.LocalCharacter._Entity;
					if (entity == Entity.Null || !((EntityManager)(ref em)).Exists(entity))
					{
						continue;
					}
					if (!GearCheckerService.CheckViolation(em, entity, out var armorMaxTier, out var weaponMaxTier))
					{
						_warned.Remove(componentData.PlatformId);
						if (GearGuardSettings.DebuffEnabled.Value && GearGuardSettings.DebuffEnabled.Value)
						{
							GearDebuffService.RemoveDebuff(em, entity);
						}
						continue;
					}
					if (GearGuardSettings.DebuffEnabled.Value)
					{
						GearDebuffService.ApplyDebuff(em, entity);
					}
					if (!_warned.Contains(componentData.PlatformId))
					{
						_warned.Add(componentData.PlatformId);
						SendWarning(em, componentData, armorMaxTier, weaponMaxTier);
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
		}

		private static void SendWarning(EntityManager em, User user, int armorMaxTier, int weaponMaxTier)
		{
			//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_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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_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)
			FixedString512Bytes val = FixedString512Bytes.op_Implicit("<color=#ff5555>[GearGuard] WARNING: Your weapon/amulet tier is too high!</color>");
			FixedString512Bytes val2 = FixedString512Bytes.op_Implicit($"<color=#ffaa00>Your weapon/amulet (Tier {weaponMaxTier}) exceeds your armor (Tier {armorMaxTier}) by more than {GearGuardSettings.MaxTierDifference.Value}.</color>");
			FixedString512Bytes val3 = FixedString512Bytes.op_Implicit("<color=#ffaa00>Please adjust your equipment to comply with the server rules.</color>");
			ServerChatUtils.SendSystemMessageToClient(em, user, ref val);
			ServerChatUtils.SendSystemMessageToClient(em, user, ref val2);
			ServerChatUtils.SendSystemMessageToClient(em, user, ref val3);
		}
	}
}
namespace BestGearGuard.Commands
{
	internal class GearGuardCommand
	{
		[Command("gg-reload", "ggr", null, "Reloads gearguard.cfg from disk", null, true)]
		public static void Reload(ChatCommandContext ctx)
		{
			GearGuardSettings.Reload();
			ctx.Reply("<color=#00ff88>[GearGuard]</color> Configuration reloaded.");
		}

		[Command("gg-toggle", "ggt", null, "Enable or disable GearGuard. Usage: .gg-toggle on|off", null, true)]
		public static void Toggle(ChatCommandContext ctx, string state)
		{
			string text = state.ToLower();
			if (!(text == "on"))
			{
				if (text == "off")
				{
					GearGuardSettings.Enabled.Value = false;
					ctx.Reply("<color=#00ff88>[GearGuard]</color> Gear enforcement <color=#ff5555>disabled</color>.");
				}
				else
				{
					ctx.Reply("<color=#ff5555>[GearGuard]</color> Usage: .gg-toggle on|off");
				}
			}
			else
			{
				GearGuardSettings.Enabled.Value = true;
				ctx.Reply("<color=#00ff88>[GearGuard]</color> Gear enforcement <color=#00ff00>enabled</color>.");
			}
		}

		[Command("gg-check", "ggc", null, "Check a player's gear tier compliance. Usage: .gg-check <playerName>", null, true)]
		public static void CheckPlayer(ChatCommandContext ctx, string playerName)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			EntityManager serverEntityManager = VWorld.ServerEntityManager;
			var (val, val2) = FindPlayer(serverEntityManager, playerName);
			if (val == Entity.Null)
			{
				ctx.Reply("<color=#ff5555>[GearGuard]</color> Player '" + playerName + "' not found or offline.");
				return;
			}
			Entity entity = val2.LocalCharacter._Entity;
			int armorMaxTier;
			int weaponMaxTier;
			if (entity == Entity.Null || !((EntityManager)(ref serverEntityManager)).Exists(entity))
			{
				ctx.Reply("<color=#ff5555>[GearGuard]</color> Could not find character entity for '" + playerName + "'.");
			}
			else if (GearCheckerService.CheckViolation(serverEntityManager, entity, out armorMaxTier, out weaponMaxTier))
			{
				ctx.Reply("<color=#ff5555>[GearGuard] WARNING: " + playerName + " is in violation!</color>");
				ctx.Reply($"  Armor max: <color=#ffffff>Tier {armorMaxTier}</color>  |  Weapon/Amulet max: <color=#ffffff>Tier {weaponMaxTier}</color>");
			}
			else
			{
				ctx.Reply($"<color=#00ff88>[GearGuard]</color> {playerName}'s gear is compliant. (Armor T{armorMaxTier} / Weapon T{weaponMaxTier})");
			}
		}

		[Command("gg-inspect", "ggi", null, "Inspect all equipped items of a player. Usage: .gg-inspect <playerName>", null, true)]
		public static void InspectPlayer(ChatCommandContext ctx, string playerName)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			EntityManager serverEntityManager = VWorld.ServerEntityManager;
			var (val, val2) = FindPlayer(serverEntityManager, playerName);
			if (val == Entity.Null)
			{
				ctx.Reply("<color=#ff5555>[GearGuard]</color> Player '" + playerName + "' not found or offline.");
				return;
			}
			Entity entity = val2.LocalCharacter._Entity;
			if (entity == Entity.Null || !((EntityManager)(ref serverEntityManager)).Exists(entity))
			{
				ctx.Reply("<color=#ff5555>[GearGuard]</color> Could not find character entity for '" + playerName + "'.");
				return;
			}
			if (!((EntityManager)(ref serverEntityManager)).HasComponent<Equipment>(entity))
			{
				ctx.Reply("<color=#ff5555>[GearGuard]</color> No Equipment component found on '" + playerName + "'.");
				return;
			}
			Equipment componentData = ((EntityManager)(ref serverEntityManager)).GetComponentData<Equipment>(entity);
			(EquipmentType, string)[] obj = new(EquipmentType, string)[6]
			{
				((EquipmentType)1, "Chest  "),
				((EquipmentType)9, "Gloves "),
				((EquipmentType)5, "Legs   "),
				((EquipmentType)4, "Boots  "),
				((EquipmentType)2, "Weapon "),
				((EquipmentType)3, "Amulet ")
			};
			ctx.Reply("<color=#ffaa00>--- Equipment of " + playerName + " ---</color>");
			(EquipmentType, string)[] array = obj;
			for (int i = 0; i < array.Length; i++)
			{
				(EquipmentType, string) tuple2 = array[i];
				EquipmentType item = tuple2.Item1;
				string item2 = tuple2.Item2;
				PrefabGUID equipmentItemId = ((Equipment)(ref componentData)).GetEquipmentItemId(item);
				if (((PrefabGUID)(ref equipmentItemId)).GuidHash == 0)
				{
					ctx.Reply("  " + item2 + ": <color=#888888>empty</color>");
					continue;
				}
				int tier;
				string value = (TierDatabase.TryGetTier(equipmentItemId, out tier) ? $"<color=#00ff88>Tier {tier}</color>" : "<color=#ffaa00>Tier ?</color>");
				string name = NameDatabase.GetName(((PrefabGUID)(ref equipmentItemId)).GuidHash);
				string value2 = ((name != null) ? Regex.Replace(name, "^Item_[^_]+_", "") : $"[{((PrefabGUID)(ref equipmentItemId)).GuidHash}]");
				ctx.Reply($"  {item2}: {value}  <color=#aaaaaa>{value2}</color>");
			}
			ctx.Reply($"<color=#ffaa00>Levels</color> — Weapon: <color=#ffffff>{((ModifiableFloat)(ref componentData.WeaponLevel)).Value:F0}</color>  Armor: <color=#ffffff>{((ModifiableFloat)(ref componentData.ArmorLevel)).Value:F0}</color>  Spell: <color=#ffffff>{((ModifiableFloat)(ref componentData.SpellLevel)).Value:F0}</color>");
		}

		[Command("gg-debuff", "ggd", null, "Enable or disable the violation debuff. Usage: .gg-debuff on|off", null, true)]
		public static void Debuff(ChatCommandContext ctx, string state)
		{
			string text = state.ToLower();
			if (!(text == "on"))
			{
				if (text == "off")
				{
					GearGuardSettings.DebuffEnabled.Value = false;
					ctx.Reply("<color=#00ff88>[GearGuard]</color> Violation debuff <color=#ff5555>disabled</color>.");
				}
				else
				{
					ctx.Reply("<color=#ff5555>[GearGuard]</color> Usage: .gg-debuff on|off");
				}
			}
			else
			{
				GearGuardSettings.DebuffEnabled.Value = true;
				ctx.Reply("<color=#00ff88>[GearGuard]</color> Violation debuff <color=#00ff00>enabled</color>.");
			}
		}

		[Command("gg-status", "ggs", null, "Shows current GearGuard configuration", null, true)]
		public static void Status(ChatCommandContext ctx)
		{
			string text = (GearGuardSettings.Enabled.Value ? "<color=#00ff00>ON</color>" : "<color=#ff5555>OFF</color>");
			string text2 = (GearGuardSettings.DebuffEnabled.Value ? "<color=#00ff00>ON</color>" : "<color=#ff5555>OFF</color>");
			ctx.Reply("<color=#ffaa00>--- GearGuard Status ---</color>");
			ctx.Reply("  Enforcement   : " + text);
			ctx.Reply($"  Max tier diff : <color=#ffffff>{GearGuardSettings.MaxTierDifference.Value}</color>");
			ctx.Reply("  Debuff        : " + text2);
		}

		private static (Entity userEntity, User user) FindPlayer(EntityManager em, string playerName)
		{
			//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_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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0087: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					User componentData = ((EntityManager)(ref em)).GetComponentData<User>(current);
					if (((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString().ToLower() == playerName.ToLower())
					{
						return (current, componentData);
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
			return (Entity.Null, default(User));
		}
	}
}