Decompiled source of Jewelcrafting v2.0.1

Jewelcrafting.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using APIManager;
using AzuEPI;
using AzuEPI.Core.Slots;
using AzuExtendedPlayerInventory;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Preloader;
using BepInEx.Preloader.Patching;
using CreatureLevelControl;
using Groups;
using HarmonyLib;
using ItemDataManager;
using ItemManager;
using JetBrains.Annotations;
using Jewelcrafting.CrystalCase;
using Jewelcrafting.Effects;
using Jewelcrafting.GemEffects;
using Jewelcrafting.GemEffects.Groups;
using Jewelcrafting.LootSystem;
using Jewelcrafting.Setup;
using Jewelcrafting.WorldBosses;
using LocalizationManager;
using LocationManager;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using PieceManager;
using ServerSync;
using SkillManager;
using SoftReferenceableAssets;
using Splatform;
using StatManager;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Jewelcrafting")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/Smoothbrain/Jewelcrafting")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Jewelcrafting")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("150BFDAF-FF35-4302-B7CC-BEDCE69118D5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Jewelcrafting
{
	[PublicAPI]
	public static class API
	{
		[PublicAPI]
		public class GemInfo
		{
			public readonly string gemPrefab;

			public readonly Dictionary<string, uint>? gemSeed;

			public readonly Sprite gemSprite;

			public readonly Dictionary<string, float> gemEffects;

			public readonly Dictionary<string, float[]> gemEffectsPowerRange;

			public GemInfo(string gemPrefab, Sprite gemSprite, Dictionary<string, float> gemEffects, Dictionary<string, float[]> gemEffectsPowerRange, Dictionary<string, uint>? gemSeed = null)
			{
				this.gemPrefab = gemPrefab;
				this.gemSeed = gemSeed;
				this.gemSprite = gemSprite;
				this.gemEffects = gemEffects;
				this.gemEffectsPowerRange = gemEffectsPowerRange;
				base..ctor();
			}
		}

		public delegate bool GemBreakHandler(ItemData? container, ItemData gem, int count = 1);

		public delegate bool ItemBreakHandler(ItemData? container);

		public delegate bool ItemMirroredHandler(ItemData? item);

		public static event Action? OnEffectRecalc;

		public static bool IsLoaded()
		{
			return true;
		}

		internal static void InvokeEffectRecalc()
		{
			API.OnEffectRecalc?.Invoke();
		}

		private static GameObject CreateNecklaceFromTemplate(string colorName, MaterialColor color)
		{
			GameObject val = JewelrySetup.CreateNecklaceFromTemplate(colorName, color);
			MarkJewelry(val);
			return val;
		}

		public static GameObject CreateNecklaceFromTemplate(string colorName, Color color)
		{
			//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)
			return CreateNecklaceFromTemplate(colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject CreateNecklaceFromTemplate(string colorName, Material material)
		{
			return CreateNecklaceFromTemplate(colorName, new MaterialColor
			{
				Material = material
			});
		}

		private static GameObject CreateRingFromTemplate(string colorName, MaterialColor color)
		{
			GameObject val = JewelrySetup.CreateRingFromTemplate(colorName, color);
			MarkJewelry(val);
			return val;
		}

		public static GameObject CreateRingFromTemplate(string colorName, Color color)
		{
			//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)
			return CreateRingFromTemplate(colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject CreateRingFromTemplate(string colorName, Material material)
		{
			return CreateRingFromTemplate(colorName, new MaterialColor
			{
				Material = material
			});
		}

		public static void MarkJewelry(GameObject jewelry)
		{
			JewelrySetup.MarkJewelry(jewelry);
		}

		private static List<GameObject> AddGems(string type, string colorName, MaterialColor color)
		{
			if (string.Equals(colorName, "White", StringComparison.InvariantCultureIgnoreCase))
			{
				throw new Exception(colorName + " is a reserved color.");
			}
			List<GameObject> list = new List<GameObject>
			{
				AddShardFromTemplate(type, colorName, color),
				RegisterUncut(type, colorName, AddUncutFromTemplate(type, colorName, color)),
				AddDestructibleFromTemplate(type, colorName, color)
			};
			list.AddRange(AddTieredGemFromTemplate(type, colorName, color));
			return list;
		}

		public static void AddGems(string type, string colorName, Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			AddGems(type, colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static List<GameObject> AddGems(string type, string colorName, Material material, Color color)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return AddGems(type, colorName, new MaterialColor
			{
				Material = material,
				Color = color
			});
		}

		private static GameObject AddDestructibleFromTemplate(string type, string colorName, MaterialColor color)
		{
			string colorName2 = colorName;
			if (!GemStoneSetup.uncutGems.ContainsKey((GemType)StringExtensionMethods.GetStableHashCode(colorName2)))
			{
				throw new Exception("A destructible for " + colorName2 + " must be registered after the uncut gemstone");
			}
			GameObject val = DestructibleSetup.CreateDestructibleFromTemplate(DestructibleSetup.customDestructiblePrefab, colorName2, color);
			Localizer.AddText(val.GetComponent<HoverText>().m_text.Substring(1), type + " Formation");
			AddDestructible(val, colorName2);
			string name = new StackTrace().GetFrame(1).GetMethod().DeclaringType.Assembly.GetName().Name;
			EffectDef.Loader.instance.parsed.Add("/" + name + "/" + type + ".yml", new EffectDef.ParseResult
			{
				gemDistribution = EffectDef.Loader.instance.DefaultConfig.gemDistribution.ToDictionary<KeyValuePair<Biome, Dictionary<GemType, float>>, Biome, Dictionary<GemType, float>>((KeyValuePair<Biome, Dictionary<GemType, float>> kv) => kv.Key, (KeyValuePair<Biome, Dictionary<GemType, float>> _) => new Dictionary<GemType, float> { 
				{
					(GemType)StringExtensionMethods.GetStableHashCode(colorName2),
					0.04f
				} })
			});
			return val;
		}

		public static GameObject AddDestructibleFromTemplate(string type, string colorName, Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return AddDestructibleFromTemplate(type, colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject AddDestructibleFromTemplate(string type, string colorName, Material material)
		{
			return AddDestructibleFromTemplate(type, colorName, new MaterialColor
			{
				Material = material
			});
		}

		private static GameObject AddUncutFromTemplate(string type, string colorName, MaterialColor color)
		{
			GameObject val = GemStoneSetup.CreateUncutFromTemplate(GemStoneSetup.customUncutGemPrefab, colorName, color);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			Localizer.AddText(shared.m_name.Substring(1), type + " Gemstone");
			Localizer.AddText(shared.m_description.Substring(1), "A " + colorName + " gemstone, ready to be cut at a Gemcutters Table.");
			return val;
		}

		public static GameObject AddUncutFromTemplate(string type, string colorName, Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return AddUncutFromTemplate(type, colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject AddUncutFromTemplate(string type, string colorName, Material material)
		{
			return AddUncutFromTemplate(type, colorName, new MaterialColor
			{
				Material = material
			});
		}

		private static GameObject RegisterUncut(string type, string colorName, GameObject uncutGem)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			AddUncutGem(uncutGem, colorName, Jewelcrafting.config("Gem Drops", "Drop chance for " + type + " Gemstones", 1.5f, new ConfigDescription("Chance to drop an " + type.ToLower() + " gemstone when killing creatures.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())));
			return uncutGem;
		}

		public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return RegisterUncut(type, colorName, AddUncutFromTemplate(type, colorName, color));
		}

		public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Material material)
		{
			return RegisterUncut(type, colorName, AddUncutFromTemplate(type, colorName, material));
		}

		private static GameObject AddShardFromTemplate(string type, string colorName, MaterialColor color)
		{
			GameObject val = GemStoneSetup.CreateShardFromTemplate(GemStoneSetup.customGemShardPrefab, colorName, color);
			AddShard(val, colorName);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			Localizer.AddText(shared.m_name.Substring(1), type + " Shard");
			Localizer.AddText(shared.m_description.Substring(1), "A " + colorName + " gemstone, which can be socketed into an equipment piece, to unlock the power within.");
			return val;
		}

		public static GameObject AddShardFromTemplate(string type, string colorName, Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return AddShardFromTemplate(type, colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject AddShardFromTemplate(string type, string colorName, Material material)
		{
			return AddShardFromTemplate(type, colorName, new MaterialColor
			{
				Material = material
			});
		}

		private static GameObject[] AddTieredGemFromTemplate(string type, string colorName, MaterialColor color)
		{
			GameObject[] array = (GameObject[])(object)new GameObject[GemStoneSetup.customGemTierPrefabs.Length];
			Localizer.AddText("jc_merged_gemstone_" + colorName.Replace(" ", "_").ToLower(), type);
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = GemStoneSetup.CreateGemFromTemplate(GemStoneSetup.customGemTierPrefabs[i], colorName, color, i);
				SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
				string key = shared.m_name.Substring(1);
				if (1 == 0)
				{
				}
				string text = i switch
				{
					0 => "Simple", 
					1 => "Advanced", 
					_ => "Perfect", 
				};
				if (1 == 0)
				{
				}
				Localizer.AddText(key, text + " " + type);
				Localizer.AddText(shared.m_description.Substring(1), "A " + colorName + " gemstone, which can be socketed into an equipment piece, to unlock the power within.");
				GemStoneSetup.RegisterTieredGemItem(val, colorName, i);
				AddGem(val, colorName);
				array[i] = val;
			}
			GemType stableHashCode = (GemType)StringExtensionMethods.GetStableHashCode(colorName);
			MergedGemStoneSetup.mergedGems[stableHashCode] = new Dictionary<GemType, GameObject[]>();
			foreach (KeyValuePair<GemType, MaterialColor> color2 in GemStoneSetup.Colors)
			{
				MergedGemStoneSetup.CreateMergedGemStone(new KeyValuePair<GemType, MaterialColor>(stableHashCode, color), color2);
				MergedGemStoneSetup.CreateMergedGemStone(color2, new KeyValuePair<GemType, MaterialColor>(stableHashCode, color));
			}
			GemStoneSetup.Colors.Add(stableHashCode, color);
			return array;
		}

		public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return AddTieredGemFromTemplate(type, colorName, new MaterialColor
			{
				Color = color
			});
		}

		public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Material material, Color color)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return AddTieredGemFromTemplate(type, colorName, new MaterialColor
			{
				Material = material,
				Color = color
			});
		}

		public static void AddGem(GameObject prefab, string colorName)
		{
			EffectDef.ValidGemTypes[colorName] = (GemType)StringExtensionMethods.GetStableHashCode(colorName);
			EffectDef.GemTypeNames[(GemType)StringExtensionMethods.GetStableHashCode(colorName)] = colorName.Replace(" ", "_");
			GemStoneSetup.RegisterGem(prefab, (GemType)StringExtensionMethods.GetStableHashCode(colorName));
		}

		public static void AddShard(GameObject prefab, string colorName)
		{
			if (GemStoneSetup.Gems.ContainsKey((GemType)StringExtensionMethods.GetStableHashCode(colorName)))
			{
				throw new Exception("A shard for " + colorName + " must be registered before any gems for " + colorName);
			}
			GemStoneSetup.RegisterShard(prefab, (GemType)StringExtensionMethods.GetStableHashCode(colorName));
		}

		public static void AddDestructible(GameObject prefab, string colorName)
		{
			DestructibleSetup.AddDestructible(prefab, (GemType)StringExtensionMethods.GetStableHashCode(colorName));
		}

		public static void AddUncutGem(GameObject prefab, string colorName, ConfigEntry<float>? dropChance = null)
		{
			GemStoneSetup.RegisterUncutGem(prefab, (GemType)StringExtensionMethods.GetStableHashCode(colorName), dropChance);
		}

		public static void AddGemEffect<T>(string name, string? englishDescription = null, string? englishDescriptionDetailed = null) where T : struct
		{
			EffectDef.ConfigTypes.Add((Effect)StringExtensionMethods.GetStableHashCode(name), typeof(T));
			EffectDef.ValidEffects[name] = (Effect)StringExtensionMethods.GetStableHashCode(name);
			EffectDef.EffectNames[(Effect)StringExtensionMethods.GetStableHashCode(name)] = name.Replace(" ", "_");
			Localizer.AddText("jc_effect_" + name.Replace(" ", "_").ToLower(), name);
			if (englishDescription != null)
			{
				Localizer.AddText("jc_effect_" + name.Replace(" ", "_").ToLower() + "_desc", englishDescription);
			}
			if (englishDescriptionDetailed != null)
			{
				Localizer.AddText("jc_effect_" + name.Replace(" ", "_").ToLower() + "_desc_detail", englishDescriptionDetailed);
			}
			Utils.zdoNames[(Effect)StringExtensionMethods.GetStableHashCode(name)] = "Jewelcrafting Socket " + name;
		}

		public static void AddGemConfig(string yaml)
		{
			string name = new StackTrace().GetFrame(1).GetMethod().DeclaringType.Assembly.GetName().Name;
			List<string> list = ConfigLoader.loaders.Single((ConfigLoader.Loader l) => l.GetType() == typeof(EffectDef.Loader)).ProcessConfig("/" + name + ".yml", new DeserializerBuilder().Build().Deserialize<Dictionary<object, object>>(yaml), global: true);
			foreach (string item in list)
			{
				Debug.LogError((object)("Error in config of Gem config specified by mod " + name + ": " + item));
			}
		}

		public static T GetEffectPower<T>(this Player player, string name) where T : struct
		{
			return player.GetEffect<T>((Effect)StringExtensionMethods.GetStableHashCode(name));
		}

		public static List<GemInfo?> GetGems(ItemData item)
		{
			List<GemInfo> list = new List<GemInfo>();
			Socketable socketable = item.Data().Get<Socketable>();
			if (socketable != null)
			{
				if (socketable is Box box)
				{
					float progress = box.progress;
					if (!(progress >= 100f))
					{
						goto IL_0042;
					}
				}
				else if (!(socketable is SocketBag))
				{
					goto IL_0042;
				}
			}
			bool flag = false;
			goto IL_004a;
			IL_0042:
			flag = true;
			goto IL_004a;
			IL_004a:
			GemLocation location;
			if (flag)
			{
				location = Utils.GetGemLocation(item.m_shared);
				foreach (SocketItem socketedGem in socketable.socketedGems)
				{
					if (!(socketedGem.Name == ""))
					{
						GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(socketedGem.Name);
						if (itemPrefab != null)
						{
							list.Add(new GemInfo(((Object)itemPrefab).name, itemPrefab.GetComponent<ItemDrop>().m_itemData.GetIcon(), effects(socketedGem.Name).ToDictionary((EffectPower e) => EffectDef.EffectNames[e.Effect].Replace("_", " "), (EffectPower e) => (e.MinPower + e.MaxPower) / 2f), effects(socketedGem.Name).ToDictionary((EffectPower e) => EffectDef.EffectNames[e.Effect].Replace("_", " "), (EffectPower e) => new float[2] { e.MinPower, e.MaxPower }), socketedGem.Seed));
							continue;
						}
					}
					list.Add(null);
				}
			}
			return list;
			IEnumerable<EffectPower> effects(string socket)
			{
				IEnumerable<EffectPower> result;
				if (!Jewelcrafting.EffectPowers.TryGetValue(StringExtensionMethods.GetStableHashCode(socket), out Dictionary<GemLocation, List<EffectPower>> value) || !value.TryGetValue(location, out var value2))
				{
					result = Enumerable.Empty<EffectPower>();
				}
				else
				{
					IEnumerable<EffectPower> enumerable = value2;
					result = enumerable;
				}
				return result;
			}
		}

		public static bool SetGems(ItemData item, List<GemInfo?> gems)
		{
			if (!Utils.IsSocketableItem(item))
			{
				return false;
			}
			Socketable socketable = item.Data().Get<Socketable>() ?? item.Data().Add<Sockets>();
			socketable.socketedGems.Clear();
			foreach (GemInfo gem in gems)
			{
				socketable.socketedGems.Add((gem == null) ? new SocketItem("") : new SocketItem(gem.gemPrefab));
			}
			if (socketable is Sockets && socketable.socketedGems.Count == 0)
			{
				item.Data().Remove(socketable);
			}
			else
			{
				socketable.Save();
			}
			return true;
		}

		public static Sprite GetSocketBorder()
		{
			return GemStones.emptySocketSprite;
		}

		public static GameObject GetGemcuttersTable()
		{
			return BuildingPiecesSetup.gemcuttersTable;
		}

		public static void AddParticleEffect(string prefabName, GameObject effect, VisualEffectCondition displayCondition)
		{
			if (VisualEffects.attachEffectPrefabs.TryGetValue(prefabName, out Dictionary<VisualEffectCondition, GameObject> value))
			{
				value.Add(displayCondition, effect);
				return;
			}
			VisualEffects.attachEffectPrefabs[prefabName] = new Dictionary<VisualEffectCondition, GameObject> { { displayCondition, effect } };
		}

		public static void SetSocketsLock(ItemData item, bool enabled)
		{
			if (enabled)
			{
				item.Data()["SocketsLock"] = "";
			}
			else
			{
				item.Data().Remove("SocketsLock");
			}
		}

		public static void SetSocketSlotsLock(ItemData item, bool enabled)
		{
			if (enabled)
			{
				item.Data()["SocketSlotsLock"] = "";
			}
			else
			{
				item.Data().Remove("SocketSlotsLock");
			}
		}

		public static void OnGemBreak(GemBreakHandler callback)
		{
			GemStones.GemBreakHandlers.Add(callback);
		}

		public static void OnItemBreak(ItemBreakHandler callback)
		{
			GemStones.ItemBreakHandlers.Add(callback);
		}

		public static void OnItemMirrored(ItemMirroredHandler callback)
		{
			GemStones.ItemMirroredHandlers.Add(callback);
		}

		public static bool IsJewelryEquipped(Player player, string prefabName)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName);
			if (((Humanoid)player).m_visEquipment.m_currentUtilityItemHash == stableHashCode)
			{
				return true;
			}
			Visual value;
			return Visual.visuals.TryGetValue(((Humanoid)player).m_visEquipment, out value) && (value.currentFingerItemHash == stableHashCode || value.currentNeckItemHash == stableHashCode);
		}

		public static Visual? GetEquippedJewelry(Player player)
		{
			Visual.visuals.TryGetValue(((Humanoid)player).m_visEquipment, out Visual value);
			return value;
		}

		public static bool BlacklistItem(GameObject item)
		{
			Jewelcrafting.PrefabBlacklist.Add(((Object)item).name);
			return true;
		}

		public static Transform? GetJewelcraftingTooltipRoot(GameObject tooltip)
		{
			return tooltip.transform.Find("Bkg (1)");
		}

		public static bool FillItemContainerTooltip(ItemData? item, Transform root, bool showInteract)
		{
			GemStones.FillItemTooltip(item, root, showInteract);
			return true;
		}

		public static Color? GetSocketableItemColor(ItemData item)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Sockets sockets = item.Data().Get<Sockets>();
			if (sockets != null)
			{
				return SocketsBackground.ItemColor(sockets);
			}
			return null;
		}

		public static Inventory? GetItemContainerInventory(ItemData item)
		{
			ItemInfo info = item.Data();
			ItemContainer container = info.Get<ItemContainer>();
			if (container != null)
			{
				if (GemStones.AddFakeSocketsContainer.openEquipment == info)
				{
					return GemStones.AddFakeSocketsContainer.openInventory;
				}
				Inventory inv = container.ReadInventory();
				Inventory obj = inv;
				obj.m_onChanged = (Action)Delegate.Combine(obj.m_onChanged, (Action)delegate
				{
					container.SaveSocketsInventory(inv);
					info.Save();
				});
				return inv;
			}
			return null;
		}

		public static bool IsFreelyAccessibleInventory(ItemData item)
		{
			ItemContainer itemContainer = item.Data().Get<ItemContainer>();
			if (itemContainer != null)
			{
				return itemContainer is ItemBag;
			}
			return false;
		}
	}
	[AttributeUsage(AttributeTargets.Field)]
	public abstract class PowerAttribute : Attribute
	{
		public abstract float Add(float a, float b);

		public abstract float Multiply(float a, float b);
	}
	public class AdditivePowerAttribute : PowerAttribute
	{
		public override float Add(float a, float b)
		{
			return a + b;
		}

		public override float Multiply(float a, float b)
		{
			return a * b;
		}
	}
	public class MultiplicativePercentagePowerAttribute : PowerAttribute
	{
		public override float Add(float a, float b)
		{
			return ((1f + a / 100f) * (1f + b / 100f) - 1f) * 100f;
		}

		public override float Multiply(float a, float b)
		{
			return a * b;
		}
	}
	public class InverseMultiplicativePercentagePowerAttribute : PowerAttribute
	{
		public override float Add(float a, float b)
		{
			return (1f - (1f - a / 100f) * (1f - b / 100f)) * 100f;
		}

		public override float Multiply(float a, float b)
		{
			return (a != 0f && b != 0f) ? ((1f - 1f / ((1f / (1f - a / 100f) - 1f) * b + 1f)) * 100f) : 0f;
		}
	}
	public class MinPowerAttribute : PowerAttribute
	{
		public override float Add(float a, float b)
		{
			return Mathf.Min(a, b);
		}

		public override float Multiply(float a, float b)
		{
			return a / b;
		}
	}
	public class MaxPowerAttribute : PowerAttribute
	{
		public override float Add(float a, float b)
		{
			return Mathf.Max(a, b);
		}

		public override float Multiply(float a, float b)
		{
			return a * b;
		}
	}
	[AttributeUsage(AttributeTargets.Field)]
	public class OptionalPowerAttribute : Attribute
	{
		public readonly float DefaultValue;

		public OptionalPowerAttribute(float defaultValue)
		{
			DefaultValue = defaultValue;
			base..ctor();
		}
	}
	[PublicAPI]
	public class Visual
	{
		[HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")]
		private static class ApplyStatusEffects
		{
			private static MethodInfo EffectCollector = AccessTools.DeclaredMethod(typeof(ApplyStatusEffects), "CollectEffects", (Type[])null, (Type[])null);

			private static void CollectEffects(Humanoid humanoid, HashSet<StatusEffect?> statusEffects)
			{
				Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
				if (val != null && visuals.TryGetValue(((Humanoid)val).m_visEquipment, out Visual value))
				{
					StatusEffect val2 = value.equippedFingerItem?.m_shared.m_equipStatusEffect;
					if (val2 != null)
					{
						statusEffects.Add(val2);
					}
					if (humanoid.HaveSetEffect(value.equippedFingerItem))
					{
						statusEffects.Add(value.equippedFingerItem.m_shared.m_equipStatusEffect);
					}
					StatusEffect val3 = value.equippedNeckItem?.m_shared.m_equipStatusEffect;
					if (val3 != null)
					{
						statusEffects.Add(val3);
					}
					if (humanoid.HaveSetEffect(value.equippedNeckItem))
					{
						statusEffects.Add(value.equippedNeckItem.m_shared.m_equipStatusEffect);
					}
				}
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructionsEnumerable)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Expected O, but got Unknown
				List<CodeInstruction> list = instructionsEnumerable.ToList();
				list.InsertRange(2, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Call, (object)EffectCollector)
				}));
				return list;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "GetSetCount")]
		private static class IncreaseSetCount
		{
			private static void Postfix(Humanoid __instance, string setName, ref int __result)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && visuals.TryGetValue(((Humanoid)val).m_visEquipment, out Visual value))
				{
					if (value.equippedFingerItem?.m_shared.m_name == setName)
					{
						__result++;
					}
					if (value.equippedNeckItem?.m_shared.m_name == setName)
					{
						__result++;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "IsItemEquiped")]
		private static class IsItemEquiped
		{
			private static void Postfix(Humanoid __instance, ItemData item, ref bool __result)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && visuals.TryGetValue(((Humanoid)val).m_visEquipment, out Visual value) && (value.equippedFingerItem == item || value.equippedNeckItem == item))
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Awake")]
		private static class AddVisual
		{
			[HarmonyPriority(800)]
			private static void Prefix(Player __instance)
			{
				visuals.Add(((Component)__instance).GetComponent<VisEquipment>(), new Visual(((Component)__instance).GetComponent<VisEquipment>()));
			}
		}

		[HarmonyPatch(typeof(VisEquipment), "OnEnable")]
		private static class AddVisualOnEnable
		{
			private static void Postfix(VisEquipment __instance)
			{
				if (!visuals.ContainsKey(__instance) && __instance.m_isPlayer)
				{
					visuals[__instance] = new Visual(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(VisEquipment), "OnDisable")]
		private static class RemoveVisualOnDisable
		{
			private static void Postfix(VisEquipment __instance)
			{
				visuals.Remove(__instance);
			}
		}

		[HarmonyPatch(typeof(Humanoid), "SetupVisEquipment")]
		private static class SetupVisEquipment
		{
			private static void Prefix(Humanoid __instance)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && visuals.TryGetValue(((Humanoid)val).m_visEquipment, out Visual value))
				{
					value.setFingerItem((value.equippedFingerItem == null) ? "" : ((Object)value.equippedFingerItem.m_dropPrefab).name);
					value.setNeckItem((value.equippedNeckItem == null) ? "" : ((Object)value.equippedNeckItem.m_dropPrefab).name);
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipAllItems")]
		private static class UnequipAllItems
		{
			private static void Prefix(Humanoid __instance)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					((Humanoid)val).UnequipItem(visuals[((Humanoid)val).m_visEquipment].equippedFingerItem, false);
					((Humanoid)val).UnequipItem(visuals[((Humanoid)val).m_visEquipment].equippedNeckItem, false);
				}
			}
		}

		[HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")]
		private static class UpdateEquipmentVisuals
		{
			private static void Postfix(VisEquipment __instance)
			{
				if (__instance.m_isPlayer)
				{
					visuals[__instance].updateEquipmentVisuals();
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		private static class EquipItem
		{
			private static bool Equip(Humanoid humanoid, ItemData item, bool triggerEquipmentEffects)
			{
				Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
				if (val != null)
				{
					if (IsFingerItem(item))
					{
						((Humanoid)val).UnequipItem(visuals[((Humanoid)val).m_visEquipment].equippedFingerItem, triggerEquipmentEffects);
						visuals[((Humanoid)val).m_visEquipment].equippedFingerItem = item;
						return true;
					}
					if (IsNeckItem(item))
					{
						((Humanoid)val).UnequipItem(visuals[((Humanoid)val).m_visEquipment].equippedNeckItem, triggerEquipmentEffects);
						visuals[((Humanoid)val).m_visEquipment].equippedNeckItem = item;
						return true;
					}
				}
				return false;
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructionEnumerable)
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Expected O, but got Unknown
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Expected O, but got Unknown
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Expected O, but got Unknown
				List<CodeInstruction> list = instructionEnumerable.ToList();
				int num = list.FindLastIndex((CodeInstruction instruction) => CodeInstructionExtensions.LoadsConstant(instruction, (Enum)(object)(ItemType)18));
				Label? label = default(Label?);
				do
				{
					num++;
				}
				while (!CodeInstructionExtensions.Branches(list[num], ref label));
				list.InsertRange(num + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[5]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldarg_1, (object)null),
					new CodeInstruction(OpCodes.Ldarg_2, (object)null),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(EquipItem), "Equip", (Type[])null, (Type[])null)),
					new CodeInstruction(OpCodes.Brtrue, (object)label.Value)
				});
				return list;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
		private static class UnequipItem
		{
			private static void Unequip(Humanoid humanoid, ItemData item)
			{
				Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
				if (val != null)
				{
					if (visuals[((Humanoid)val).m_visEquipment].equippedFingerItem == item)
					{
						visuals[((Humanoid)val).m_visEquipment].equippedFingerItem = null;
					}
					if (visuals[((Humanoid)val).m_visEquipment].equippedNeckItem == item)
					{
						visuals[((Humanoid)val).m_visEquipment].equippedNeckItem = null;
					}
				}
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructionEnumerable)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Expected O, but got Unknown
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Expected O, but got Unknown
				MethodInfo setupEquipment = AccessTools.DeclaredMethod(typeof(Humanoid), "SetupEquipment", (Type[])null, (Type[])null);
				List<CodeInstruction> list = instructionEnumerable.ToList();
				int num = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.Calls(instruction, setupEquipment));
				list.InsertRange(num - 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldarg_1, (object)null),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(UnequipItem), "Unequip", (Type[])null, (Type[])null))
				});
				return list;
			}
		}

		private readonly VisEquipment visEquipment;

		public ItemData? equippedFingerItem;

		public ItemData? equippedNeckItem;

		public int currentFingerItemHash;

		public int currentNeckItemHash;

		public static readonly Dictionary<VisEquipment, Visual> visuals = new Dictionary<VisEquipment, Visual>();

		private string fingerItem = "";

		private string neckItem = "";

		private List<GameObject> fingerItemInstances = new List<GameObject>();

		private List<GameObject> neckItemInstances = new List<GameObject>();

		private Visual(VisEquipment visEquipment)
		{
			this.visEquipment = visEquipment;
		}

		private static bool IsFingerItem(ItemData item)
		{
			if (Jewelcrafting.ringSlot.Value == Jewelcrafting.Toggle.Off)
			{
				return false;
			}
			string name = item.m_shared.m_name;
			return Utils.CustomStartsWith(name, "$jc_ring_");
		}

		private static bool IsNeckItem(ItemData item)
		{
			if (Jewelcrafting.necklaceSlot.Value == Jewelcrafting.Toggle.Off)
			{
				return false;
			}
			string name = item.m_shared.m_name;
			return Utils.CustomStartsWith(name, "$jc_necklace_");
		}

		private int getHash(string zdoKey, string equippedItem)
		{
			ZDO zDO = visEquipment.m_nview.GetZDO();
			if (zDO != null)
			{
				return zDO.GetInt(zdoKey, 0);
			}
			return (!string.IsNullOrEmpty(equippedItem)) ? StringExtensionMethods.GetStableHashCode(equippedItem) : 0;
		}

		private void updateEquipmentVisuals()
		{
			if (setFingerEquipped(getHash("FingerItem", fingerItem)) || setNeckEquipped(getHash("NeckItem", neckItem)))
			{
				visEquipment.UpdateLodgroup();
			}
		}

		private bool setNeckEquipped(int hash)
		{
			if (currentNeckItemHash == hash)
			{
				return false;
			}
			foreach (GameObject neckItemInstance in neckItemInstances)
			{
				Object.Destroy((Object)(object)neckItemInstance);
			}
			neckItemInstances.Clear();
			currentNeckItemHash = hash;
			if (hash != 0)
			{
				neckItemInstances = visEquipment.AttachArmor(hash, -1);
			}
			return true;
		}

		private void setNeckItem(string name)
		{
			if (!(neckItem == name))
			{
				neckItem = name;
				ZDO zDO = visEquipment.m_nview.GetZDO();
				if (zDO != null && visEquipment.m_nview.IsOwner())
				{
					zDO.Set("NeckItem", (!string.IsNullOrEmpty(name)) ? StringExtensionMethods.GetStableHashCode(name) : 0);
				}
			}
		}

		private bool setFingerEquipped(int hash)
		{
			if (currentFingerItemHash == hash)
			{
				return false;
			}
			foreach (GameObject fingerItemInstance in fingerItemInstances)
			{
				Object.Destroy((Object)(object)fingerItemInstance);
			}
			fingerItemInstances.Clear();
			currentFingerItemHash = hash;
			if (hash != 0)
			{
				fingerItemInstances = visEquipment.AttachArmor(hash, -1);
			}
			return true;
		}

		private void setFingerItem(string name)
		{
			if (!(fingerItem == name))
			{
				fingerItem = name;
				ZDO zDO = visEquipment.m_nview.GetZDO();
				if (zDO != null && visEquipment.m_nview.IsOwner())
				{
					zDO.Set("FingerItem", (!string.IsNullOrEmpty(name)) ? StringExtensionMethods.GetStableHashCode(name) : 0);
				}
			}
		}

		public static void HandleSettingChanged(ConfigEntry<Jewelcrafting.Toggle> setting)
		{
			ConfigEntry<Jewelcrafting.Toggle> setting2 = setting;
			if (!AzuExtendedPlayerInventory.API.IsLoaded())
			{
				return;
			}
			if (setting2 == Jewelcrafting.necklaceSlot)
			{
				Handle("Neck", IsNeckItem, (Visual v) => v.equippedNeckItem);
			}
			else if (setting2 == Jewelcrafting.ringSlot)
			{
				Handle("Finger", IsFingerItem, (Visual v) => v.equippedFingerItem);
			}
			void Handle(string name, Func<ItemData, bool> isValid, Func<Visual, ItemData?> get)
			{
				string name2 = name;
				Func<Visual, ItemData?> get2 = get;
				if (setting2.Value == Jewelcrafting.Toggle.On)
				{
					int num = AzuExtendedPlayerInventory.API.GetSlots().SlotNames.ToList().FindIndex((string slot) => slot == ((name2 == "Neck") ? "Finger" : "Neck"));
					AzuExtendedPlayerInventory.API.AddSlot(name2, (Player player) => visuals.TryGetValue(((Humanoid)player).m_visEquipment, out Visual value) ? get2(value) : null, isValid, (num < 0) ? (-1) : ((name2 == "Neck") ? num : (num + 1)));
				}
				else
				{
					AzuExtendedPlayerInventory.API.RemoveSlot(name2);
				}
			}
		}
	}
	[Flags]
	public enum VisualEffectCondition : uint
	{
		IsSkill = 0xFFFu,
		Swords = 1u,
		Knives = 2u,
		Clubs = 3u,
		Polearms = 4u,
		Spears = 5u,
		Blocking = 6u,
		Axes = 7u,
		Bows = 8u,
		Unarmed = 0xBu,
		Pickaxes = 0xCu,
		WoodCutting = 0xDu,
		Crossbows = 0xEu,
		IsItem = 0xFF000u,
		Helmet = 0x6000u,
		Chest = 0x7000u,
		Legs = 0xB000u,
		Hands = 0xC000u,
		Shoulder = 0x11000u,
		Tool = 0x13000u,
		GenericExtraAttributes = 0xFF000000u,
		Blackmetal = 0x40000000u,
		TwoHanded = 0x80000000u,
		SpecificExtraAttributes = 0xF00000u,
		Hammer = 0x113000u,
		Hoe = 0x213000u,
		Buckler = 0x100006u,
		Towershield = 0x200006u,
		FineWoodBow = 0x100008u,
		BowHuntsman = 0x200008u,
		BowDraugrFang = 0x300008u,
		PickaxeIron = 0x10000Cu,
		Club = 0x100003u
	}
	[BepInPlugin("org.bepinex.plugins.jewelcrafting", "Jewelcrafting", "2.0.1")]
	[BepInIncompatibility("randyknapp.mods.epicloot")]
	[BepInIncompatibility("org.bepinex.plugins.valheim_plus")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Jewelcrafting : BaseUnityPlugin
	{
		public class LootConfigs
		{
			public ConfigEntry<float> lootSkew = null;

			public ConfigEntry<float> lootLowHpChance = null;

			public ConfigEntry<float> lootDefaultChance = null;

			public ConfigEntry<LootRestriction> lootRestriction = null;

			public ConfigEntry<Toggle> unsocketDroppedItems = null;

			public ConfigEntry<Toggle> addSocketToDroppedItem = null;
		}

		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		public enum UniqueDrop
		{
			Disabled,
			TrulyUnique,
			Custom,
			GuaranteedFirst
		}

		public enum Unsocketing
		{
			Disabled,
			UniquesOnly,
			All
		}

		public enum InteractBehaviour
		{
			Disabled,
			Hovering,
			Enabled
		}

		public enum AdvancedTooltipMode
		{
			General,
			Detailed
		}

		[Flags]
		public enum LootSystem
		{
			GemDrops = 1,
			EquipmentDrops = 2,
			GemChests = 4,
			EquipmentChests = 8
		}

		public enum LootRestriction
		{
			None,
			KnownStation,
			KnownRecipe
		}

		public enum SocketCost
		{
			ItemMayBreak,
			CostsItems,
			BreakOrCost,
			BreakAndCost
		}

		[PublicAPI]
		public class ConfigurationManagerAttributes
		{
			public int? Order;

			public bool? Browsable;

			public bool? HideSettingName;

			public bool? HideDefaultButton;

			public string? DispName;

			public Action<ConfigEntryBase>? CustomDrawer;
		}

		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		private static class FetchConfigManager
		{
			private static void Prefix()
			{
				Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
				configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class AddBossBoxProgressConfigs
		{
			private static void Postfix(ZNetScene __instance)
			{
				foreach (GameObject prefab in __instance.m_prefabs)
				{
					Character component = prefab.GetComponent<Character>();
					if (component != null && component.IsBoss() && !boxBossProgress.ContainsKey(component.m_name))
					{
						AddBossBoxProgressConfig(component.m_name, new float[3]);
					}
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		private static class FixupSocketTooltipFont
		{
			private static bool initialized;

			private static void Postfix(FejdStartup __instance)
			{
				if (initialized)
				{
					initialized = true;
					return;
				}
				Transform obj = ((Component)__instance).transform.Find("StartGame/Panel/JoinPanel/serverCount");
				TextMeshProUGUI val = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
				if (val != null)
				{
					TMP_Text[] componentsInChildren = GemStoneSetup.SocketTooltip.GetComponentsInChildren<TMP_Text>(true);
					foreach (TMP_Text val2 in componentsInChildren)
					{
						val2.font = ((TMP_Text)val).font;
						val2.textWrappingMode = (TextWrappingModes)1;
					}
				}
				english.SetupLanguage("English");
			}
		}

		[HarmonyPatch(typeof(ZRoutedRpc), "AddPeer")]
		private static class AddRPCs
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Method <0>__RPC_GenerateVegetation;
			}

			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static Method <>9__0_0;

				internal void <Postfix>b__0_0(ZRpc _)
				{
					BossSpawn.SpawnBoss();
				}
			}

			private static void Postfix(ZNetPeer peer)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Expected O, but got Unknown
				if (!ZNet.instance.IsServer())
				{
					return;
				}
				ZRpc rpc = peer.m_rpc;
				object obj = <>O.<0>__RPC_GenerateVegetation;
				if (obj == null)
				{
					Method val = GenerateVegetationSpawners.RPC_GenerateVegetation;
					<>O.<0>__RPC_GenerateVegetation = val;
					obj = (object)val;
				}
				rpc.Register("Jewelcrafting GenerateVegetation", (Method)obj);
				ZRpc rpc2 = peer.m_rpc;
				object obj2 = <>c.<>9__0_0;
				if (obj2 == null)
				{
					Method val2 = delegate
					{
						BossSpawn.SpawnBoss();
					};
					<>c.<>9__0_0 = val2;
					obj2 = (object)val2;
				}
				rpc2.Register("Jewelcrafting SpawnBoss", (Method)obj2);
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class AddStatusEffects
		{
			private static void Prefix(ObjectDB __instance)
			{
				__instance.m_StatusEffects.Add((StatusEffect)(object)GemEffectSetup.headhunter);
				__instance.m_StatusEffects.Add((StatusEffect)(object)GemEffectSetup.fireBossDebuff);
				__instance.m_StatusEffects.Add((StatusEffect)(object)GemEffectSetup.frostBossDebuff);
				__instance.m_StatusEffects.Add((StatusEffect)(object)GemEffectSetup.poisonBossDebuff);
			}

			private static void Postfix()
			{
				ToggleFeatherFall(null, null);
				ToggleWindRun(null, null);
			}
		}

		[HarmonyPatch(typeof(ItemStand), "CanAttach")]
		private static class MakeGemsAttachableToItemStand
		{
			private static bool CanAttachGem(ItemStand itemStand, ItemData item)
			{
				return itemStand.m_supportedTypes.Contains((ItemType)16) && Utils.ItemAllowedInGemBag(item);
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructionsEnumerable)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				List<CodeInstruction> list = instructionsEnumerable.ToList();
				list.InsertRange(list.Count - 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[4]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldarg_1, (object)null),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(MakeGemsAttachableToItemStand), "CanAttachGem", (Type[])null, (Type[])null)),
					new CodeInstruction(OpCodes.Or, (object)null)
				});
				return list;
			}
		}

		[HarmonyPatch(typeof(Player), "ToggleEquipped")]
		private static class ErrorOnGemEquip
		{
			private static void Postfix(Player __instance, ItemData item)
			{
				if (!item.IsEquipable() && GemStones.socketableGemStones.Contains(item.m_shared.m_name))
				{
					((Character)__instance).Message((MessageType)2, "$jc_cannot_equip_gem", 0, (Sprite)null);
				}
			}
		}

		private const int WindowId = -669;

		private Rect yamlWindowRect;

		private Dictionary<string, string> currentYamlInput = null;

		private readonly Dictionary<string, bool> collapsed = new Dictionary<string, bool>();

		private readonly Dictionary<string, Vector2> yamlTextareaScrollPosition = new Dictionary<string, Vector2>();

		private Vector2 yamlErrorsScrollPosition;

		private bool hasErrors = false;

		private CustomSyncedValue<List<string>>? activeConfigFileData = null;

		private Func<object?, List<string>> configChecker = null;

		public const string ModName = "Jewelcrafting";

		private const string ModVersion = "2.0.1";

		private const string ModGUID = "org.bepinex.plugins.jewelcrafting";

		public static readonly ConfigSync configSync = new ConfigSync("Jewelcrafting")
		{
			DisplayName = "Jewelcrafting",
			CurrentVersion = "2.0.1",
			MinimumRequiredVersion = "2.0.1"
		};

		private static ConfigEntry<Toggle> serverConfigLocked = null;

		public static SyncedConfigEntry<Toggle> useExternalYaml = null;

		public static ConfigEntry<Toggle> inventorySocketing = null;

		public static ConfigEntry<Toggle> displayGemcursor = null;

		public static ConfigEntry<Toggle> displaySocketBackground = null;

		public static ConfigEntry<Toggle> colorItemName = null;

		public static ConfigEntry<Unsocketing> allowUnsocketing = null;

		public static ConfigEntry<InteractBehaviour> inventoryInteractBehaviour = null;

		public static ConfigEntry<float> breakChanceUnsocketSimple = null;

		public static ConfigEntry<float> breakChanceUnsocketAdvanced = null;

		public static ConfigEntry<float> breakChanceUnsocketPerfect = null;

		public static ConfigEntry<float> breakChanceUnsocketMerged = null;

		public static ConfigEntry<Toggle> socketingItemsExperience = null;

		public static ConfigEntry<Toggle> visualEffects = null;

		public static ConfigEntry<UniqueDrop> uniqueGemDropSystem = null;

		public static ConfigEntry<int> uniqueGemDropChance = null;

		public static ConfigEntry<Toggle> uniqueGemDropOnePerPlayer = null;

		public static ConfigEntry<int> uniqueGemDropChanceIncreasePerWorldLevel = null;

		public static ConfigEntry<int> resourceReturnRate = null;

		public static ConfigEntry<int> resourceReturnRateUpgrade = null;

		public static ConfigEntry<int> resourceReturnRateDistance = null;

		public static ConfigEntry<Toggle> badLuckRecipes = null;

		public static readonly ConfigEntry<int>[] crystalFusionBoxDropRate = new ConfigEntry<int>[FusionBoxSetup.Boxes.Length];

		public static readonly ConfigEntry<float>[] crystalFusionBoxMergeActivityProgress = new ConfigEntry<float>[FusionBoxSetup.Boxes.Length];

		public static ConfigEntry<int> maximumNumberSockets = null;

		public static ConfigEntry<Toggle> limitSocketsByTableLevel = null;

		public static readonly ConfigEntry<int>[] maxSocketsTableLevel = new ConfigEntry<int>[4];

		public static ConfigEntry<int> gemRespawnRate = null;

		public static ConfigEntry<int> upgradeChanceIncrease = null;

		public static ConfigEntry<Toggle> additiveSkillBonus = null;

		public static ConfigEntry<int> awarenessRange = null;

		private static ConfigEntry<int> rigidDamageReduction = null;

		private static ConfigEntry<uint> headhunterDuration = null;

		private static ConfigEntry<int> headhunterDamage = null;

		private static ConfigEntry<float> experienceGainedFactor = null;

		private static ConfigEntry<int> experienceLoss = null;

		private static ConfigEntry<int> warmthStaminaRegen = null;

		public static ConfigEntry<int> magicRepairAmount = null;

		private static ConfigEntry<int> aquaticDamageIncrease = null;

		public static ConfigEntry<int> modersBlessingDuration = null;

		public static ConfigEntry<int> modersBlessingCooldown = null;

		public static ConfigEntry<int> guidanceCooldown = null;

		public static ConfigEntry<int> legacyCooldown = null;

		public static ConfigEntry<int> gemBagSlotsRows = null;

		public static ConfigEntry<int> gemBagSlotsColumns = null;

		public static ConfigEntry<Toggle> gemBagAutofill = null;

		public static ConfigEntry<int> gemBoxSlotsRows = null;

		public static ConfigEntry<int> gemBoxSlotsColumns = null;

		public static ConfigEntry<KeyboardShortcut> advancedTooltipKey = null;

		public static ConfigEntry<AdvancedTooltipMode> advancedTooltipMode = null;

		public static ConfigEntry<Toggle> advancedTooltipAlwaysOn = null;

		public static ConfigEntry<Toggle> gachaLocationIcon = null;

		public static ConfigEntry<Toggle> gachaLocationActive = null;

		public static ConfigEntry<int> bossSpawnTimer = null;

		public static ConfigEntry<int> bossSpawnMinDistance = null;

		public static ConfigEntry<int> bossSpawnMaxDistance = null;

		public static ConfigEntry<int> bossSpawnBaseDistance = null;

		public static ConfigEntry<int> bossTimeLimit = null;

		public static ConfigEntry<int> bossCoinDrop = null;

		public static ConfigEntry<float> eventBossSpawnChance = null;

		private static ConfigEntry<GachaSetup.BalanceToggle> worldBossBalance = null;

		private static ConfigEntry<float> worldBossHealth = null;

		private static ConfigEntry<float> worldBossPunchDamage = null;

		private static ConfigEntry<float> worldBossSmashDamage = null;

		private static ConfigEntry<float> worldBossFireDamage = null;

		private static ConfigEntry<float> worldBossFrostDamage = null;

		private static ConfigEntry<float> worldBossPoisonDamage = null;

		public static ConfigEntry<int> worldBossBonusWeaponDamage = null;

		public static ConfigEntry<int> worldBossBonusBlockPower = null;

		public static ConfigEntry<int> worldBossCountdownDisplayOffset = null;

		public static ConfigEntry<Toggle> worldBossExploitProtectionHeal = null;

		public static ConfigEntry<Toggle> worldBossExploitProtectionRangedShield = null;

		public static ConfigEntry<float> defaultEventDuration = null;

		public static ConfigEntry<int> frameOfChanceChance = null;

		public static ConfigEntry<Toggle> mirrorMirrorImages = null;

		public static ConfigEntry<Toggle> unsocketMirrorImages = null;

		public static ConfigEntry<string> socketBlacklist = null;

		public static ConfigEntry<string> mirrorBlacklist = null;

		public static ConfigEntry<Toggle> gemstoneFormationParticles = null;

		public static ConfigEntry<Toggle> wisplightGem = null;

		public static ConfigEntry<Toggle> wishboneGem = null;

		public static ConfigEntry<LootSystem> lootSystem = null;

		public static ConfigEntry<Toggle> lootBeams = null;

		public static readonly Dictionary<LootSystem, LootConfigs> lootConfigs = new Dictionary<LootSystem, LootConfigs>();

		public static ConfigEntry<int> gemChestMinGems = null;

		public static ConfigEntry<int> gemChestMaxGems = null;

		public static ConfigEntry<int> gemChestAllowedAmount = null;

		public static ConfigEntry<int> equipmentChestMinItems = null;

		public static ConfigEntry<int> equipmentChestMaxItems = null;

		public static ConfigEntry<int> equipmentChestAllowedAmount = null;

		public static ConfigEntry<Toggle> gemstoneFormations = null;

		public static ConfigEntry<float> gemstoneFormationHealth = null;

		public static ConfigEntry<Toggle> featherGliding = null;

		public static ConfigEntry<int> featherGlidingBuff = null;

		public static ConfigEntry<Toggle> asksvinRunning = null;

		public static ConfigEntry<int> asksvinRunningBuff = null;

		public static ConfigEntry<Toggle> ringSlot = null;

		public static ConfigEntry<Toggle> necklaceSlot = null;

		public static ConfigEntry<Toggle> splitSockets = null;

		public static ConfigEntry<SocketCost> socketCost = null;

		public static ConfigEntry<Toggle> pixelateTextures = null;

		public static ConfigEntry<float> divinityOrbGlobalDropChance = null;

		public static ConfigEntry<float> corruptionOrbGlobalDropChance = null;

		public static ConfigEntry<float> whimsicalOrbGlobalDropChance = null;

		public static ConfigEntry<float> prophecyOrbGlobalDropChance = null;

		public static ConfigEntry<float> finalityOrbGlobalDropChance = null;

		public static ConfigEntry<int> divinityOrbDropChance = null;

		public static ConfigEntry<float> corruptionOrbDropChance = null;

		public static ConfigEntry<int> whimsicalOrbDroprate = null;

		public static ConfigEntry<float> finalityOrbDropMultiplier = null;

		public static ConfigEntry<int> finalityOrbRerollAmount = null;

		public static ConfigEntry<float> misfortuneOrbDropChance = null;

		public static ConfigEntry<float> chanceFrameOrbGlobalDropChance = null;

		public static ConfigEntry<float> chaosFrameOrbGlobalDropChance = null;

		public static ConfigEntry<Toggle> randomPowerRanges = null;

		public static ConfigEntry<float> gemPowerMultiplier = null;

		public static ConfigEntry<Toggle> vanillaGemCrafting = null;

		public static ConfigEntry<float> bigGemstoneFormationChance = null;

		public static ConfigEntry<int> effectPowerStandardDeviation = null;

		public static ConfigEntry<Toggle> gemReturnLockedGems = null;

		public static ConfigEntry<Toggle> disableUniqueGemsInBase = null;

		public static ConfigEntry<Toggle> gemDropBiomeDistribution = null;

		public static ConfigEntry<Toggle> glidingFallDamagePrevention = null;

		public static ConfigEntry<Toggle> gemCaveLocationIcon = null;

		public static ConfigEntry<Toggle> daringAffectsBosses = null;

		public static ConfigEntry<Toggle> socketingTab = null;

		public static readonly Dictionary<int, ConfigEntry<int>> socketAddingChances = new Dictionary<int, ConfigEntry<int>>();

		public static readonly Dictionary<GameObject, ConfigEntry<float>> gemDropChances = new Dictionary<GameObject, ConfigEntry<float>>();

		public static readonly CustomSyncedValue<List<string>> socketEffectDefinitions = new CustomSyncedValue<List<string>>(configSync, "socket effects", new List<string>());

		private readonly Dictionary<string, int[]> defaultBoxMergeChances = new Dictionary<string, int[]>
		{
			{
				"$jc_common_gembox",
				new int[3] { 90, 40, 10 }
			},
			{
				"$jc_epic_gembox",
				new int[3] { 100, 70, 35 }
			},
			{
				"$jc_legendary_gembox",
				new int[3] { 100, 90, 65 }
			}
		};

		private readonly Dictionary<string, float[]> defaultBoxBossProgress = new Dictionary<string, float[]>
		{
			{
				"$enemy_eikthyr",
				new float[3] { 12f, 0.5f, 0f }
			},
			{
				"$enemy_gdking",
				new float[3] { 15f, 2f, 0.5f }
			},
			{
				"$enemy_bonemass",
				new float[3] { 20f, 4f, 1.5f }
			},
			{
				"$enemy_dragon",
				new float[3] { 28f, 12f, 3f }
			},
			{
				"$enemy_goblinking",
				new float[3] { 40f, 20f, 6f }
			},
			{
				"$enemy_seekerqueen",
				new float[3] { 55f, 30f, 9f }
			},
			{
				"$jc_crystal_frost_reaper",
				new float[3] { 57f, 31f, 10f }
			},
			{
				"$jc_crystal_flame_reaper",
				new float[3] { 57f, 31f, 10f }
			},
			{
				"$jc_crystal_soul_reaper",
				new float[3] { 57f, 31f, 10f }
			},
			{
				"$enemy_fader",
				new float[3] { 60f, 33f, 11f }
			}
		};

		public static readonly Dictionary<string, ConfigEntry<float>> gemUpgradeChances = new Dictionary<string, ConfigEntry<float>>();

		public static readonly Dictionary<string, ConfigEntry<int>[]> boxMergeChances = new Dictionary<string, ConfigEntry<int>[]>();

		public static readonly Dictionary<string, ConfigEntry<int>> boxSelfMergeChances = new Dictionary<string, ConfigEntry<int>>();

		public static readonly Dictionary<string, ConfigEntry<float>[]> boxBossProgress = new Dictionary<string, ConfigEntry<float>[]>();

		public static ConfigEntry<int> boxBossGemMergeChance = null;

		public static Dictionary<Effect, List<EffectDef>> SocketEffects = new Dictionary<Effect, List<EffectDef>>();

		public static readonly Dictionary<int, Dictionary<GemLocation, List<EffectPower>>> EffectPowers = new Dictionary<int, Dictionary<GemLocation, List<EffectPower>>>();

		public static readonly HashSet<GemType> GemsUsingPowerRanges = new HashSet<GemType>();

		public static Dictionary<Biome, Dictionary<GemType, float>> GemDistribution = new Dictionary<Biome, Dictionary<GemType, float>>();

		public static List<string> configFilePaths = null;

		public static readonly List<SynergyDef> Synergies = new List<SynergyDef>();

		public static readonly HashSet<string> PrefabBlacklist = new HashSet<string>();

		public const int maxNumberOfSockets = 10;

		public const int maxInternalNumberOfSockets = 11;

		private static Skill jewelcrafting = null;

		public static Jewelcrafting self = null;

		private static object? configManager;

		internal static Localization english = null;

		private AssetBundle assets = null;

		private void DrawYamlEditorButton(ConfigEntryBase _)
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			ConfigLoader.Loader[] loaders = ConfigLoader.loaders;
			foreach (ConfigLoader.Loader loader in loaders)
			{
				if (loader.FileData.Value.Count <= 0 || !GUILayout.Button(loader.EditButtonName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
				{
					continue;
				}
				activeConfigFileData = loader.FileData;
				configChecker = loader.ErrorCheck;
				currentYamlInput = (from g in activeConfigFileData.Value.Select((string f, int index) => new { f, index })
					group g by g.index / 2).ToDictionary(g => g.First().f, g => g.Last().f);
				foreach (string key in currentYamlInput.Keys)
				{
					if (!collapsed.ContainsKey(key))
					{
						collapsed[key] = collapsed.Count > 3;
						yamlTextareaScrollPosition[key] = default(Vector2);
					}
				}
			}
			GUILayout.EndVertical();
		}

		private void Update()
		{
			if (activeConfigFileData != null)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		private void LateUpdate()
		{
			Update();
		}

		private void OnGUI()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (activeConfigFileData != null)
			{
				Update();
				yamlWindowRect = new Rect(10f, 10f, (float)(Screen.width - 20), (float)(Screen.height - 20));
				GUILayout.Window(-669, yamlWindowRect, new WindowFunction(yamlWindowDrawer), "Jewelcrafting YAML Editor", Array.Empty<GUILayoutOption>());
			}
		}

		private void yamlWindowDrawer(int id)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Invalid comparison between Unknown and I4
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Expected O, but got Unknown
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Invalid comparison between Unknown and I4
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Expected O, but got Unknown
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Invalid comparison between Unknown and I4
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Invalid comparison between Unknown and I4
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Invalid comparison between Unknown and I4
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Invalid comparison between Unknown and I4
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			GUI.Box(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.blackTexture);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.enabled = !hasErrors && (!configSync.IsLocked || configSync.IsSourceOfTruth);
			if (GUILayout.Button(Localization.instance.Localize("$jc_config_editor_save"), Array.Empty<GUILayoutOption>()) && !hasErrors)
			{
				save();
				activeConfigFileData = null;
			}
			if (configSync.IsSourceOfTruth && GUILayout.Button(Localization.instance.Localize("$jc_config_editor_apply"), Array.Empty<GUILayoutOption>()) && !hasErrors)
			{
				ConfigLoader.SkipSavingOfValueChange = true;
				save();
				ConfigLoader.SkipSavingOfValueChange = false;
				activeConfigFileData = null;
			}
			GUI.enabled = true;
			if (GUILayout.Button(Localization.instance.Localize("$jc_config_editor_discard"), Array.Empty<GUILayoutOption>()))
			{
				activeConfigFileData = null;
			}
			GUILayout.EndHorizontal();
			hasErrors = false;
			string text = "";
			foreach (string item in currentYamlInput.Keys.ToList())
			{
				bool flag = GUI.GetNameOfFocusedControl() == "Jewelcrafting yaml textarea for " + item;
				bool flag2 = flag;
				if (flag2)
				{
					EventType type = Event.current.type;
					bool flag3 = type - 4 <= 1;
					flag2 = flag3;
				}
				if (flag2 && Event.current.isKey)
				{
					if ((int)Event.current.keyCode == 9 || Event.current.character == '\t')
					{
						if ((int)Event.current.type == 5)
						{
							TextEditor val = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
							val.Insert(' ');
							val.Insert(' ');
							currentYamlInput[item] = val.text;
						}
						Event.current.Use();
					}
					if ((int)Event.current.keyCode == 271 || (int)Event.current.keyCode == 13 || Event.current.character == '\n')
					{
						if ((int)Event.current.type == 5)
						{
							TextEditor val2 = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
							string text2 = val2.text;
							int num = val2.cursorIndex;
							if (num > 0)
							{
								while (text2[num - 1] != '\n' && --num > 0)
								{
								}
							}
							int num2 = num;
							if (num2 < text2.Length && text2[num2] == ' ')
							{
								while (true)
								{
									if (num2 >= text2.Length || text2[num2] == '\n')
									{
										num2 = num;
										break;
									}
									if (text2[num2] != ' ')
									{
										break;
									}
									num2++;
								}
							}
							if (num2 > val2.cursorIndex)
							{
								num2 = num;
							}
							val2.Insert('\n');
							for (int num3 = num2 - num; num3 > 0; num3--)
							{
								val2.Insert(' ');
							}
							currentYamlInput[item] = val2.text;
						}
						Event.current.Use();
					}
				}
				if (currentYamlInput.Count > 1)
				{
					GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
					if (GUILayout.Button(Path.GetFileName(item), new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)1,
						wordWrap = true,
						stretchWidth = true,
						fontSize = 15
					}, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
					{
						collapsed[item] = !collapsed[item];
					}
				}
				else
				{
					collapsed[item] = false;
				}
				if (!collapsed[item])
				{
					yamlTextareaScrollPosition[item] = GUILayout.BeginScrollView(yamlTextareaScrollPosition[item], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
					GUI.SetNextControlName("Jewelcrafting yaml textarea for " + item);
					currentYamlInput[item] = GUILayout.TextArea(currentYamlInput[item], (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.ExpandWidth(true),
						GUILayout.ExpandHeight(true)
					});
					GUILayout.EndScrollView();
				}
				if (currentYamlInput.Count > 1)
				{
					GUILayout.EndVertical();
				}
				try
				{
					object arg = new DeserializerBuilder().Build().Deserialize<object>(currentYamlInput[item]);
					List<string> list = configChecker(arg);
					if (list.Count > 0)
					{
						hasErrors = true;
						text = text + "There are errors in your " + Path.GetFileName(item) + " config:\n" + string.Join("\n", list) + "\n";
					}
				}
				catch (YamlException ex)
				{
					hasErrors = true;
					text = text + "The syntax of your " + Path.GetFileName(item) + " config is invalid, parsing failed:\n" + ex.Message + ((ex.InnerException != null) ? (": " + ex.InnerException.Message) : "") + "\n";
				}
			}
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			yamlErrorsScrollPosition = GUILayout.BeginScrollView(yamlErrorsScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(100f) });
			if (text != "")
			{
				GUIStyle val3 = new GUIStyle(GUI.skin.label);
				val3.normal.textColor = new Color(200f, 50f, 50f);
				GUIStyle val4 = val3;
				Color contentColor = GUI.contentColor;
				GUI.contentColor = new Color(200f, 50f, 50f);
				GUILayout.Label(text, val4, Array.Empty<GUILayoutOption>());
				GUI.contentColor = contentColor;
			}
			else
			{
				GUILayout.Label("Configuration syntax is valid.", Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			void save()
			{
				activeConfigFileData.Value = currentYamlInput.SelectMany<KeyValuePair<string, string>, string>((KeyValuePair<string, string> kv) => new string[2] { kv.Key, kv.Value }).ToList();
			}
		}

		public static ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = ((BaseUnityPlugin)self).Config.Bind<T>(group, name, value, description);
			SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val;
		}

		private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		private static void reloadConfigDisplay()
		{
			configManager?.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
		}

		public void Awake()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Expected O, but got Unknown
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Expected O, but got Unknown
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Expected O, but got Unknown
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Expected O, but got Unknown
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Expected O, but got Unknown
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Expected O, but got Unknown
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Expected O, but got Unknown
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Expected O, but got Unknown
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Expected O, but got Unknown
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_0721: Expected O, but got Unknown
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Expected O, but got Unknown
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Expected O, but got Unknown
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Expected O, but got Unknown
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Expected O, but got Unknown
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08db: Expected O, but got Unknown
			//IL_0925: Unknown result type (might be due to invalid IL or missing references)
			//IL_0930: Expected O, but got Unknown
			//IL_099d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a8: Expected O, but got Unknown
			//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a29: Expected O, but got Unknown
			//IL_0a84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Expected O, but got Unknown
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0add: Expected O, but got Unknown
			//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2f: Expected O, but got Unknown
			//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Expected O, but got Unknown
			//IL_0bd0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdb: Expected O, but got Unknown
			//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2f: Expected O, but got Unknown
			//IL_0c78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c83: Expected O, but got Unknown
			//IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd7: Expected O, but got Unknown
			//IL_0d20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2b: Expected O, but got Unknown
			//IL_0d6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d75: Expected O, but got Unknown
			//IL_0de2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ded: Expected O, but got Unknown
			//IL_0e5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e66: Expected O, but got Unknown
			//IL_0ee5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef0: Expected O, but got Unknown
			//IL_0f37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f42: Expected O, but got Unknown
			//IL_0f89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f94: Expected O, but got Unknown
			//IL_0fd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe3: Expected O, but got Unknown
			//IL_1027: Unknown result type (might be due to invalid IL or missing references)
			//IL_1032: Expected O, but got Unknown
			//IL_107c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1087: Expected O, but got Unknown
			//IL_10ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d5: Expected O, but got Unknown
			//IL_1125: Unknown result type (might be due to invalid IL or missing references)
			//IL_1130: Expected O, but got Unknown
			//IL_1175: Unknown result type (might be due to invalid IL or missing references)
			//IL_1180: Expected O, but got Unknown
			//IL_11c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d0: Expected O, but got Unknown
			//IL_1215: Unknown result type (might be due to invalid IL or missing references)
			//IL_1220: Expected O, but got Unknown
			//IL_1265: Unknown result type (might be due to invalid IL or missing references)
			//IL_1270: Expected O, but got Unknown
			//IL_12b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c0: Expected O, but got Unknown
			//IL_131b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1326: Expected O, but got Unknown
			//IL_136a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1375: Expected O, but got Unknown
			//IL_13b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c3: Expected O, but got Unknown
			//IL_1430: Unknown result type (might be due to invalid IL or missing references)
			//IL_143b: Expected O, but got Unknown
			//IL_147e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1489: Expected O, but got Unknown
			//IL_14d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_14db: Expected O, but got Unknown
			//IL_151e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1529: Expected O, but got Unknown
			//IL_156c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1577: Expected O, but got Unknown
			//IL_1639: Unknown result type (might be due to invalid IL or missing references)
			//IL_1644: Expected O, but got Unknown
			//IL_16a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_16b2: Expected O, but got Unknown
			//IL_1715: Unknown result type (might be due to invalid IL or missing references)
			//IL_1720: Expected O, but got Unknown
			//IL_1771: Unknown result type (might be due to invalid IL or missing references)
			//IL_177c: Expected O, but got Unknown
			//IL_18be: Unknown result type (might be due to invalid IL or missing references)
			//IL_18c9: Expected O, but got Unknown
			//IL_17f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_17fc: Expected O, but got Unknown
			//IL_1857: Unknown result type (might be due to invalid IL or missing references)
			//IL_1862: Expected O, but got Unknown
			//IL_193c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1947: Expected O, but got Unknown
			//IL_19ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_19c5: Expected O, but got Unknown
			//IL_1a0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a19: Expected O, but got Unknown
			//IL_1a8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a97: Expected O, but got Unknown
			//IL_1b0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b15: Expected O, but got Unknown
			//IL_1b58: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b63: Expected O, but got Unknown
			//IL_1bae: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bb9: Expected O, but got Unknown
			//IL_1bfc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c07: Expected O, but got Unknown
			//IL_1c5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c67: Expected O, but got Unknown
			//IL_1cc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cd3: Expected O, but got Unknown
			//IL_1d5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d66: Expected O, but got Unknown
			//IL_1dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1de4: Expected O, but got Unknown
			//IL_1e51: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e5c: Expected O, but got Unknown
			//IL_1ea5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1eb0: Expected O, but got Unknown
			//IL_1f23: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f2e: Expected O, but got Unknown
			//IL_1fa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fae: Expected O, but got Unknown
			//IL_1ff5: Unknown result type (might be due to invalid IL or missing references)
			//IL_2000: Expected O, but got Unknown
			//IL_2043: Unknown result type (might be due to invalid IL or missing references)
			//IL_204e: Expected O, but got Unknown
			//IL_2091: Unknown result type (might be due to invalid IL or missing references)
			//IL_209c: Expected O, but got Unknown
			//IL_20b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_20ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_20f8: Expected O, but got Unknown
			//IL_213b: Unknown result type (might be due to invalid IL or missing references)
			//IL_2146: Expected O, but got Unknown
			//IL_2189: Unknown result type (might be due to invalid IL or missing references)
			//IL_2194: Expected O, but got Unknown
			//IL_21d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_21e2: Expected O, but got Unknown
			//IL_224f: Unknown result type (might be due to invalid IL or missing references)
			//IL_225a: Expected O, but got Unknown
			//IL_22c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_22d2: Expected O, but got Unknown
			//IL_233f: Unknown result type (might be due to invalid IL or missing references)
			//IL_234a: Expected O, but got Unknown
			//IL_239f: Unknown result type (might be due to invalid IL or missing references)
			//IL_23aa: Expected O, but got Unknown
			//IL_23f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_23fc: Expected O, but got Unknown
			//IL_2469: Unknown result type (might be due to invalid IL or missing references)
			//IL_2474: Expected O, but got Unknown
			//IL_24de: Unknown result type (might be due to invalid IL or missing references)
			//IL_24e9: Expected O, but got Unknown
			//IL_252c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2537: Expected O, but got Unknown
			//IL_25a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_25ac: Expected O, but got Unknown
			//IL_25ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_25fa: Expected O, but got Unknown
			//IL_2672: Unknown result type (might be due to invalid IL or missing references)
			//IL_267d: Expected O, but got Unknown
			//IL_26f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_2700: Expected O, but got Unknown
			//IL_276d: Unknown result type (might be due to invalid IL or missing references)
			//IL_2778: Expected O, but got Unknown
			//IL_27cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_27d8: Expected O, but got Unknown
			//IL_2822: Unknown result type (might be due to invalid IL or missing references)
			//IL_282d: Expected O, but got Unknown
			//IL_2882: Unknown result type (might be due to invalid IL or missing references)
			//IL_288d: Expected O, but got Unknown
			//IL_28e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_28ed: Expected O, but got Unknown
			//IL_2937: Unknown result type (might be due to invalid IL or missing references)
			//IL_2942: Expected O, but got Unknown
			//IL_2997: Unknown result type (might be due to invalid IL or missing references)
			//IL_29a2: Expected O, but got Unknown
			//IL_29ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_29f7: Expected O, but got Unknown
			//IL_2a4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2a57: Expected O, but got Unknown
			//IL_2aac: Unknown result type (might be due to invalid IL or missing references)
			//IL_2ab7: Expected O, but got Unknown
			//IL_2b0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2b17: Expected O, but got Unknown
			//IL_2b6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2b77: Expected O, but got Unknown
			//IL_2bcc: Unknown result type (might be due to invalid IL or missing references)
			//IL_2bd7: Expected O, but got Unknown
			//IL_2c2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2c37: Expected O, but got Unknown
			//IL_2c7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_2c85: Expected O, but got Unknown
			//IL_2cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_2cfd: Expected O, but got Unknown
			//IL_2d40: Unknown result type (might be due to invalid IL or missing references)
			//IL_2d4b: Expected O, but got Unknown
			//IL_2d8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2d99: Expected O, but got Unknown
			//IL_2dbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_2dc7: Expected O, but got Unknown
			//IL_2dea: Unknown result type (might be due to invalid IL or missing references)
			//IL_2df5: Expected O, but got Unknown
			//IL_2e17: Unknown result type (might be due to invalid IL or missing references)
			//IL_2e22: Expected O, but got Unknown
			//IL_2e3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2e49: Expected O, but got Unknown
			//IL_2e6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2e77: Expected O, but got Unknown
			//IL_2e99: Unknown result type (might be due to invalid IL or missing references)
			//IL_2ea4: Expected O, but got Unknown
			//IL_2ec7: Unknown result type (might be due to invalid IL or missing references)
			//IL_2ed2: Expected O, but got Unknown
			//IL_2eee: Unknown result type (might be due to invalid IL or missing references)
			//IL_2ef9: Expected O, but got Unknown
			//IL_2f15: Unknown result type (might be due to invalid IL or missing references)
			//IL_2f20: Expected O, but got Unknown
			//IL_2f3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2f47: Expected O, but got Unknown
			//IL_2f63: Unknown result type (might be due to invalid IL or missing references)
			//IL_2f6e: Expected O, but got Unknown
			//IL_3173: Unknown result type (might be due to invalid IL or missing references)
			//IL_317e: Expected O, but got Unknown
			//IL_331e: Unknown result type (might be due to invalid IL or missing references)
			//IL_3329: Expected O, but got Unknown
			//IL_33bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_33c7: Expected O, but got Unknown
			//IL_3420: Unknown result type (might be due to invalid IL or missing references)
			//IL_3427: Expected O, but got Unknown
			self = this;
			configFilePaths = new List<string>(2)
			{
				Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath),
				Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
			};
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			Patcher.Patch();
			RuntimeHelpers.RunClassConstructor(typeof(Stats).TypeHandle);
			Localizer.Load();
			english = new Localization();
			english.SetupLanguage("English");
			assets = PrefabManager.RegisterAssetBundle("jewelcrafting");
			AssetBundle val = PrefabManager.RegisterAssetBundle("jc_ui_additions");
			CompendiumDisplay.initializeCompendiumDisplay(val);
			jewelcrafting = new Skill("Jewelcrafting", assets.LoadAsset<Sprite>("jewelcutting"));
			jewelcrafting.Name.Alias("jc_jewelcrafting_skill_name");
			jewelcrafting.Description.Alias("jc_jewelcrafting_skill_description");
			jewelcrafting.Configurable = false;
			serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			configSync.AddLockingConfigEntry<Toggle>(serverConfigLocked);
			int order = 0;
			config("2 - Socket System", "YAML Editor Anchor", 0, new ConfigDescription("Just ignore this.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					HideSettingName = true,
					HideDefaultButton = true,
					CustomDrawer = DrawYamlEditorButton
				}
			}), synchronizedSetting: false);
			inventorySocketing = config("2 - Socket System", "Inventory Socketing", Toggle.On, "If enabled, you can press the interact key to change gems in your items from your inventory. If disabled, you have to use the Gemcutters Table, to change the gems in your items.");
			socketingTab = config("2 - Socket System", "Socketing Tab", Toggle.On, new ConfigDescription("Can be used to disable the socketing tab on the gemcutter's table. Do not do this, if you don't know what you are doing.", (AcceptableValueBase)null, Array.Empty<object>()));
			socketCost = config("2 - Socket System", "Socket Cost", SocketCost.ItemMayBreak, "Item May Break: If adding a socket to the item fails, the item will be destroyed.\nCosts Items: Adding sockets to an item costs other items. Use the Jewelcrafting.SocketCosts.yml to configure this.\nBreak Or Cost: Successfully adding a socket spends the resources required for that socket. Failing to add a socket breaks the item.\nBreak And Cost: Successfully adding a socket spends the resources required for that socket. Failing to add a socket breaks the item and spends the resources.");
			effectPowerStandardDeviation = config("2 - Socket System", "Effect Power Deviation", 0, new ConfigDescription("Can be used to apply a standard deviation in percent to all gem effects. E.g. putting 30 here, will turn an effect power of 10 into 7 - 13. Use 0 to disable this.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 75), Array.Empty<object>()));
			effectPowerStandardDeviation.SettingChanged += delegate
			{
				ConfigLoader.TryReapplyConfig();
			};
			randomPowerRanges = config("2 - Socket System", "Random Power Ranges", Toggle.On, "If enabled, the effect powers for power ranges on gems are different for each effect on the gem.");
			gemPowerMultiplier = config("2 - Socket System", "Gem Power Multiplier", 1f, new ConfigDescription("This can be used to apply a multiplier to all gem effect powers. Please note that results may differ from your expectations. This is intended, since some gem powers are logarithmic.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			gemPowerMultiplier.SettingChanged += delegate
			{
				ConfigLoader.TryReapplyConfig();
			};
			inventoryInteractBehaviour = config("2 - Socket System", "Interact Behaviour", InteractBehaviour.Hovering, "Disabled: Interact key is disabled, while the inventory is open.\nHovering: Interact key is disabled, while hovering an item with at least one socket.\nEnabled: Interact key is enabled. You will have to use the Gemcutters Table, to socket your items.", synchronizedSetting: false);
			visualEffects = config("2 - Socket System", "Particle Effects", Toggle.On, "Enables or disables the particle effects for perfect gems.", synchronizedSetting: false);
			visualEffects.SettingChanged += delegate
			{
				ItemDrop[] array5 = Resources.FindObjectsOfTypeAll<ItemDrop>();
				foreach (ItemDrop val10 in array5)
				{
					if (visualEffects.Value == Toggle.On)
					{
						VisualEffects.DisplayEffectOnItemDrop.Postfix(val10);
					}
					else
					{
						VisualEffects.DisplayEffectOnItemDrop.RemoveEffects(val10);
					}
				}
			};
			displayGemcursor = config("2 - Socket System", "Display Gem Cursor", Toggle.On, "Changes the cursor to a gem, while interacting with the Gemcutters Table or socketing an item.", synchronizedSetting: false);
			displaySocketBackground = config("2 - Socket System", "Display Socket Background", Toggle.On, "Changes the background of items that have sockets.", synchronizedSetting: false);
			displaySocketBackground.SettingChanged += delegate
			{
				SocketsBackground.UpdateSocketBackground();
			};
			colorItemName = config("2 - Socket System", "Color Item Names", Toggle.On, "Colors the name of items according to their socket levels.", synchronizedSetting: false);
			useExternalYaml = configSync.AddConfigEntry<Toggle>(((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Socket System", "Use External YAML", Toggle.Off, new ConfigDescription("If set to on, external YAML files will be loaded from your config folder. These can be used, to highly fine tune Jewelcrafting to your liking.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			})));
			useExternalYaml.SourceConfig.SettingChanged += delegate
			{
				ConfigLoader.reloadConfigFile();
			};
			badLuckRecipes = config("2 - Socket System", "Bad Luck Recipes", Toggle.On, new ConfigDescription("Enables or disables the bad luck recipes of all gems.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			uniqueGemDropSystem = config("2 - Socket System", "Drop System for Unique Gems", UniqueDrop.TrulyUnique, new ConfigDescription("Disabled: Unique Gems do not drop.\nTruly Unique: The first kill of each boss grants one Unique Gem.\nCustom: Lets you configure a drop chance and rate.\nGuaranteed First: The first kill of each boss grants one Unique Gem. After that, the custom drop chance is used.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			uniqueGemDropChance = config("2 - Socket System", "Drop Chance for Unique Gems", 30, new ConfigDescription("Drop chance for Unique Gems. Has no effect, if the drop system is not set to custom.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			uniqueGemDropChanceIncreasePerWorldLevel = config("2 - Socket System", "Drop Chance Increase per World Level", 0, new ConfigDescription("If you have Creature Level & Loot Control installed, you can use this setting to increase the drop chance of Unique Gems per World Level. Additive, not multiplicative.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			uniqueGemDropOnePerPlayer = config("2 - Socket System", "Drop one Gem per Player", Toggle.On, new ConfigDescription("If bosses should drop one Unique Gem per player. Has no effect, if the drop system is not set to custom.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			allowUnsocketing = config("2 - Socket System", "Gems can be removed from items", Unsocketing.All, new ConfigDescription("All: All gems can be removed from items.\nUnique Only: Only unique gems can be removed from items.\nDisabled: No gems can be removed from items.\nDoes not affect gems without an effect.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			gemReturnLockedGems = config("2 - Socket System", "Return locked gems", Toggle.Off, new ConfigDescription("If on, locked gems will be returned to the player, if the item breaks while adding a socket to it.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			breakChanceUnsocketSimple = config("2 - Socket System", "Simple Gem Break Chance", 0f, new ConfigDescription("Chance to break a simple gem when trying to remove it from a socket. Does not affect gems without an effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			breakChanceUnsocketAdvanced = config("2 - Socket System", "Advanced Gem Break Chance", 0f, new ConfigDescription("Chance to break an advanced gem when trying to remove it from a socket. Does not affect gems without an effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			breakChanceUnsocketPerfect = config("2 - Socket System", "Perfect Gem Break Chance", 0f, new ConfigDescription("Chance to break a perfect gem when trying to remove it from a socket. Does not affect gems without an effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			breakChanceUnsocketMerged = config("2 - Socket System", "Merged Gem Break Chance", 0f, new ConfigDescription("Chance to break a merged gem when trying to remove it from a socket. Does not affect gems without an effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			resourceReturnRate = config("2 - Socket System", "Percentage Recovered", 50, new ConfigDescription("Percentage of items to be recovered, when an item breaks while trying to add a socket to it. This only considers the base cost of the item.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			resourceReturnRateUpgrade = config("2 - Socket System", "Percentage Recovered Upgrades", 100, new ConfigDescription("Percentage of items to be recovered, when an item breaks while trying to add a socket to it. This only considers the upgrade cost of the item.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}
			}));
			resourceReturnRateDistance = config("2 - Socket System", "Maximum Distance for Item Recovery", 0, new ConfigDescription("Maximum distance between the position where the item has been crafted and the position where the item has been destroyed to recover non-teleportable resources. This can be used, to prevent people from crafting items from metal, taking them through a portal and destroying them on the other side, to teleport the metal. Setting this to 0 disables this.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = (order -= 1)
				}