Иконка ресурса

FREE Kits : 1.2.16 1.2.16

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
// #define TESTING

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using Facepunch;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Oxide.Plugins.KitsExtensionMethods;
using UnityEngine;
using Random = UnityEngine.Random;

namespace Oxide.Plugins
{
	[Info("Kits", "Mevent", "1.2.16")]
	public class Kits : RustPlugin
	{
		#region Fields

		[PluginReference] private Plugin
			ImageLibrary = null,
			CopyPaste = null,
			Notify = null,
			UINotify = null,
			NoEscape = null;

		private static Kits _instance;

		private const string Layer = "UI.Kits";

		private const string InfoLayer = "UI.Kits.Info";

		private const string EditingLayer = "UI.Kits.Editing";

		private const string ModalLayer = "UI.Kits.Modal";

		private bool _enabledImageLibrary;

		private readonly Dictionary<BasePlayer, List<Kit>> _openGUI = new Dictionary<BasePlayer, List<Kit>>();

		private readonly Dictionary<ulong, Dictionary<string, object>> _kitEditing =
			new Dictionary<ulong, Dictionary<string, object>>();

		private readonly Dictionary<ulong, Dictionary<string, object>> _itemEditing =
			new Dictionary<ulong, Dictionary<string, object>>();

		private readonly Dictionary<string, List<KeyValuePair<int, string>>> _itemsCategories =
			new Dictionary<string, List<KeyValuePair<int, string>>>();

		private readonly List<BasePlayer> _toRemove = new List<BasePlayer>();

		private const string PermAdmin = "Kits.admin";

		private int _lastKitID;

		#endregion

		#region Config

		private Configuration _config;

		private class Configuration
		{
			[JsonProperty(PropertyName = "Automatic wipe on wipe")]
			public bool AutoWipe = false;

			[JsonProperty(PropertyName = "Save given kits (via the kits.givekit command) on wipe?")]
			public bool SaveGivenKitsOnWipe = false;

			[JsonProperty(PropertyName = "Default Kit Color")]
			public string KitColor = "#A0A935";

			[JsonProperty(PropertyName = "Work with Notify?")]
			public bool UseNotify = true;

			[JsonProperty(PropertyName = "Use NoEscape? (Raid/Combat block)")]
			public bool UseNoEscape = false;

			[JsonProperty(PropertyName = "Use Raid Blocked?")]
			public bool UseRaidBlock = true;

			[JsonProperty(PropertyName = "Use Combat Blocked?")]
			public bool UseCombatBlock = true;

			[JsonProperty(PropertyName = "Can admins edit? (by flag)")]
			public bool FlagAdmin = true;

			[JsonProperty(PropertyName = "Whitelist for NoEscape",
				ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<string> NoEscapeWhiteList = new List<string>
			{
				"kit name 1",
				"kit name 2"
			};

			[JsonProperty(PropertyName = "Commands", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public string[] Commands = {"kit", "kits"};

			[JsonProperty(PropertyName = "Economy")]
			public EconomyConf Economy = new EconomyConf
			{
				Type = EconomyType.Plugin,
				AddHook = "Deposit",
				BalanceHook = "Balance",
				RemoveHook = "Withdraw",
				Plug = "Economics",
				ShortName = "scrap",
				DisplayName = string.Empty,
				Skin = 0
			};

			[JsonProperty(PropertyName = "Rarity Settings", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<RarityColor> RarityColors = new List<RarityColor>
			{
				new RarityColor(40, "#A0A935")
			};

			[JsonProperty(PropertyName = "Auto Kits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<string> AutoKits = new List<string>
			{
				"autokit", "autokit_vip", "autokit_premium"
			};

			[JsonProperty(PropertyName = "Getting an auto kit 1 time?")]
			public bool OnceAutoKit = false;

			[JsonProperty(PropertyName = "Allow to enable/disable autokit?")]
			public bool UseChangeAutoKit = false;

			[JsonProperty(PropertyName = "Permission to enable/disable autokit")]
			public string ChangeAutoKitPermission = "kits.changeautokit";

			[JsonProperty(PropertyName = "Update the kits menu during permissions operations?")]
			public bool OnPermissionsUpdate = false;

			[JsonProperty(PropertyName = "Logs")] public LogInfo Logs = new LogInfo
			{
				Console = true,
				File = true
			};

			[JsonProperty(PropertyName = "Show Number?")]
			public bool ShowNumber = true;

			[JsonProperty(PropertyName = "Show No Permission Description?")]
			public bool ShowNoPermDescription = true;

			[JsonProperty(PropertyName = "Show All Kits?")]
			public bool ShowAllKits = false;

			[JsonProperty(PropertyName = "Show the kit when the number of uses is up?")]
			public bool ShowUsesEnd = false;

			[JsonProperty(PropertyName = "CopyPaste Parameters",
				ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<string> CopyPasteParameters = new List<string>
			{
				"deployables", "true", "inventories", "true"
			};

			[JsonProperty(PropertyName = "Block in Building Block?")]
			public bool BlockBuilding = false;

			[JsonProperty(PropertyName = "NPC Kits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public Dictionary<string, NpcKitsData> NpcKits = new Dictionary<string, NpcKitsData>
			{
				["1234567"] = new NpcKitsData
				{
					Description = "Free Kits",
					Kits = new List<string>
					{
						"kit_one",
						"kit_two"
					}
				},
				["7654321"] = new NpcKitsData
				{
					Description = "VIPs Kits",
					Kits = new List<string>
					{
						"kit_three",
						"kit_four"
					}
				}
			};

			[JsonProperty(PropertyName = "Description")]
			public MenuDescription Description = new MenuDescription
			{
				AnchorMin = "0 0", AnchorMax = "1 0",
				OffsetMin = "0 -55", OffsetMax = "0 -5",
				Enabled = true,
				Color = new IColor("#0E0E10", 100),
				FontSize = 18,
				Font = "robotocondensed-bold.ttf",
				Align = TextAnchor.MiddleCenter,
				TextColor = new IColor("#FFFFFF", 100),
				Description = string.Empty
			};

			[JsonProperty(PropertyName = "Info Kit Description")]
			public DescriptionSettings InfoKitDescription = new DescriptionSettings
			{
				AnchorMin = "0.5 1", AnchorMax = "0.5 1",
				OffsetMin = "-125 -55", OffsetMax = "125 -5",
				Enabled = true,
				Color = new IColor("#0E0E10", 100),
				FontSize = 18,
				Font = "robotocondensed-bold.ttf",
				Align = TextAnchor.MiddleCenter,
				TextColor = new IColor("#FFFFFF", 100)
			};

			[JsonProperty(PropertyName = "Interface")]
			public UserInterface UI = new UserInterface
			{
				Height = 455,
				Width = 640,
				KitHeight = 165,
				KitWidth = 135f,
				Margin = 10f,
				KitsOnString = 4,
				Strings = 2,
				YIndent = -100f,
				DisplayName = new DisplayNameSettings
				{
					AnchorMin = "0.5 1",
					AnchorMax = "0.5 1",
					OffsetMin = "-45 -75",
					OffsetMax = "45 0",
					Enabled = true
				},
				Image = new InterfacePosition
				{
					AnchorMin = "0.5 1",
					AnchorMax = "0.5 1",
					OffsetMin = "-32 -75",
					OffsetMax = "32 -11"
				},
				KitAvailable = new InterfacePosition
				{
					AnchorMin = "0 1",
					AnchorMax = "1 1",
					OffsetMin = "0 -100",
					OffsetMax = "0 -75"
				},
				KitAmount = new KitAmountSettings
				{
					AnchorMin = "0.5 1",
					AnchorMax = "0.5 1",
					OffsetMin = "-125",
					OffsetMax = "-120",
					Width = 115
				},
				KitCooldown = new InterfacePosition
				{
					AnchorMin = "0.5 1",
					AnchorMax = "0.5 1",
					OffsetMin = "-32.5 -125",
					OffsetMax = "32.5 -105"
				},
				KitSale = new InterfacePosition
				{
					AnchorMin = "0.5 1",
					AnchorMax = "0.5 1",
					OffsetMin = "-32.5 -115",
					OffsetMax = "32.5 -95"
				},
				KitAmountCooldown = new InterfacePosition
				{
					AnchorMin = "0 1",
					AnchorMax = "1 1",
					OffsetMin = "0 -120",
					OffsetMax = "0 -95"
				},
				NoPermission = new InterfacePosition
				{
					AnchorMin = "0 1",
					AnchorMax = "1 1",
					OffsetMin = "0 -100",
					OffsetMax = "0 -75"
				},
				CloseAfterReceive = true,
				Logo = new LogoConf
				{
					AnchorMin = "0 0.5",
					AnchorMax = "0 0.5",
					OffsetMin = "10 -20",
					OffsetMax = "50 20",
					Enabled = false,
					Image = string.Empty
				},
				ColorOne = new IColor("#161617", 100),
				ColorTwo = new IColor("#0E0E10", 100),
				ColorThree = new IColor("#4B68FF", 100),
				ColorFour = new IColor("#303030", 100),
				ColorFive = new IColor("#0E0E10", 98),
				ColorSix = new IColor("#161617", 80),
				ColorSeven = new IColor("#4B68FF", 50),
				ColorRed = new IColor("#FF4B4B", 100),
				ColorWhite = new IColor("#FFFFFF", 100)
			};

			[JsonProperty(PropertyName = "Custom Title for Kits")]
			public CustomTitles CustomTitles = new CustomTitles
			{
				Enabled = false,
				KitTitles = new Dictionary<string, CustomTitles.KitTitle>
				{
					["custom_kit"] = new CustomTitles.KitTitle
					{
						Enabled = false,
						Titles = new Dictionary<string, CustomTitles.TitleConf>
						{
							["NoPermissionDescription"] = new CustomTitles.TitleConf
							{
								Enabled = false,
								Messages = new Dictionary<string, string>
								{
									["en"] = "You don't have permission to get this kit",
									["fr"] = "Vous n'avez pas l'autorisation d'obtenir ce kit"
								}
							},
							["KitAvailable"] = new CustomTitles.TitleConf
							{
								Enabled = false,
								Messages = new Dictionary<string, string>
								{
									["en"] = "KIT AVAILABLE\nTO RECEIVE",
									["fr"] = "KIT DISPONIBLE\nPOUR RECEVOIR"
								}
							}
						}
					},
					["second_custom_kit"] = new CustomTitles.KitTitle
					{
						Enabled = false,
						Titles = new Dictionary<string, CustomTitles.TitleConf>
						{
							["NoPermissionDescription"] = new CustomTitles.TitleConf
							{
								Enabled = false,
								Messages = new Dictionary<string, string>
								{
									["en"] = "You don't have permission to get this kit",
									["fr"] = "Vous n'avez pas l'autorisation d'obtenir ce kit"
								}
							},
							["KitAvailable"] = new CustomTitles.TitleConf
							{
								Enabled = false,
								Messages = new Dictionary<string, string>
								{
									["en"] = "KIT AVAILABLE\nTO RECEIVE",
									["fr"] = "KIT DISPONIBLE\nPOUR RECEVOIR"
								}
							}
						}
					}
				}
			};

			[JsonProperty(PropertyName = "Kits hidden in the interface",
				ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public string[] KitsHidden =
			{
				"Enter the name of the kit here",
				"Example of a string for the second kit"
			};

			public VersionNumber Version;
		}

		private class LogoConf : InterfacePosition
		{
			[JsonProperty(PropertyName = "Enabled")]
			public bool Enabled;

			[JsonProperty(PropertyName = "Image")] public string Image;
		}

		private class CustomTitles
		{
			[JsonProperty(PropertyName = "Enabled")]
			public bool Enabled;

			[JsonProperty(PropertyName = "Kit Titles (kit name – settings)",
				ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public Dictionary<string, KitTitle> KitTitles = new Dictionary<string, KitTitle>();

			public class TitleConf
			{
				[JsonProperty(PropertyName = "Enabled")]
				public bool Enabled;

				[JsonProperty(PropertyName = "Text (language - text)",
					ObjectCreationHandling = ObjectCreationHandling.Replace)]
				public Dictionary<string, string> Messages = new Dictionary<string, string>();

				public string GetMessage(BasePlayer player = null)
				{
					if (Messages.Count == 0)
						throw new Exception("The use of custom titles is enabled, but there are no messages!");

					var userLang = "en";
					if (player != null) userLang = _instance.lang.GetLanguage(player.UserIDString);

					string message;
					if (Messages.TryGetValue(userLang, out message))
						return message;

					if (Messages.TryGetValue("en", out message))
						return message;

					return Messages.ElementAt(0).Value;
				}
			}

			public class KitTitle
			{
				[JsonProperty(PropertyName = "Enabled")]
				public bool Enabled;

				[JsonProperty(PropertyName = "Titles (key – settings)",
					ObjectCreationHandling = ObjectCreationHandling.Replace)]
				public Dictionary<string, TitleConf> Titles = new Dictionary<string, TitleConf>();
			}
		}

		private enum EconomyType
		{
			Plugin,
			Item
		}

		private class EconomyConf
		{
			[JsonProperty(PropertyName = "Type (Plugin/Item)")] [JsonConverter(typeof(StringEnumConverter))]
			public EconomyType Type;

			[JsonProperty(PropertyName = "Plugin name")]
			public string Plug;

			[JsonProperty(PropertyName = "Balance add hook")]
			public string AddHook;

			[JsonProperty(PropertyName = "Balance remove hook")]
			public string RemoveHook;

			[JsonProperty(PropertyName = "Balance show hook")]
			public string BalanceHook;

			[JsonProperty(PropertyName = "ShortName")]
			public string ShortName;

			[JsonProperty(PropertyName = "Display Name (empty - default)")]
			public string DisplayName;

			[JsonProperty(PropertyName = "Skin")] public ulong Skin;

			public double ShowBalance(BasePlayer player)
			{
				switch (Type)
				{
					case EconomyType.Plugin:
					{
						var plugin = _instance?.plugins?.Find(Plug);
						if (plugin == null) return 0;

						return Math.Round(Convert.ToDouble(plugin.Call(BalanceHook, player.userID)));
					}
					case EconomyType.Item:
					{
						return ItemCount(player.inventory.AllItems(), ShortName, Skin);
					}
					default:
						return 0;
				}
			}

			public void AddBalance(BasePlayer player, double amount)
			{
				switch (Type)
				{
					case EconomyType.Plugin:
					{
						var plugin = _instance?.plugins?.Find(Plug);
						if (plugin == null) return;

						switch (Plug)
						{
							case "BankSystem":
							case "ServerRewards":
							case "IQEconomic":
								plugin.Call(AddHook, player.userID, (int) amount);
								break;
							default:
								plugin.Call(AddHook, player.userID, amount);
								break;
						}

						break;
					}
					case EconomyType.Item:
					{
						var am = (int) amount;

						var item = ToItem(am);
						if (item == null) return;

						player.GiveItem(item);
						break;
					}
				}
			}

			public bool RemoveBalance(BasePlayer player, double amount)
			{
				switch (Type)
				{
					case EconomyType.Plugin:
					{
						if (ShowBalance(player) < amount) return false;

						var plugin = _instance?.plugins.Find(Plug);
						if (plugin == null) return false;

						switch (Plug)
						{
							case "BankSystem":
							case "ServerRewards":
							case "IQEconomic":
								plugin.Call(RemoveHook, player.userID, (int) amount);
								break;
							default:
								plugin.Call(RemoveHook, player.userID, amount);
								break;
						}

						return true;
					}
					case EconomyType.Item:
					{
						var playerItems = player.inventory.AllItems();
						var am = (int) amount;

						if (ItemCount(playerItems, ShortName, Skin) < am) return false;

						Take(playerItems, ShortName, Skin, am);
						return true;
					}
					default:
						return false;
				}
			}

			private static int ItemCount(Item[] items, string shortname, ulong skin)
			{
				return items.Where(item =>
						item.info.shortname == shortname && !item.isBroken && (skin == 0 || item.skin == skin)).Sum(item => item.amount);
			}

			private static void Take(IEnumerable<Item> itemList, string shortname, ulong skinId, int iAmount)
			{
				var num1 = 0;
				if (iAmount == 0) return;

				var list = Pool.GetList<Item>();

				foreach (var item in itemList)
				{
					if (item.info.shortname != shortname ||
					    (skinId != 0 && item.skin != skinId) || item.isBroken) continue;

					var num2 = iAmount - num1;
					if (num2 <= 0) continue;
					if (item.amount > num2)
					{
						item.MarkDirty();
						item.amount -= num2;
						break;
					}

					if (item.amount <= num2)
					{
						num1 += item.amount;
						list.Add(item);
					}

					if (num1 == iAmount)
						break;
				}

				foreach (var obj in list)
					obj.RemoveFromContainer();

				Pool.FreeList(ref list);
			}

			private Item ToItem(int amount)
			{
				var item = ItemManager.CreateByName(ShortName, amount, Skin);
				if (item == null)
				{
					Debug.LogError($"Error creating item with ShortName: '{ShortName}'");
					return null;
				}

				if (!string.IsNullOrEmpty(DisplayName)) item.name = DisplayName;

				return item;
			}
		}

		private class UserInterface
		{
			[JsonProperty(PropertyName = "Height")]
			public float Height;

			[JsonProperty(PropertyName = "Width")] public float Width;

			[JsonProperty(PropertyName = "Kit Height")]
			public float KitHeight;

			[JsonProperty(PropertyName = "Kit Width")]
			public float KitWidth;

			[JsonProperty(PropertyName = "Margin")]
			public float Margin;

			[JsonProperty(PropertyName = "Kits On String")]
			public int KitsOnString;

			[JsonProperty(PropertyName = "Strings")]
			public int Strings;

			[JsonProperty(PropertyName = "Y Indent")]
			public float YIndent;

			[JsonProperty(PropertyName = "Display Name Settings")]
			public DisplayNameSettings DisplayName;

			[JsonProperty(PropertyName = "Image Settings")]
			public InterfacePosition Image;

			[JsonProperty(PropertyName = "Kit Available Settings")]
			public InterfacePosition KitAvailable;

			[JsonProperty(PropertyName = "Kit Amount Settings")]
			public KitAmountSettings KitAmount;

			[JsonProperty(PropertyName = "Kit Cooldown Settings")]
			public InterfacePosition KitCooldown;

			[JsonProperty(PropertyName = "Kit Sale Settings")]
			public InterfacePosition KitSale;

			[JsonProperty(PropertyName = "Kit Cooldown Settings (with amount)")]
			public InterfacePosition KitAmountCooldown;

			[JsonProperty(PropertyName = "No Permission Settings")]
			public InterfacePosition NoPermission;

			[JsonProperty(PropertyName = "Close the interface after receiving a kit?")]
			public bool CloseAfterReceive;

			[JsonProperty(PropertyName = "Logo Settings")]
			public LogoConf Logo;

			[JsonProperty(PropertyName = "Color 1")]
			public IColor ColorOne;

			[JsonProperty(PropertyName = "Color 2")]
			public IColor ColorTwo;

			[JsonProperty(PropertyName = "Color 3")]
			public IColor ColorThree;

			[JsonProperty(PropertyName = "Color 4")]
			public IColor ColorFour;

			[JsonProperty(PropertyName = "Color 5")]
			public IColor ColorFive;

			[JsonProperty(PropertyName = "Color 6")]
			public IColor ColorSix;

			[JsonProperty(PropertyName = "Color 7")]
			public IColor ColorSeven;

			[JsonProperty(PropertyName = "Color Red")]
			public IColor ColorRed;

			[JsonProperty(PropertyName = "Color White")]
			public IColor ColorWhite;
		}

		private class DisplayNameSettings : InterfacePosition
		{
			[JsonProperty(PropertyName = "Enabled")]
			public bool Enabled;
		}

		private class KitAmountSettings : InterfacePosition
		{
			[JsonProperty(PropertyName = "Width")] public float Width;
		}

		private class NpcKitsData
		{
			[JsonProperty(PropertyName = "Description")]
			public string Description;

			[JsonProperty(PropertyName = "Kits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<string> Kits;
		}

		private class InterfacePosition
		{
			public string AnchorMin;

			public string AnchorMax;

			public string OffsetMin;

			public string OffsetMax;
		}

		private class DescriptionSettings : InterfacePosition
		{
			[JsonProperty(PropertyName = "Enabled")]
			public bool Enabled;

			[JsonProperty(PropertyName = "Background Color")]
			public IColor Color;

			[JsonProperty(PropertyName = "Font Size")]
			public int FontSize;

			[JsonProperty(PropertyName = "Font")] public string Font;

			[JsonProperty(PropertyName = "Align")] [JsonConverter(typeof(StringEnumConverter))]
			public TextAnchor Align;

			[JsonProperty(PropertyName = "Text Color")]
			public IColor TextColor;

			public void Get(ref CuiElementContainer container, string parent, string name = null,
				string description = null)
			{
				if (!Enabled || string.IsNullOrEmpty(description)) return;

				if (string.IsNullOrEmpty(name))
					name = CuiHelper.GetGuid();

				container.Add(new CuiPanel
				{
					RectTransform =
					{
						AnchorMin = AnchorMin, AnchorMax = AnchorMax,
						OffsetMin = OffsetMin, OffsetMax = OffsetMax
					},
					Image = {Color = Color.Get()}
				}, parent, name);

				container.Add(new CuiLabel
				{
					RectTransform = {AnchorMin = "0 0", AnchorMax = "1 1"},
					Text =
					{
						Text = $"{description}",
						Align = Align,
						Font = Font,
						FontSize = FontSize,
						Color = TextColor.Get()
					}
				}, name);
			}
		}

		private class MenuDescription : DescriptionSettings
		{
			[JsonProperty(PropertyName = "Description")]
			public string Description;
		}

		private class IColor
		{
			[JsonProperty(PropertyName = "HEX")] public string HEX;

			[JsonProperty(PropertyName = "Opacity (0 - 100)")]
			public float Alpha;

			public string Get()
			{
				if (string.IsNullOrEmpty(HEX)) HEX = "#FFFFFF";

				var str = HEX.Trim('#');
				if (str.Length != 6) throw new Exception(HEX);
				var r = byte.Parse(str.Substring(0, 2), NumberStyles.HexNumber);
				var g = byte.Parse(str.Substring(2, 2), NumberStyles.HexNumber);
				var b = byte.Parse(str.Substring(4, 2), NumberStyles.HexNumber);

				return $"{(double) r / 255} {(double) g / 255} {(double) b / 255} {Alpha / 100}";
			}

			public IColor(string hex, float alpha)
			{
				HEX = hex;
				Alpha = alpha;
			}
		}

		private class LogInfo
		{
			[JsonProperty(PropertyName = "To Console")]
			public bool Console;

			[JsonProperty(PropertyName = "To File")]
			public bool File;
		}

		private class RarityColor
		{
			[JsonProperty(PropertyName = "Chance")]
			public int Chance;

			[JsonProperty(PropertyName = "Color")] public string Color;

			public RarityColor(int chance, string color)
			{
				Chance = chance;
				Color = color;
			}
		}

		protected override void LoadConfig()
		{
			base.LoadConfig();
			try
			{
				_config = Config.ReadObject<Configuration>();
				if (_config == null) throw new Exception();

				if (_config.Version < Version)
					UpdateConfigValues();

				SaveConfig();
			}
			catch
			{
				PrintError("Your configuration file contains an error.Using default configuration values.");
				LoadDefaultConfig();
			}
		}

		protected override void SaveConfig()
		{
			Config.WriteObject(_config);
		}

		protected override void LoadDefaultConfig()
		{
			_config = new Configuration();
		}

		private void UpdateConfigValues()
		{
			PrintWarning("Config update detected! Updating config values...");

			var baseConfig = new Configuration();

			if (_config.Version != default(VersionNumber))
			{
				if (_config.Version < new VersionNumber(1, 0, 25))
					_config.UI.KitSale = baseConfig.UI.KitSale;

				if (_config.Version < new VersionNumber(1, 2, 0)) StartConvertOldData();

				if (_config.Version < new VersionNumber(1, 2, 13))
				{
					_config.UI.ColorOne = new IColor(Config["Color 1"].ToString(), 100);
					_config.UI.ColorTwo = new IColor(Config["Color 2"].ToString(), 100);
					_config.UI.ColorThree = new IColor(Config["Color 3"].ToString(), 100);
					_config.UI.ColorFour = new IColor(Config["Color 4"].ToString(), 100);
					_config.UI.ColorRed = new IColor(Config["Color Red"].ToString(), 100);
					_config.UI.ColorWhite = new IColor(Config["Color White"].ToString(), 100);
				}
			}

			_config.Version = Version;
			PrintWarning("Config update completed!");
		}

		#endregion

		#region Data

		private PluginData _data;

		private List<ulong> _disablesAutoKits = new List<ulong>();

		private void SaveKits()
		{
			Interface.Oxide.DataFileSystem.WriteObject($"{Name}/Kits", _data);
		}

		private void SaveDisabledAutoKits()
		{
			if (!_config.UseChangeAutoKit) return;

			Interface.Oxide.DataFileSystem.WriteObject($"{Name}/DisabledAutoKits", _disablesAutoKits);
		}

		private void LoadData()
		{
			try
			{
				_data = Interface.Oxide.DataFileSystem.ReadObject<PluginData>($"{Name}/Kits");

				if (_config.UseChangeAutoKit)
					_disablesAutoKits =
						Interface.Oxide.DataFileSystem.ReadObject<List<ulong>>(
							$"{Name}/DisabledAutoKits");
			}
			catch (Exception e)
			{
				PrintError(e.ToString());
			}

			if (_data == null) _data = new PluginData();
			if (_disablesAutoKits == null) _disablesAutoKits = new List<ulong>();
		}

		private class PluginData
		{
			[JsonProperty(PropertyName = "Kits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<Kit> Kits = new List<Kit>();
		}

		private class Kit
		{
			[JsonIgnore] public int ID;

			[JsonProperty(PropertyName = "Name")] public string Name;

			[JsonProperty(PropertyName = "Display Name")]
			public string DisplayName;

			[JsonProperty(PropertyName = "Color")] public string Color;

			[JsonProperty(PropertyName = "Permission")]
			public string Permission;

			[JsonProperty(PropertyName = "Description")]
			public string Description;

			[JsonProperty(PropertyName = "Image")] public string Image;

			[JsonProperty(PropertyName = "Hide")] public bool Hide;

			[JsonProperty(PropertyName = "ShowInfo")] [DefaultValue(true)]
			public bool ShowInfo;

			[JsonProperty(PropertyName = "Amount")]
			public int Amount;

			[JsonProperty(PropertyName = "Cooldown")]
			public double Cooldown;

			[JsonProperty(PropertyName = "Wipe Block")]
			public double CooldownAfterWipe;

			[JsonProperty(PropertyName = "Use Building")]
			public bool UseBuilding;

			[JsonProperty(PropertyName = "Building")]
			public string Building;

			[JsonProperty(PropertyName = "Enable sale")]
			public bool Sale;

			[JsonProperty(PropertyName = "Selling price")]
			public int Price;

			[JsonProperty(PropertyName = "Items", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<KitItem> Items;

			[JsonProperty(PropertyName = "Use commands on receiving?")]
			public bool UseCommandsOnReceiving;

			[JsonProperty(PropertyName = "Commands on receiving (via '|')",
				ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public string CommandsOnReceiving;

			public void Get(BasePlayer player)
			{
				Items?.ForEach(item => item?.Get(player));

				UseCommands(player);
			}

			public void UseCommands(BasePlayer player)
			{
				if (UseCommandsOnReceiving && !string.IsNullOrWhiteSpace(CommandsOnReceiving))
				{
					var command = CommandsOnReceiving.Replace("\n", "|").Replace("%steamid%", player.UserIDString, StringComparison.OrdinalIgnoreCase).Replace("%username%", player.displayName, StringComparison.OrdinalIgnoreCase);

					foreach (var check in command.Split('|'))
						_instance?.Server.Command(check);
				}
			}

			[JsonIgnore] public Dictionary<int, KitItem> dictMainItems = new Dictionary<int, KitItem>();

			[JsonIgnore] public Dictionary<int, KitItem> dictBeltItems = new Dictionary<int, KitItem>();

			[JsonIgnore] public Dictionary<int, KitItem> dictWearItems = new Dictionary<int, KitItem>();

			[JsonIgnore] public int beltCount;

			[JsonIgnore] public int wearCount;

			[JsonIgnore] public int mainCount;

			public void Update()
			{
				LoadContainers();

				GenerateJObject();
			}

			private void LoadContainers()
			{
				dictWearItems.Clear();
				dictBeltItems.Clear();
				dictMainItems.Clear();

				beltCount = 0;
				wearCount = 0;
				mainCount = 0;

				Items.ForEach(item =>
				{
					switch (item.Container)
					{
						case "wear":
							dictWearItems[item.Position] = item;

							wearCount++;
							break;
						case "belt":
							dictBeltItems[item.Position] = item;

							beltCount++;
							break;
						case "main":
							dictMainItems[item.Position] = item;

							mainCount++;
							break;
					}
				});
			}

			public KitItem GetItemByContainerAndPosition(string container, int position)
			{
				KitItem item;
				switch (container)
				{
					case "wear":
					{
						return dictWearItems.TryGetValue(position, out item) ? item : null;
					}
					case "belt":
					{
						return dictBeltItems.TryGetValue(position, out item) ? item : null;
					}
					default:
					{
						return dictMainItems.TryGetValue(position, out item) ? item : null;
					}
				}
			}

			#region JObject

			[JsonIgnore] private JObject _jObject;

			[JsonIgnore]
			internal JObject ToJObject
			{
				get
				{
					if (_jObject == null)
					{
						GenerateJObject();
					}

					return _jObject;
				}
			}

			private void GenerateJObject()
			{
				_jObject = new JObject
				{
					["Name"] = DisplayName,
					["Description"] = Description,
					["RequiredPermission"] = Permission,
					["MaximumUses"] = Amount,
					["Cost"] = Price,
					["IsHidden"] = Hide,
					["CopyPasteFile"] = Building,
					["KitImage"] = Image,
					["MainItems"] = new JArray(),
					["WearItems"] = new JArray(),
					["BeltItems"] = new JArray()
				};

				foreach (var kitItem in dictMainItems.Values)
					(_jObject["MainItems"] as JArray).Add(kitItem.ToJObject);

				foreach (var kitItem in dictWearItems.Values)
					(_jObject["WearItems"] as JArray).Add(kitItem.ToJObject);

				foreach (var kitItem in dictBeltItems.Values)
					(_jObject["BeltItems"] as JArray).Add(kitItem.ToJObject);
			}

			#endregion
		}

		private enum KitItemType
		{
			Item,
			Command
		}

		private class KitItem
		{
			[JsonProperty(PropertyName = "Type")] [JsonConverter(typeof(StringEnumConverter))]
			public KitItemType Type;

			[JsonProperty(PropertyName = "Command")]
			public string Command;

			[JsonProperty(PropertyName = "ShortName")]
			public string ShortName;

			[JsonProperty(PropertyName = "DisplayName")]
			public string DisplayName;

			[JsonProperty(PropertyName = "Amount")]
			public int Amount;

			[JsonProperty(PropertyName = "Blueprint")]
			public int Blueprint;

			[JsonProperty(PropertyName = "SkinID")]
			public ulong SkinID;

			[JsonProperty(PropertyName = "Container")]
			public string Container;

			[JsonProperty(PropertyName = "Condition")]
			public float Condition;

			[JsonProperty(PropertyName = "Chance")]
			public int Chance;

			[JsonProperty(PropertyName = "Position", DefaultValueHandling = DefaultValueHandling.Populate)]
			[DefaultValue(-1)]
			public int Position;

			[JsonProperty(PropertyName = "Image")] public string Image;

			[JsonProperty(PropertyName = "Weapon")]
			public Weapon Weapon;

			[JsonProperty(PropertyName = "Content", ObjectCreationHandling = ObjectCreationHandling.Replace)]
			public List<ItemContent> Content;

			[JsonProperty(PropertyName = "Text")] public string Text;

			public void Get(BasePlayer player)
			{
				if (Chance < 100 && Random.Range(0, 100) > Chance) return;

				switch (Type)
				{
					case KitItemType.Item:
					{
						GiveItem(player, BuildItem(),
							Container == "belt" ? player.inventory.containerBelt :
							Container == "wear" ? player.inventory.containerWear : player.inventory.containerMain);
						break;
					}
					case KitItemType.Command:
					{
						ToCommand(player);
						break;
					}
				}
			}

			private void ToCommand(BasePlayer player)
			{
				var command = Command.Replace("\n", "|").Replace("%steamid%", player.UserIDString, StringComparison.OrdinalIgnoreCase).Replace("%username%",
						player.displayName, StringComparison.OrdinalIgnoreCase);

				foreach (var check in command.Split('|')) _instance?.Server.Command(check);
			}

			private static void GiveItem(BasePlayer player, Item item, ItemContainer cont = null)
			{
				if (item == null) return;
				var inv = player.inventory;

				var moved = item.MoveToContainer(cont, item.position) || item.MoveToContainer(cont) ||
				            item.MoveToContainer(inv.containerMain);
				if (!moved)
				{
					if (cont == inv.containerBelt)
						moved = item.MoveToContainer(inv.containerWear);
					if (cont == inv.containerWear)
						moved = item.MoveToContainer(inv.containerBelt);
				}

				if (!moved)
					item.Drop(player.GetCenter(), player.GetDropVelocity());
			}

			[JsonIgnore] private ItemDefinition _itemDefinition;

			[JsonIgnore]
			public ItemDefinition ItemDefinition
			{
				get
				{
					if (_itemDefinition == null) _itemDefinition = ItemManager.FindItemDefinition(ShortName);

					return _itemDefinition;
				}
			}

			private Item BuildItem()
			{
				var item = ItemManager.Create(ItemDefinition, Mathf.Max(Amount, 1), SkinID);
				item.condition = Condition;

				item.position = Position;

				if (Blueprint != 0)
					item.blueprintTarget = Blueprint;

				if (!string.IsNullOrEmpty(DisplayName))
					item.name = DisplayName;

				if (!string.IsNullOrEmpty(Text))
					item.text = Text;

				if (Weapon != null)
				{
					var heldEntity = item.GetHeldEntity();
					if (heldEntity != null)
					{
						heldEntity.skinID = SkinID;

						var baseProjectile = heldEntity as BaseProjectile;
						if (baseProjectile != null && !string.IsNullOrEmpty(Weapon.ammoType))
						{
							baseProjectile.primaryMagazine.contents = Weapon.ammoAmount;
							baseProjectile.primaryMagazine.ammoType =
								ItemManager.FindItemDefinition(Weapon.ammoType);
						}

						heldEntity.SendNetworkUpdate();
					}
				}

				Content?.ForEach(cont =>
				{
					var newCont = ItemManager.CreateByName(cont.ShortName, cont.Amount);
					newCont.condition = cont.Condition;
					newCont.MoveToContainer(item.contents);
				});

				return item;
			}

			public static KitItem FromOld(ItemData item, string container)
			{
				var newItem = new KitItem
				{
					Content =
						item.Contents?.Select(x =>
								new ItemContent {ShortName = x.Shortname, Condition = x.Condition, Amount = x.Amount}).ToList() ?? new List<ItemContent>(),
					Weapon = new Weapon {ammoAmount = item.Ammo, ammoType = item.Ammotype},
					Container = container,
					SkinID = item.Skin,
					Command = string.Empty,
					Chance = 100,
					Blueprint = string.IsNullOrEmpty(item.BlueprintShortname) ? 0 : 1,
					Condition = item.Condition,
					Amount = item.Amount,
					ShortName = item.Shortname,
					Type = KitItemType.Item,
					Position = item.Position
				};

				return newItem;
			}

			[JsonIgnore] private int _itemId = -1;

			[JsonIgnore]
			public int itemId
			{
				get
				{
					if (_itemId == -1)
						UpdateItemID();
					return _itemId;
				}
			}

			[JsonIgnore] private ICuiComponent _image;

			public CuiElement GetImage(string aMin, string aMax, string oMin, string oMax, string parent,
				string name = null)
			{
				if (_image == null)
					GenerateNewImage();

				return new CuiElement
				{
					Name = string.IsNullOrEmpty(name) ? CuiHelper.GetGuid() : name,
					Parent = parent,
					Components =
					{
						_image,
						new CuiRectTransformComponent
						{
							AnchorMin = aMin, AnchorMax = aMax,
							OffsetMin = oMin, OffsetMax = oMax
						}
					}
				};
			}

			private void GenerateNewImage()
			{
				if (_instance._enabledImageLibrary && !string.IsNullOrEmpty(Image))
					_image = new CuiRawImageComponent
					{
						Png = _instance.ImageLibrary.Call<string>("GetImage", Image)
					};
				else
					_image = new CuiImageComponent
					{
						ItemId = itemId,
						SkinId = SkinID
					};
			}

			private void UpdateItemID()
			{
				_itemId = ItemManager.FindItemDefinition(ShortName)?.itemid ?? -1;
			}

			public void Update()
			{
				UpdateItemID();

				GenerateNewImage();

				GenerateJObject();
			}

			#region JObject

			[JsonIgnore] private JObject _jObject;

			[JsonIgnore]
			public JObject ToJObject
			{
				get
				{
					if (_jObject == null)
					{
						GenerateJObject();
					}

					return _jObject;
				}
			}

			private void GenerateJObject()
			{
				_jObject = new JObject
				{
					["Shortname"] = ShortName,
					["DisplayName"] = DisplayName,
					["SkinID"] = SkinID,
					["Amount"] = Amount,
					["Condition"] = Condition,
					["MaxCondition"] = Condition,
					["IsBlueprint"] = Blueprint != 0,
					["Ammo"] = Weapon?.ammoAmount,
					["AmmoType"] = Weapon?.ammoType,
					["Text"] = Text,
					["Contents"] = new JArray()
				};

				Content?.ForEach(x =>
				{
					(_jObject["Contents"] as JArray)?.Add(new JObject
					{
						["Shortname"] = x.ShortName,
						["DisplayName"] = string.Empty,
						["SkinID"] = 0,
						["Amount"] = x.Amount,
						["Condition"] = x.Condition,
						["MaxCondition"] = x.Condition,
						["IsBlueprint"] = false,
						["Ammo"] = 0,
						["AmmoType"] = string.Empty,
						["Text"] = string.Empty,
						["Contents"] = new JArray()
					});
				});
			}

			#endregion
		}

		private class Weapon
		{
			public string ammoType;

			public int ammoAmount;
		}

		private class ItemContent
		{
			public string ShortName;

			public float Condition;

			public int Amount;
		}

		#endregion

		#region Hooks

		private void Init()
		{
			_instance = this;

			LoadData();

			if (!_config.OnPermissionsUpdate)
			{
				Unsubscribe(nameof(OnUserPermissionGranted));
				Unsubscribe(nameof(OnUserPermissionRevoked));
			}
		}

		private void OnServerInitialized()
		{
			LoadImages();

			LoadKits();

			FixItemsPositions();

			FillCategories();

			RegisterPermissions();

			RegisterCommands();

			timer.Every(1, HandleUi);
		}

		private void OnServerSave()
		{
			timer.In(Random.Range(2, 7), PlayerData.Save);
		}

		private void Unload()
		{
			if (_wipePlayers != null)
				ServerMgr.Instance.StopCoroutine(_wipePlayers);

			foreach (var player in BasePlayer.activePlayerList)
			{
				CuiHelper.DestroyUi(player, Layer);
				CuiHelper.DestroyUi(player, InfoLayer);
				CuiHelper.DestroyUi(player, EditingLayer);
				CuiHelper.DestroyUi(player, ModalLayer);

				PlayerData.SaveAndUnload(player.UserIDString);
			}

			_instance = null;
		}

		#region Wipe

		private void OnNewSave(string filename)
		{
			if (!_config.AutoWipe) return;

			DoWipePlayers();
		}

		#endregion

		private void OnPlayerRespawned(BasePlayer player)
		{
			if (player == null || (_config.UseChangeAutoKit && _disablesAutoKits.Contains(player.userID))) return;

			var kits = GetAutoKits(player);
			if (kits.Count == 0)
				return;

			player.inventory.Strip();

			if (_config.OnceAutoKit)
				kits.LastOrDefault()?.Get(player);
			else
				kits.ForEach(kit => kit.Get(player));
		}

		private void OnPlayerDisconnected(BasePlayer player)
		{
			_openGUI.Remove(player);
			_kitEditing.Remove(player.userID);
			_itemEditing.Remove(player.userID);

			PlayerData.SaveAndUnload(player.UserIDString);
		}

		private void OnPlayerDeath(BasePlayer player, HitInfo info)
		{
			if (player == null) return;

			CuiHelper.DestroyUi(player, Layer);

			OnPlayerDisconnected(player);
		}

		private void OnUseNPC(BasePlayer npc, BasePlayer player)
		{
			if (npc == null || player == null || !_config.NpcKits.ContainsKey(npc.UserIDString)) return;

			MainUi(player, npc.userID, first: true);
		}

		#region Image Library

		private void OnPluginLoaded(Plugin plugin)
		{
			if (plugin.Name == "ImageLibrary") _enabledImageLibrary = true;
		}

		private void OnPluginUnloaded(Plugin plugin)
		{
			if (plugin.Name == "ImageLibrary") _enabledImageLibrary = false;
		}

		#endregion

		#region Permissions

		private void OnUserPermissionGranted(string id, string permName)
		{
			UpdateOpenedUI(id, permName);
		}

		private void OnUserPermissionRevoked(string id, string permName)
		{
			UpdateOpenedUI(id, permName);
		}

		#endregion

		#endregion

		#region Commands

		private void CmdOpenKits(IPlayer cov, string command, string[] args)
		{
			var player = cov?.Object as BasePlayer;
			if (player == null) return;

			if (_enabledImageLibrary == false)
			{
				SendNotify(player, NoILError, 1);

				BroadcastILNotInstalled();
				return;
			}

			if (args.Length == 0)
			{
				MainUi(player, first: true);
				return;
			}

			switch (args[0])
			{
				case "help":
				{
					Reply(player, KitsHelp, command);
					break;
				}

				case "list":
				{
					Reply(player, KitsList,
						string.Join(", ", GetAvailableKits(player).Select(x => $"'{x.DisplayName}'")));
					break;
				}

				case "remove":
				{
					if (!IsAdmin(player)) return;

					var name = string.Join(" ", args.Skip(1));
					if (string.IsNullOrEmpty(name))
					{
						SendNotify(player, KitNotFound, 1, name);
						return;
					}

					var kit = GetAvailableKits(player)?.Find(x => x.DisplayName == name);
					if (kit == null)
					{
						SendNotify(player, KitNotFound, 1, name);
						return;
					}

					_data.Kits.Remove(kit);
					SaveKits();

					SendNotify(player, KitRemoved, 0, name);
					break;
				}

				case "autokit":
				{
					if (!_config.UseChangeAutoKit) return;

					if (!string.IsNullOrEmpty(_config.ChangeAutoKitPermission) &&
					    !cov.HasPermission(_config.ChangeAutoKitPermission))
					{
						ErrorUi(player, Msg(player, NoPermission));
						return;
					}

					bool enabled;
					if (_disablesAutoKits.Contains(player.userID))
					{
						_disablesAutoKits.Remove(player.userID);

						enabled = true;
					}
					else
					{
						_disablesAutoKits.Add(player.userID);

						enabled = false;
					}

					if (enabled)
						SendNotify(player, ChangeAutoKitOn, 0);
					else
						SendNotify(player, ChangeAutoKitOff, 1);

					SaveDisabledAutoKits();
					break;
				}

				default:
				{
					var name = string.Join(" ", args);
					if (string.IsNullOrEmpty(name))
					{
						SendNotify(player, KitNotFound, 1, name);
						return;
					}

					var kit = GetAvailableKits(player, checkAmount: false).Find(x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase) ||
						           string.Equals(x.DisplayName, name, StringComparison.InvariantCultureIgnoreCase));
					if (kit == null)
					{
						SendNotify(player, KitNotFound, 1, name);
						return;
					}

					GiveKitToPlayer(player, kit, chat: true);
					break;
				}
			}
		}

		[ConsoleCommand("UI_Kits")]
		private void CmdKitsConsole(ConsoleSystem.Arg arg)
		{
			var player = arg?.Player();
			if (player == null || !arg.HasArgs()) return;

			switch (arg.Args[0])
			{
				case "close":
				{
					_openGUI.Remove(player);

					StopEditing(player);
					break;
				}

				case "stopedit":
				{
					StopEditing(player);
					break;
				}

				case "main":
				{
					var targetId = 0UL;
					if (arg.HasArgs(2))
						ulong.TryParse(arg.Args[1], out targetId);

					var page = 0;
					if (arg.HasArgs(3))
						int.TryParse(arg.Args[2], out page);

					var showAll = false;
					if (arg.HasArgs(4))
						bool.TryParse(arg.Args[3], out showAll);

					MainUi(player, targetId, page, showAll);
					break;
				}

				case "infokit":
				{
					int page, kitId;
					if (!arg.HasArgs(3) || !int.TryParse(arg.Args[1], out page) ||
					    !int.TryParse(arg.Args[2], out kitId)) return;

					var kit = FindKitByID(kitId);
					if (kit == null) return;

					StopEditing(player);

					InfoKitUi(player, page, kit);
					break;
				}

				case "givekit":
				{
					int kitId, page;
					ulong targetId;
					bool showAll;
					if (!arg.HasArgs(5) ||
					    !int.TryParse(arg.Args[1], out kitId) ||
					    !ulong.TryParse(arg.Args[2], out targetId) ||
					    !int.TryParse(arg.Args[3], out page) ||
					    !bool.TryParse(arg.Args[4], out showAll)) return;

					var kit = FindKitByID(kitId);
					if (kit == null) return;

					GiveKitToPlayer(player, kit, targetId: targetId, page: page, showAll: showAll);
					break;
				}

				case "editkit":
				{
					if (!IsAdmin(player)) return;

					int page;
					if (!arg.HasArgs(2) || !int.TryParse(arg.Args[1], out page)) return;

					bool creating;
					if (!arg.HasArgs(3) || !bool.TryParse(arg.Args[2], out creating)) return;

					var kitId = -1;
					if (arg.HasArgs(4))
						int.TryParse(arg.Args[3], out kitId);

					if (arg.HasArgs(5) && (!arg.HasArgs(6) || string.IsNullOrEmpty(arg.Args[5])))
						return;

					if (arg.HasArgs(6))
					{
						var key = arg.Args[4];
						var value = arg.Args[5];

						if (_kitEditing.ContainsKey(player.userID) && _kitEditing[player.userID].ContainsKey(key))
						{
							object newValue = null;

							switch (key)
							{
								case "ShowInfo":
								case "Hide":
								case "AutoKit":
								case "Sale":
								{
									bool result;
									if (value == "delete")
										newValue = default(bool);
									else if (bool.TryParse(value, out result)) newValue = result;
									break;
								}
								case "Amount":
								case "Price":
								{
									int result;
									if (value == "delete")
										newValue = default(int);
									else if (int.TryParse(value, out result))
										newValue = result;
									break;
								}
								case "Cooldown":
								case "CooldownAfterWipe":
								{
									double result;
									if (value == "delete")
										newValue = default(double);
									else if (double.TryParse(value, out result))
										newValue = result;
									break;
								}
								case "Description":
								case "DisplayName":
								{
									newValue = value == "delete" ? string.Empty : string.Join(" ", arg.Args.Skip(5));
									break;
								}
								default:
								{
									newValue = value == "delete" ? string.Empty : value;
									break;
								}
							}

							if (_kitEditing[player.userID][key] != null &&
							    _kitEditing[player.userID][key].Equals(newValue))
								return;

							_kitEditing[player.userID][key] = newValue;
						}
					}

					EditingKitUi(player, page, creating, kitId);
					break;
				}

				case "takeitem":
				{
					if (!IsAdmin(player)) return;

					int page, kitId, slot;
					if (!arg.HasArgs(6) ||
					    !_itemEditing.ContainsKey(player.userID) ||
					    !int.TryParse(arg.Args[1], out page) ||
					    !int.TryParse(arg.Args[3], out kitId) ||
					    !int.TryParse(arg.Args[4], out slot))
						return;

					var container = arg.Args[2];

					_itemEditing[player.userID]["ShortName"] = arg.Args[5];
					_itemEditing[player.userID]["SkinID"] = 0UL;

					EditingItemUi(player, page, kitId, slot, container);
					break;
				}

				case "selectitem":
				{
					if (!IsAdmin(player)) return;

					int kitId, slot;
					if (!arg.HasArgs(4) ||
					    !_itemEditing.ContainsKey(player.userID) ||
					    !int.TryParse(arg.Args[2], out kitId) ||
					    !int.TryParse(arg.Args[3], out slot))
						return;

					var container = arg.Args[1];

					var selectedCategory = string.Empty;
					if (arg.HasArgs(5))
						selectedCategory = arg.Args[4];

					var page = 0;
					if (arg.HasArgs(6))
						int.TryParse(arg.Args[5], out page);

					var input = string.Empty;
					if (arg.HasArgs(7))
						input = string.Join(" ", arg.Args.Skip(6));

					SelectItem(player, kitId, slot, container, selectedCategory, page, input);
					break;
				}

				case "startedititem":
				{
					if (!IsAdmin(player)) return;

					int page, kitId, slot;
					if (!arg.HasArgs(5) ||
					    !int.TryParse(arg.Args[1], out page) ||
					    !int.TryParse(arg.Args[3], out kitId) ||
					    !int.TryParse(arg.Args[4], out slot)) return;

					var container = arg.Args[2];

					EditingItemUi(player, page, kitId, slot, container, true);
					break;
				}

				case "edititem":
				{
					if (!IsAdmin(player)) return;

					int page, kitId, slot;
					if (!arg.HasArgs(7) ||
					    !int.TryParse(arg.Args[1], out page) ||
					    !int.TryParse(arg.Args[3], out kitId) ||
					    !int.TryParse(arg.Args[4], out slot)) return;

					var container = arg.Args[2];

					var key = arg.Args[5];
					var value = arg.Args[6];

					if (_itemEditing.ContainsKey(player.userID) && _itemEditing[player.userID].ContainsKey(key))
					{
						object newValue = null;

						switch (key)
						{
							case "Type":
							{
								KitItemType type;
								if (value == "delete")
									newValue = default(KitItemType);
								else if (Enum.TryParse(value, out type))
									newValue = type;
								break;
							}
							cas
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху