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

FREE Battlepass : 1.37.20 1.37.20

Нет прав для скачивания
C#:
// #define TESTING

#if TESTING
using System.Diagnostics;
#endif
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Random = UnityEngine.Random;

#if CARBON
using Carbon.Base;
using Carbon.Modules;
#endif

namespace Oxide.Plugins;

[Info("Battlepass", "Mevent", "1.37.20")]
public class Battlepass : RustPlugin
{
	#region Fields

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

	private const string
		Layer = "UI.Battlepass",
		ModalLayer = "UI.Battlepass.Modal";

	private static Battlepass _instance;

	private bool _needUpdate;

	private Timer _updateMissions, _refreshCooldown;

	private bool _enabledImageLibrary;

#if CARBON
	private ImageDatabaseModule imageDatabase;
#endif

	private readonly Dictionary<int, ItemConf> _itemById = new();

	private readonly Dictionary<ulong, List<ItemConf>> _openedCaseItems = new();

	private List<GeneralMission> _generalMissions = new();

	private List<int> _privateMissions = new();

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

	private DateTime _nextTime;

	private readonly DateTime epoch = new(1970, 1, 1, 0, 0, 0);

	private enum MissionType
	{
		Gather,
		Kill,
		Craft,
		Look,
		Build,
		Upgrade,
		Fishing,
		LootCrate,
		Swipe,
		RaidableBases,
		RecycleItem,
		HackCrate,
		PurchaseFromNpc,
		ArcticBaseEvent,
		GasStationEvent,
		SputnikEvent,
		ShipwreckEvent,
		HarborEvent,
		JunkyardEvent,
		SatDishEvent,
		WaterEvent,
		AirEvent,
		PowerPlantEvent,
		ArmoredTrainEvent,
		ConvoyEvent,
		SurvivalArena,
		KillBoss
	}

	private class GeneralMission
	{
		public int ID;
		public MissionConfig Mission;

		public GeneralMission(int id, MissionConfig mission)
		{
			ID = id;
			Mission = mission;
		}

		public void Check(BasePlayer player, ref PlayerData data, MissionType type, Item item = null,
			BaseEntity entity = null,
			int targetGrade = 0, int itemAmount = -1,
			string mode = null,
			ItemDefinition definition = null)
		{
			if (Mission.Type != type || !_config.Missions.ContainsKey(ID)) return;

			data.Missions.TryAdd(ID, 0);

			if (data.Missions[ID] >= Mission.Amount) return;

			var missionAmount = GetMissionAmount(Mission, item, entity, targetGrade, itemAmount, mode, definition);
#if TESTING
			SayDebug($"[Check.{player.userID}] type: {type}, amount: {missionAmount}");
#endif

			data.Missions[ID] += missionAmount;

			if (data.Missions[ID] >= Mission.Amount)
			{
				CompleteMission(player, Mission);
				if (_config.ResetQuestAfterComplete) data.Missions[ID] = 0;
			}
		}
	}

	private enum ItemType
	{
		Item,
		Command,
		Plugin
	}

	#endregion

	#region Config

	private static Configuration _config;

	private class Configuration
	{
		[JsonProperty(PropertyName = "Command")]
		public string Command = "pass";

		[JsonProperty(PropertyName = "Commands for Missions page")]
		public string[] MissionsCommands = {"passmissions", "pmissions"};

		[JsonProperty(PropertyName = "Commands for Cases page")]
		public string[] CasesCommands = {"passcase"};

		[JsonProperty(PropertyName = "Commands for Inventory page")]
		public string[] InventoryCommands = {"passinv"};

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

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

		[JsonProperty(PropertyName = "Background")]
		public string Background = "https://i.ibb.co/0JbMVnV/image.png";

		[JsonProperty(PropertyName = "Logo")] public string Logo = "https://i.ibb.co/GMMWyB4/image.png";

		[JsonProperty(PropertyName = "Reset the quest after completing it?")]
		public bool ResetQuestAfterComplete = false;

		[JsonProperty(PropertyName = "Wipe Settings")]
		public WipeSettings Wipe = new()
		{
			Players = false,
			Missions = false
		};

		[JsonProperty(PropertyName = "Currency 1")]
		public FirstCurrencyClass FirstCurrency = new()
		{
			Image = "https://i.ibb.co/ThrdX3r/image.png",
			UseDefaultCur = true,
			AddHook = "Deposit",
			BalanceHook = "Balance",
			RemoveHook = "Withdraw",
			Plug = "Economics",
			Rates = new Dictionary<string, float>
			{
				["battlepass.vip"] = 2f,
				["battlepass.premium"] = 3f
			}
		};

		[JsonProperty(PropertyName = "Use 2nd currency?")]
		public bool useSecondCur = true;

		[JsonProperty(PropertyName = "Currency 2")]
		public SecondCurrencyClass SecondCurrency = new()
		{
			Permission = "battlepass.vip",
			Image = "https://i.ibb.co/gRbyTFW/image.png",
			UseDefaultCur = true,
			AddHook = "Deposit",
			BalanceHook = "Balance",
			RemoveHook = "Withdraw",
			Plug = "Economics"
		};

		[JsonProperty(PropertyName = "Image Top Awards")]
		public string AdvanceAwardImg = "https://i.ibb.co/4jcqqhf/image.png";

		[JsonProperty(PropertyName = "Background for cases")]
		public string CaseBG = "https://i.ibb.co/kg8tR4K/image.png";

		[JsonProperty(PropertyName = "Cases", ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public List<CaseClass> Cases = new()
		{
			new()
			{
				DisplayName = "Newbie Case",
				Permission = "",
				Image = "https://i.ibb.co/chhtKTK/9KIoJ2G.png",
				FCost = 150,
				PCost = 75,
				Items = new List<ItemConf>
				{
					new() { Title = "Wood", Chance = 80, Type = ItemType.Item, Shortname = "wood", Amount = 1000 },
					new() { Title = "Stones", Chance = 75, Type = ItemType.Item, Shortname = "stones", Amount = 1500 },
					new() { Title = "Bandage", Chance = 70, Type = ItemType.Item, Shortname = "bandage", Amount = 5 },
					new() { Title = "Pistol", Chance = 50, Type = ItemType.Item, Shortname = "pistol.revolver", Amount = 1 },
					new() { Title = "Low Grade Fuel", Chance = 40, Type = ItemType.Item, Shortname = "lowgradefuel", Amount = 50 },
					new() { Title = "Hunting Bow", Chance = 30, Type = ItemType.Item, Shortname = "bow.hunting", Amount = 1 },
					new() { Title = "Leather Gloves", Chance = 25, Type = ItemType.Item, Shortname = "gloves.leather", Amount = 1 }
				}
			},
			new()
			{
				DisplayName = "Amateur Case",
				Permission = "battlepass.use",
				Image = "https://i.ibb.co/9yMhCrR/5bur68a.png",
				FCost = 500,
				PCost = 250,
				Items = new List<ItemConf>
				{
					new() { Title = "Metal Fragments", Chance = 75, Type = ItemType.Item, Shortname = "metal.fragments", Amount = 500 },
					new() { Title = "SMG", Chance = 60, Type = ItemType.Item, Shortname = "smg.thompson", Amount = 1 },
					new() { Title = "Medical Syringe", Chance = 55, Type = ItemType.Item, Shortname = "syringe.medical", Amount = 2 },
					new() { Title = "Road Sign Jacket", Chance = 50, Type = ItemType.Item, Shortname = "jacket.roadsign", Amount = 1 },
					new() { Title = "Gunpowder", Chance = 45, Type = ItemType.Item, Shortname = "gunpowder", Amount = 250 },
					new() { Title = "Crossbow", Chance = 40, Type = ItemType.Item, Shortname = "crossbow", Amount = 1 },
					new() { Title = "Tactical Gloves", Chance = 35, Type = ItemType.Item, Shortname = "gloves.tactical", Amount = 1 }
				}
			},
			new()
			{
				DisplayName = "Professional Case",
				Permission = "battlepass.use",
				Image = "https://i.ibb.co/4Y4K8vm/kZyZqy9.png",
				FCost = 1000,
				PCost = 500,
				Items = new List<ItemConf>
				{
					new() { Title = "Sulfur", Chance = 70, Type = ItemType.Item, Shortname = "sulfur.ore", Amount = 1000 },
					new() { Title = "Assault Rifle", Chance = 60, Type = ItemType.Item, Shortname = "rifle.ak", Amount = 1 },
					new() { Title = "Metal Facemask", Chance = 55, Type = ItemType.Item, Shortname = "mask.metal", Amount = 1 },
					new() { Title = "Explosives", Chance = 50, Type = ItemType.Item, Shortname = "explosives", Amount = 2 },
					new() { Title = "Rocket", Chance = 45, Type = ItemType.Item, Shortname = "ammo.rocket.basic", Amount = 1 },
					new() { Title = "L96 Sniper", Chance = 40, Type = ItemType.Item, Shortname = "rifle.l96", Amount = 1 },
					new() { Title = "HV Rocket", Chance = 35, Type = ItemType.Item, Shortname = "ammo.rocket.hv", Amount = 1 }
				}
			},
			new()
			{
				DisplayName = "Master Case",
				Permission = "battlepass.use",
				Image = "https://i.ibb.co/FBpxMmK/NvHk5Sw.png",
				FCost = 1500,
				PCost = 750,
				Items = new List<ItemConf>
				{
					new() { Title = "High Quality Metal", Chance = 65, Type = ItemType.Item, Shortname = "metal.refined", Amount = 50 },
					new() { Title = "M249", Chance = 55, Type = ItemType.Item, Shortname = "lmg.m249", Amount = 1 },
					new() { Title = "Armored Door", Chance = 50, Type = ItemType.Item, Shortname = "door.hinged.metal", Amount = 1 },
					new() { Title = "C4", Chance = 45, Type = ItemType.Item, Shortname = "explosive.timed", Amount = 1 },
					new() { Title = "Rocket Launcher", Chance = 40, Type = ItemType.Item, Shortname = "rocket.launcher", Amount = 1 },
					new() { Title = "Incendiary Rocket", Chance = 35, Type = ItemType.Item, Shortname = "ammo.rocket.incendiary", Amount = 2 },
					new() { Title = "Auto Turret", Chance = 30, Type = ItemType.Item, Shortname = "autoturret", Amount = 1 }
				}
			},
			new()
			{
				DisplayName = "Legendary Case",
				Permission = "battlepass.use",
				Image = "https://i.ibb.co/XLPg66N/3mtbqji.png",
				FCost = 2000,
				PCost = 1000,
				Items = new List<ItemConf>
				{
					new() { Title = "Elite Crate", Chance = 60, Type = ItemType.Item, Shortname = "crate_elite", Amount = 1 },
					new() { Title = "Military Crate", Chance = 55, Type = ItemType.Item, Shortname = "crate_military", Amount = 1 },
					new() { Title = "MLRS Rocket", Chance = 50, Type = ItemType.Item, Shortname = "ammo.rocket.mlrs", Amount = 2 },
					new() { Title = "Sam Site", Chance = 45, Type = ItemType.Item, Shortname = "samsite", Amount = 1 },
					new() { Title = "Attack Helicopter", Chance = 40, Type = ItemType.Item, Shortname = "minihelicopter.repair", Amount = 1 },
					new() { Title = "Tank", Chance = 35, Type = ItemType.Item, Shortname = "car.tank", Amount = 1 },
					new() { Title = "M2 Bradley APC", Chance = 25, Type = ItemType.Item, Shortname = "bradleyapc", Amount = 1 }
				}
			},
			new()
			{
				DisplayName = "Pirate Treasure",
				Permission = "battlepass.vip",
				Image = "https://i.ibb.co/M2bNGcM/tsPPUhg.png",
				FCost = 3000,
				PCost = 1500,
				Items = new List<ItemConf>
				{
					new() { Title = "Golden Revolver", Chance = 50, Type = ItemType.Item, Shortname = "pistol.python", Skin = 123456789, Amount = 1 },
					new() { Title = "Treasure Map", Chance = 45, Type = ItemType.Item, Shortname = "map", Skin = 987654321, Amount = 1 },
					new() { Title = "Ancient Coin", Chance = 40, Type = ItemType.Item, Shortname = "coin", Skin = 555555555, Amount = 5 },
					new() { Title = "Pirate Cutlass", Chance = 35, Type = ItemType.Item, Shortname = "longsword", Skin = 111222333, Amount = 1 },
					new() { Title = "Cannon Shells", Chance = 30, Type = ItemType.Item, Shortname = "ammo.shotgun.slug", Amount = 25 },
					new() { Title = "Rum Barrel", Chance = 25, Type = ItemType.Item, Shortname = "water.barrel", Skin = 444555666, Amount = 1 },
					new() { Title = "Captain's Hat", Chance = 20, Type = ItemType.Item, Shortname = "hat.captain", Skin = 777888999, Amount = 1 }
				}
			}
		};

		[JsonProperty(PropertyName = "Total missions per day")]
		public int MissionsCount = 7;

		[JsonProperty(PropertyName =
			"How many hours are missions updated?")]
		public int MissionHours = 24;

		[JsonProperty(PropertyName = "Settings shared missions",
			ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public Dictionary<int, MissionConfig> Missions = new()
		{
			[1] = MissionConfig.CreateDefault(MissionType.Gather, "stones", "Collect 5000 stones", 5000, 50,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[2] = MissionConfig.CreateDefault(MissionType.Kill, "player", "Kill 3 players", 3, 90,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[3] = MissionConfig.CreateDefault(MissionType.Craft, "ammo.rocket.basic", "Craft 15 rockets", 15, 75,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[4] = MissionConfig.CreateDefault(MissionType.Look, "metalspring", "Loot 10 metal springs", 10, 50,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[5] = MissionConfig.CreateDefault(MissionType.Build, "wall.external.high.stone",
				"Build 25 high exterior stone walls to protect your home", 25, 100),

			[6] = MissionConfig.CreateDefault(MissionType.Upgrade, "foundation.prefab",
				"Upgrade 10 Foundations to Metal", 10, 60,
				grade: 3),

			[7] = MissionConfig.CreateDefault(MissionType.Gather, "wood", "Collect 10000 wood", 10000, 50,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[8] = MissionConfig.CreateDefault(MissionType.Craft, "door.hinged.toptier", "Craft 3 Armored Doors", 3,
				85,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[9] = MissionConfig.CreateDefault(MissionType.Fishing, "fish.herring", "Catch 10 herring", 10, 50,
				useSecondAward: true, secondAward: 25),

			[10] = MissionConfig.CreateDefault(MissionType.Swipe, "keycard_blue",
				"Swipe the Blue Keycard on monuments 10 times", 10, 50, useSecondAward: true, secondAward: 25),

			[11] = MissionConfig.CreateDefault(MissionType.RaidableBases, string.Empty,
				"Win the RaidableBases event 3 times", 3, 75,
				raidMode: "Easy"),

			[12] = MissionConfig.CreateDefault(MissionType.RecycleItem, "riflebody", "Recycle 15 Rifle Body", 15,
				50),

			[13] = MissionConfig.CreateDefault(MissionType.HackCrate, "codelockedhackablecrate",
				"Hack 3 locked crates", 3, 50),

			[14] = MissionConfig.CreateDefault(MissionType.PurchaseFromNpc, "scrap", "Buy 1000 scrap from bots",
				1000, 50),

			[15] = MissionConfig.CreateDefault(MissionType.ArcticBaseEvent, string.Empty,
				"Win the \"Artic Base Event\" 3 times", 3, 100, enabled: false),
			[16] = MissionConfig.CreateDefault(MissionType.GasStationEvent, string.Empty,
				"Win the \"GasStation Event\" 3 times", 3, 100, enabled: false),
			[17] = MissionConfig.CreateDefault(MissionType.SputnikEvent, string.Empty,
				"Win the \"Sputnik Event\" 3 times", 3, 100, enabled: false),
			[18] = MissionConfig.CreateDefault(MissionType.ShipwreckEvent, string.Empty,
				"Win the \"Shipwreck Event\" 3 times", 3, 100, enabled: false),
			[19] = MissionConfig.CreateDefault(MissionType.HarborEvent, string.Empty,
				"Win the \"Harbor Event\" 3 times", 3, 100, enabled: false),
			[20] = MissionConfig.CreateDefault(MissionType.JunkyardEvent, string.Empty,
				"Win the \"Junkyard Event\" 3 times", 3, 100, enabled: false),
			[21] = MissionConfig.CreateDefault(MissionType.SatDishEvent, string.Empty,
				"Win the \"Sat Dish Event\" 3 times", 3, 100, enabled: false),
			[22] = MissionConfig.CreateDefault(MissionType.WaterEvent, string.Empty,
				"Win the \"Water Event\" 3 times", 3, 100, enabled: false),
			[23] = MissionConfig.CreateDefault(MissionType.AirEvent, string.Empty,
				"Win the \"Air Event\" 3 times", 3, 100, enabled: false),
			[24] = MissionConfig.CreateDefault(MissionType.PowerPlantEvent, string.Empty,
				"Win the \"Power Plant Event\" 3 times", 3, 100, enabled: false),
			[25] = MissionConfig.CreateDefault(MissionType.ArmoredTrainEvent, string.Empty,
				"Win the \"Armored Train Event\" 3 times", 3, 100, enabled: false),
			[26] = MissionConfig.CreateDefault(MissionType.ConvoyEvent, string.Empty,
				"Win the \"Convoy Event\" 3 times", 3, 100, enabled: false),
			[27] = MissionConfig.CreateDefault(MissionType.SurvivalArena, string.Empty,
				"Win the \"Survival Arena\" 3 times", 3, 100, enabled: false),
			[28] = MissionConfig.CreateDefault(MissionType.KillBoss, string.Empty,
				"Kill the boss 5 times", 5, 75, enabled: false)
		};

		[JsonProperty(PropertyName = "Settings challenge of the day",
			ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public Dictionary<int, MissionConfig> PrivateMissions = new()
		{
			[1] = MissionConfig.CreateDefault(MissionType.Gather, "stones", "Collect 5000 stones", 5000, 50,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[2] = MissionConfig.CreateDefault(MissionType.Kill, "player", "Kill 3 players", 3, 90,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[3] = MissionConfig.CreateDefault(MissionType.Craft, "ammo.rocket.basic", "Craft 15 rockets", 15, 75,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[4] = MissionConfig.CreateDefault(MissionType.Look, "metalspring", "Loot 10 metal springs", 10, 50,
				useAdvanceAward: true,
				advanceAward: ItemConf.CreateItem(1031, "rifle.ak", 1, 1230963555, "Talon AK-47")),

			[5] = MissionConfig.CreateDefault(MissionType.Build, "wall.external.high.stone",
				"Build 25 high exterior stone walls to protect your home", 25, 100),

			[6] = MissionConfig.CreateDefault(MissionType.Upgrade, "foundation.prefab",
				"Upgrade 10 Foundations to Metal", 10, 60,
				grade: 3)
		};

		[JsonProperty(PropertyName = "Enable logging to the console?")]
		public bool LogToConsole = true;

		[JsonProperty(PropertyName = "Enable logging to the file?")]
		public bool LogToFile = true;

		[JsonProperty(PropertyName = "PlayerDatabase")]
		public PlayerDatabaseConf PlayerDatabase = new(false, "Battlepass");

		[JsonProperty(PropertyName = "Loot Settings (for storage containers)")]
		public LootSettings StorageLoot = new()
		{
			Enabled = true,
			Containers = new Dictionary<string, List<ulong>>
			{
				["box.wooden.large"] = new()
				{
					2764183607,
					624269671
				},
				["stocking_small_deployed"] = new()
				{
					0
				}
			}
		};

		[JsonProperty(PropertyName = "Cooldown After Wipe (0 - disable)")]
		public CooldownSettings WipeCooldown = new()
		{
			Inventory = 0
		};

		[JsonProperty(PropertyName = "Give out case items immediately to the player?")]
		public bool CaseItemsToPlayer = false;

		[JsonProperty(PropertyName = "Give an advance reward to the player's inventory?")]
		public bool AdRewardToInventory = false;

		[JsonProperty(PropertyName = "Notify the player when a mission is completed?")]
		public bool NotifyMissionCompleted = true;

		[JsonProperty(PropertyName = "Block (NoEscape)")]
		public bool BlockNoEscape = false;

		[JsonProperty(PropertyName = "Interface")]
		public UserInterface UI = new()
		{
			Header = new UserInterface.HeaderInfo(),
			Colors = new UserInterface.ColorsData(),
			Missions = new UserInterface.MissionsScreen(),
			Cases = new UserInterface.CasesScreen(),
			CaseInfo = new UserInterface.CasesInfoScreen(),
			Inventory = new UserInterface.InventoryScreen()
		};

		[JsonProperty(PropertyName = "Tabs")] public TabsSettings Tabs = new()
		{
			Margin = 0f,
			Missions = new TabInterface(true, 0, 256f, 256f,
				"https://i.ibb.co/C0jjqLB/f2GN8m7.png",
				new UserInterface.InterfacePosition
				{
					AnchorMin = "0.5 0.5",
					AnchorMax = "0.5 0.5",
					OffsetMin = "-105 -75",
					OffsetMax = "105 135"
				},
				new UserInterface.Button
				{
					AnchorMin = "0.5 0",
					AnchorMax = "0.5 0",
					OffsetMin = "-105 5",
					OffsetMax = "105 35",
					Align = TextAnchor.MiddleCenter,
					FontSize = 16,
					Font = "robotocondensed-bold.ttf",
					ButtonColor = new UserInterface.ColorsData.IColor("#000000",
						00),
					Color = "1 1 1 1",
					FadeIn = 0
				},
				"Mission btn",
				"UI_Battlepass missions",
				false),
			Cases = new TabInterface(true, 1, 256f, 256f,
				"https://i.ibb.co/HtFh68D/2lMM2bS.png",
				new UserInterface.InterfacePosition
				{
					AnchorMin = "0.5 0.5",
					AnchorMax = "0.5 0.5",
					OffsetMin = "-105 -75",
					OffsetMax = "105 135"
				},
				new UserInterface.Button
				{
					AnchorMin = "0.5 0",
					AnchorMax = "0.5 0",
					OffsetMin = "-105 5",
					OffsetMax = "105 35",
					Align = TextAnchor.MiddleCenter,
					Color = "1 1 1 1",
					FadeIn = 0,
					FontSize = 16,
					Font = "robotocondensed-bold.ttf",
					ButtonColor = new UserInterface.ColorsData.IColor("#000000",
						00)
				},
				"Cases btn",
				"UI_Battlepass cases",
				false),
			Inventory = new TabInterface(true, 2, 256f, 256f,
				"https://i.ibb.co/KLMwgHj/vvJe7KO.png",
				new UserInterface.InterfacePosition
				{
					AnchorMin = "0.5 0.5",
					AnchorMax = "0.5 0.5",
					OffsetMin = "-105 -75",
					OffsetMax = "105 135"
				},
				new UserInterface.Button
				{
					AnchorMin = "0.5 0",
					AnchorMax = "0.5 0",
					OffsetMin = "-105 5",
					OffsetMax = "105 35",
					Align = TextAnchor.MiddleCenter,
					Color = "1 1 1 1",
					FadeIn = 0,
					FontSize = 16,
					Font = "robotocondensed-bold.ttf",
					ButtonColor = new UserInterface.ColorsData.IColor("#000000",
						00)
				},
				"Inventory btn",
				"UI_Battlepass inventory",
				false),
			CustomTabs = new List<TabInterface>
			{
				new(false, 3, 256f, 256f,
					"https://i.ibb.co/xDsVSXY/C83Rprq.png",
					new UserInterface.InterfacePosition
					{
						AnchorMin = "0.5 0.5",
						AnchorMax = "0.5 0.5",
						OffsetMin = "-105 -75",
						OffsetMax = "105 135"
					},
					new UserInterface.Button
					{
						AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-105 5", OffsetMax = "105 35",
						Align = TextAnchor.MiddleCenter,
						FontSize = 16,
						ButtonColor = new UserInterface.ColorsData.IColor("#000000", 00)
					},
					"Leaders",
					"leaders",
					true)
			}
		};

		public VersionNumber Version;
	}

	private class TabsSettings
	{
		[JsonProperty(PropertyName = "Margin")]
		public float Margin;

		[JsonProperty(PropertyName = "Missions")]
		public TabInterface Missions;

		[JsonProperty(PropertyName = "Cases")] public TabInterface Cases;

		[JsonProperty(PropertyName = "Inventory")]
		public TabInterface Inventory;

		[JsonProperty(PropertyName = "Custom Tabs", ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public List<TabInterface> CustomTabs;

		[JsonIgnore] private List<TabInterface> _tabsList;

		[JsonIgnore] public List<TabInterface> Tabs => _tabsList ?? (_tabsList = GetTabs());

		private List<TabInterface> GetTabs()
		{
			var list = new List<TabInterface>
			{
				Missions,
				Cases,
				Inventory
			};

			list.AddRange(CustomTabs);

			list.Sort((x, y) => x.Index.CompareTo(y.Index));

			return list;
		}
	}

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

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

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

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

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

		[JsonProperty(PropertyName = "Image Position")]
		public UserInterface.InterfacePosition ImagePosition;

		[JsonProperty(PropertyName = "Button")]
		public UserInterface.Button Button;

		[JsonProperty(PropertyName = "Lang Key")]
		public string LangKey;

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

		[JsonProperty(PropertyName = "Close Menu")]
		public bool CloseMenu;

		public TabInterface(bool enabled, int index, float width, float height, string image,
			UserInterface.InterfacePosition imagePosition, UserInterface.Button button,
			string langKey,
			string command,
			bool closeMenu)
		{
			Enabled = enabled;
			Index = index;
			Width = width;
			Height = height;
			Image = image;
			ImagePosition = imagePosition;
			Button = button;
			LangKey = langKey;
			Command = command;
			CloseMenu = closeMenu;
		}
	}

	private class WipeSettings
	{
		[JsonProperty(PropertyName = "Wipe Players?")]
		public bool Players;

		[JsonProperty(PropertyName = "Wipe Missions?")]
		public bool Missions;
	}

	private class UserInterface
	{
		[JsonProperty(PropertyName = "Header")]
		public HeaderInfo Header;

		[JsonProperty(PropertyName = "Colors")]
		public ColorsData Colors;

		[JsonProperty(PropertyName = "Missions")]
		public MissionsScreen Missions;

		[JsonProperty(PropertyName = "Cases")] public CasesScreen Cases;

		[JsonProperty(PropertyName = "Case Page")]
		public CasesInfoScreen CaseInfo;

		[JsonProperty(PropertyName = "Inventory")]
		public InventoryScreen Inventory;

		public class InterfacePosition
		{
			public string AnchorMin;

			public string AnchorMax;

			public string OffsetMin;

			public string OffsetMax;
		}

		public class Label : InterfacePosition
		{
			[JsonProperty("FontSize")] public int FontSize = 14;

			[JsonProperty("Font")] public string Font = "robotocondensed-bold.ttf";

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

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

			[JsonProperty("FadeIn")] public float FadeIn;
		}

		public class Button : Label
		{
			[JsonProperty(PropertyName = "Button Color")]
			public ColorsData.IColor ButtonColor;
		}

		public class OutlineInfo
		{
			[JsonProperty(PropertyName = "Color")] public ColorsData.IColor Color = new("#FFFFFF");

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

		public class ColorsData
		{
			[JsonProperty(PropertyName = "Background Color")]
			public IColor BackgroundColor = new("#FFFFFF");

			[JsonProperty(PropertyName = "Color 1")]
			public IColor Color1 = new("#E54D41");

			[JsonProperty(PropertyName = "Color 2")]
			public IColor Color2 = new("#BF2E24");

			[JsonProperty(PropertyName = "Color 3")]
			public IColor Color3 = new("#BD5C22");

			[JsonProperty(PropertyName = "Color 4")]
			public IColor Color4 = new("#BD5C22", 40);

			[JsonProperty(PropertyName = "Color 5")]
			public IColor Color5 = new("#000000", 00);

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

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

				[JsonIgnore] private string _color;

				[JsonIgnore]
				public string Get
				{
					get
					{
						if (string.IsNullOrEmpty(_color))
							_color = GetColor();

						return _color;
					}
				}

				private string GetColor()
				{
					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()
				{
				}

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

		public class HeaderInfo
		{
			[JsonProperty(PropertyName = "Height")]
			public float Height = 35f;

			[JsonProperty(PropertyName = "Logo Position")]
			public InterfacePosition Logo = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-350 -9",
				OffsetMax = "-250 9"
			};

			[JsonProperty(PropertyName = "Line")] public InterfacePosition Line = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-240.5 -9",
				OffsetMax = "-239.5 9"
			};

			[JsonProperty(PropertyName = "Player Name")]
			public InterfacePosition PlayerName = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-230 -9",
				OffsetMax = "80 9"
			};

			[JsonProperty(PropertyName = "First Currency")]
			public InterfacePosition FirstCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "230 -10",
				OffsetMax = "250 10"
			};

			[JsonProperty(PropertyName = "Balance of First Currency")]
			public Label BalanceFirstCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "0 -10",
				OffsetMax = "225 10",
				FontSize = 12,
				Align = TextAnchor.MiddleRight,
				Color = "1 1 1 1",
				FadeIn = 0,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Second Currency")]
			public InterfacePosition SecondCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "315 -10",
				OffsetMax = "335 10"
			};

			[JsonProperty(PropertyName = "Balance of Second Currency")]
			public Label BalanceSecondCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "0 -10",
				OffsetMax = "310 10",
				FontSize = 12,
				Align = TextAnchor.MiddleRight,
				Color = "1 1 1 1",
				FadeIn = 0,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Exit Button")]
			public Button Exit = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "200 295",
				OffsetMax = "320 315",
				Align = TextAnchor.MiddleRight,
				Color = "1 1 1 1",
				FadeIn = 0,
				FontSize = 16,
				Font = "robotocondensed-bold.ttf",
				ButtonColor = new ColorsData.IColor("#000000",
					00)
			};
		}

		public class MissionsScreen
		{
			[JsonProperty(PropertyName = "Back")] public Button Back = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "200 295",
				OffsetMax = "320 315",
				Align = TextAnchor.MiddleRight, FontSize = 16,
				ButtonColor = new ColorsData.IColor("#000000", 00)
			};

			[JsonProperty(PropertyName = "Private Mission | Progress Bar")]
			public InterfacePosition ProgressBar = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 230",
				OffsetMax = "-15 235"
			};

			[JsonProperty(PropertyName = "Private Mission | Progress Title")]
			public Label ProgressTitle = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 240",
				OffsetMax = "0 255",
				Align = TextAnchor.MiddleLeft,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | Progress Amount")]
			public Label ProgressAmount = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 240",
				OffsetMax = "-15 255",
				Align = TextAnchor.MiddleRight,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | Title")]
			public Label PMTitle = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 260",
				OffsetMax = "0 290",
				Align = TextAnchor.MiddleLeft,
				FontSize = 16
			};

			[JsonProperty(PropertyName = "Private Mission | Title Description")]
			public Label PMTitleDescription = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "15 260",
				OffsetMax = "320 290",
				Align = TextAnchor.MiddleLeft,
				FontSize = 16
			};

			[JsonProperty(PropertyName = "Private Mission | Description")]
			public Label PMDescription = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "15 200",
				OffsetMax = "325 255",
				Align = TextAnchor.UpperLeft,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | Title Award")]
			public Label PMTitleAward = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "15 195",
				OffsetMax = "150 215",
				Align = TextAnchor.MiddleLeft,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | First Currency Image")]
			public InterfacePosition FirstCurrencyImage = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "85 195",
				OffsetMax = "105 215"
			};

			[JsonProperty(PropertyName = "Private Mission | First Currency")]
			public Label FirstCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "55 195",
				OffsetMax = "80 215",
				Align = TextAnchor.MiddleRight,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | Second Currency Image")]
			public InterfacePosition SecondCurrencyImage = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "135 195",
				OffsetMax = "155 215"
			};

			[JsonProperty(PropertyName = "Private Mission | Second Currency")]
			public Label SecondCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "100 195",
				OffsetMax = "130 215",
				Align = TextAnchor.MiddleRight,
				FontSize = 11,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Private Mission | Line")]
			public InterfacePosition Line1 = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-335 164.5",
				OffsetMax = "325 165.5"
			};

			[JsonProperty(PropertyName = "Title")] public Label Title = new()
			{
				AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-320 95", OffsetMax = "0 165",
				Align = TextAnchor.MiddleLeft,
				FontSize = 14
			};

			[JsonProperty(PropertyName = "Cooldown")]
			public Label Cooldown = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-150 95",
				OffsetMax = "150 165",
				Align = TextAnchor.MiddleCenter,
				FontSize = 14,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "Background for missions")]
			public InterfacePosition Background = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-355 55",
				OffsetMax = "310 55"
			};

			[JsonProperty(PropertyName = "Pages")] public InterfacePosition Pages = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "315 -115",
				OffsetMax = "325 95"
			};
		}

		public class CasesScreen
		{
			[JsonProperty(PropertyName = "Back")] public Button Back = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "200 295",
				OffsetMax = "320 315",
				Align = TextAnchor.MiddleRight, FontSize = 16,
				ButtonColor = new ColorsData.IColor("#000000", 00)
			};

			[JsonProperty(PropertyName = "Title")] public Label Title = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 250",
				OffsetMax = "0 290",
				Align = TextAnchor.MiddleLeft,
				FontSize = 26
			};

			[JsonProperty(PropertyName = "Up Indent for cases")]
			public float CaseUpIdent = 335;

			[JsonProperty(PropertyName = "Left Indent for cases")]
			public float CaseLeftIdent = 40;

			[JsonProperty(PropertyName = "Case Height")]
			public float CaseHeight = 195f;

			[JsonProperty(PropertyName = "Case Width")]
			public float CaseWidth = 205f;

			[JsonProperty(PropertyName = "Cases Margin")]
			public float CaseMargin = 10f;

			[JsonProperty(PropertyName = "Case Image")]
			public InterfacePosition CaseImage = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-70 -65",
				OffsetMax = "70 75"
			};

			[JsonProperty(PropertyName = "Case Look Button")]
			public Button CaseShow = new()
			{
				AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-58 15", OffsetMax = "58 35",
				Align = TextAnchor.MiddleCenter,
				FontSize = 12,
				ButtonColor = new ColorsData.IColor("#000000", 00)
			};
		}

		public class CasesInfoScreen
		{
			[JsonProperty(PropertyName = "Amount Awards On Page")]
			public int AwardsOnPage = 10;

			[JsonProperty(PropertyName = "Back")] public Button Back = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "200 295",
				OffsetMax = "320 315",
				Align = TextAnchor.MiddleRight, FontSize = 16,
				ButtonColor = new ColorsData.IColor("#000000", 00)
			};

			[JsonProperty(PropertyName = "Title")] public Label Title = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 250",
				OffsetMax = "0 290",
				Align = TextAnchor.MiddleLeft,
				FontSize = 26
			};

			[JsonProperty(PropertyName = "Case Title")]
			public Label CaseTitle = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 200",
				OffsetMax = "0 250",
				Align = TextAnchor.MiddleLeft, FontSize = 18
			};

			[JsonProperty(PropertyName = "Case Image")]
			public InterfacePosition CaseImage = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-290 5",
				OffsetMax = "-110 185"
			};

			[JsonProperty(PropertyName = "Buy Amount")]
			public Label BuyAmount = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-310 -25",
				OffsetMax = "-110 -5",
				Align = TextAnchor.MiddleLeft,
				FontSize = 12,
				Font = "robotocondensed-regular.ttf"
			};

			[JsonProperty(PropertyName = "First Currency")]
			public InterfacePosition FirstCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-210 -30",
				OffsetMax = "-135 0"
			};

			[JsonProperty(PropertyName = "Second Currency")]
			public InterfacePosition SecondCurrency = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-130 -30",
				OffsetMax = "-55 0"
			};

			[JsonProperty(PropertyName = "Awards Title")]
			public Label AwardsTitle = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "70 200",
				OffsetMax = "270 250",
				Align = TextAnchor.MiddleLeft,
				FontSize = 18
			};

			[JsonProperty(PropertyName = "Awards Background")]
			public InterfacePosition AwardsBackground = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "70 -70",
				OffsetMax = "320 195"
			};

			[JsonProperty(PropertyName = "Open Button")]
			public Button OpenButton = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-205 -75",
				OffsetMax = "-50 -50",
				Align = TextAnchor.MiddleCenter,
				FontSize = 12,
				ButtonColor = new ColorsData.IColor("#000000", 00)
			};

			[JsonProperty(PropertyName = "Open Button | Outline")]
			public OutlineInfo OpenButtonOutline = new()
			{
				Color = new ColorsData.IColor("#FFFFFF"),
				Size = "1"
			};

			[JsonProperty(PropertyName = "Enter Amount")]
			public InterfacePosition EnterAmount = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-235 -75",
				OffsetMax = "-210 -50"
			};
		}

		public class InventoryScreen
		{
			[JsonProperty(PropertyName = "Item Size")]
			public int ItemSize = 80;

			[JsonProperty(PropertyName = "Items Margin")]
			public int Margin = 5;

			[JsonProperty(PropertyName = "Items On String")]
			public int ItemsOnString = 8;

			[JsonProperty(PropertyName = "Lines for items")]
			public int Lines = 6;

			[JsonIgnore] public int MaxCount => _config.UI.Inventory.Lines * _config.UI.Inventory.ItemsOnString;

			[JsonProperty(PropertyName = "Back")] public Label Back = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "200 295",
				OffsetMax = "320 315",
				Align = TextAnchor.MiddleRight, FontSize = 16
			};

			[JsonProperty(PropertyName = "Title")] public Label Title = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-320 250",
				OffsetMax = "0 290",
				Align = TextAnchor.MiddleLeft,
				FontSize = 26
			};

			[JsonProperty(PropertyName = "Pages")] public InterfacePosition Pages = new()
			{
				AnchorMin = "0.5 0.5",
				AnchorMax = "0.5 0.5",
				OffsetMin = "-335 -275",
				OffsetMax = "340 -260"
			};
		}
	}


	private class CooldownSettings
	{
		[JsonProperty(PropertyName = "Inventory")]
		public float Inventory;
	}

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

		[JsonProperty(PropertyName = "Containers (shortname - skins) [skin 0 = all skins]",
			ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public Dictionary<string, List<ulong>> Containers;
	}

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

		[JsonProperty(PropertyName = "Table")] public string Field;

		public PlayerDatabaseConf(bool enabled, string field)
		{
			Enabled = enabled;
			Field = field;
		}
	}

	private class CurrencyClass
	{
		[JsonProperty(PropertyName = "Image")] public string Image;

		[JsonProperty(PropertyName = "Use embedded system?")]
		public bool UseDefaultCur;

		[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;
	}

	private class FirstCurrencyClass : CurrencyClass
	{
		[JsonProperty(PropertyName = "Rates for permissions",
			ObjectCreationHandling = ObjectCreationHandling.Replace)]
		public Dictionary<string, float> Rates;

		public double ShowBalance(BasePlayer player)
		{
			if (UseDefaultCur) return _instance.GetFirstCurrency(player.userID);

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

			return Math.Round(Convert.ToDouble(plugin.Call(BalanceHook, player.UserIDString)));
		}

		public void AddBalance(BasePlayer player, int amount)
		{
			AddBalance(player.UserIDString, amount);
		}

		public void AddBalance(string player, int amount)
		{
			if (UseDefaultCur)
			{
				_instance.AddFirstCurrency(player, amount);
				return;
			}

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

			switch (Plug)
			{
				case "Economics":
					plugin.Call(AddHook, player, (double) amount);
					break;
				default:
					plugin.Call(AddHook, player, amount);
					break;
			}
		}

		public bool RemoveBalance(BasePlayer player, int amount)
		{
			if (ShowBalance(player) < amount) return false;

			if (UseDefaultCur) return _instance.RemoveFirstCurrency(player, amount);

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

			switch (Plug)
			{
				case "Economics":
					plugin.Call(RemoveHook, player.UserIDString, (double) amount);
					break;
				default:
					plugin.Call(RemoveHook, player.UserIDString, amount);
					break;
			}

			return true;
		}
	}

	private class SecondCurrencyClass : CurrencyClass
	{
		[JsonProperty(PropertyName = "Permission (empty - all)")]
		public string Permission;

		public double ShowBalance(BasePlayer player)
		{
			if (UseDefaultCur) return _instance.GetSecondCurrency(player.userID);

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

			return Math.Round(Convert.ToDouble(plugin.Call(BalanceHook, player.UserIDString)));
		}

		public void AddBalance(BasePlayer player, int amount)
		{
			AddBalance(player.UserIDString, amount);
		}

		public void AddBalance(string player, int amount)
		{
			if (UseDefaultCur)
			{
				_instance.AddSecondCurrency(player, amount);
				return;
			}

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

			switch (Plug)
			{
				case "Economics":
					plugin.Call(AddHook, player, (double) amount);
					break;
				default:
					plugin.Call(AddHook, player, amount);
					break;
			}
		}

		public bool RemoveBalance(BasePlayer player, int amount)
		{
			if (ShowBalance(player) < amount) return false;

			if (UseDefaultCur) return _instance.RemoveSecondCurrency(player, amount);

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

			switch (Plug)
			{
				case "Economics":
					plugin.Call(RemoveHook, player.UserIDString, (double) amount);
					break;
				default:
					plugin.Call(RemoveHook, player.UserIDString, amount);
					break;
			}

			return true;
		}
	}

	private class MissionConfig
	{
		#region Fields

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

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

		[JsonProperty(PropertyName = "Mission type")] [JsonConverter(typeof(StringEnumConverter))]
		public MissionType Type;

		[JsonProperty(PropertyName = "Shortname/prefab")]
		public string Shortname;

		[JsonProperty(PropertyName = "Skin (0 - any item)")]
		public ulong Skin;

		[JsonProperty(PropertyName =
			"Upgrade Level (for 'Upgrade' missions)")]
		public int Grade;

		[JsonProperty(PropertyName = "Display Name (for 'Kill' missions)")]
		public string DisplayName;

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

		[JsonProperty(PropertyName = "Amount of main reward")]
		public int MainAward;

		[JsonProperty(PropertyName = "Give extra reward?")]
		public bool UseAdvanceAward;

		[JsonProperty(PropertyName = "Settings extra reward")]
		public ItemConf AdvanceAward;

		[JsonProperty(PropertyName = "Give second currency?")]
		public bool UseSecondAward;

		[JsonProperty(PropertyName = "Amount of second currency")]
		public int SecondAward;

		[JsonProperty(PropertyName = "Mode (for 'RaidableBases' missions)")]
		public string Mode;

		#endregion

		#region Helpers

		private void GiveMainAward(BasePlayer player)
		{
			_config.FirstCurrency.AddBalance(player, (int) (MainAward * GetPlayerRates(player.UserIDString)));
		}

		public void GiveAwards(BasePlayer player)
		{
			GiveMainAward(player);

			if (UseAdvanceAward && AdvanceAward != null)
			{
				if (_config.AdRewardToInventory)
					AdvanceAward?.GetItem(player);
				else
					PlayerData.GetOrCreate(player.UserIDString).Items.Add(AdvanceAward.ID);
			}

			if (UseSecondAward) _config.SecondCurrency.AddBalance(player, SecondAward);
		}

		public JObject ToJObject()
		{
			return new JObject
			{
				["description"] = Description,
				["type"] = (int) Type,
				["shortname"] = Shortname,
				["skin"] = Skin,
				["grade"] = Grade,
				["amount"] = Amount,
				["mainaward"] = MainAward,
				["use_advanceaward"] = UseAdvanceAward,
				["advanceaward_image"] = AdvanceAward?.Image,
				["advanceaward_displayname"] = AdvanceAward?.DisplayName,
				["advanceaward_title"] = AdvanceAward?.Title,
				["advanceaward_shortname"] = AdvanceAward?.Shortname,
				["advanceaward_skin"] = AdvanceAward?.Skin,
				["advanceaward_amount"] = AdvanceAward?.Amount,
				["use_second_award"] = UseSecondAward,
				["second_award"] = SecondAward
			};
		}

		#endregion

		#region Constructors

		public static MissionConfig CreateDefault(
			MissionType type,
			string shortName, string description,
			int amount, int mainAward,
			ulong skinID = 0UL, string displayName = "",
			bool useAdvanceAward = false, ItemConf advanceAward = null,
			bool useSecondAward = false, int secondAward = 0, int grade = 0,
			string raidMode = "",
			bool enabled = true)
		{
			return new MissionConfig
			{
				Enabled = enabled,
				Description = description,
				Type = type,
				Shortname = shortName,
				Skin = skinID,
				Grade = grade,
				DisplayName = displayName ?? string.Empty,
				Amount = amount,
				MainAward = mainAward,
				UseAdvanceAward = useAdvanceAward,
				AdvanceAward = advanceAward ?? new ItemConf(),
				UseSecondAward = useSecondAward,
				SecondAward = secondAward,
				Mode = raidMode ?? string.Empty
			};
		}

		#endregion
	}

	private class CaseClass
	{
		[JsonProperty(PropertyName = "Case Display Name")]
		public string DisplayName;

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

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

		[JsonProperty(PropertyName = "Cost in currency 1")]
		pub
// ... [Code preview truncated due to length. Full source in attached file] ...

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