using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ReservedItemSlotCore.Config;
using ReservedItemSlotCore.Data;
using ReservedUtilitySlot.Config;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReservedUtilitySlot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReservedUtilitySlot")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bdec4763-b8c7-4814-ad3d-43fa8d7ee121")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReservedUtilitySlot
{
[BepInPlugin("FlipMods.ReservedUtilitySlot", "ReservedUtilitySlot", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static Plugin instance;
private static ManualLogSource logger;
private Harmony _harmony;
public static ReservedItemSlotData utilitySlotData;
public static ReservedItemData ladderData;
public static ReservedItemData lockpickerData;
public static ReservedItemData jetpackData;
public static ReservedItemData stunGrenadeData;
public static ReservedItemData homemadeFlashbangData;
public static ReservedItemData tzpInhalantData;
public static ReservedItemData radarBoosterData;
public static ReservedItemData remoteRadarData;
public static ReservedItemData utilityBeltData;
public static ReservedItemData hackingToolData;
public static ReservedItemData pingerData;
public static ReservedItemData portableTeleData;
public static ReservedItemData advancedPortableTeleData;
public static ReservedItemData peeperData;
public static ReservedItemData medkitData;
public static ReservedItemData binocularsData;
public static ReservedItemData mapperData;
public static ReservedItemData toothpasteData;
public static List<ReservedItemData> additionalItemData = new List<ReservedItemData>();
public static ReservedItemSlotData keySlotData;
public static ReservedItemData keyData;
public static List<ReservedItemData> additionalKeyItemData = new List<ReservedItemData>();
private void Awake()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
instance = this;
CreateCustomLogger();
ConfigSettings.BindConfigSettings();
CreateReservedItemSlots();
CreateAdditionalReservedItemSlots();
_harmony = new Harmony("ReservedUtilitySlot");
PatchAll();
Log("ReservedUtilitySlot loaded");
}
private void CreateReservedItemSlots()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Expected O, but got Unknown
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Expected O, but got Unknown
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Expected O, but got Unknown
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Expected O, but got Unknown
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Expected O, but got Unknown
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Expected O, but got Unknown
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Expected O, but got Unknown
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Expected O, but got Unknown
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Expected O, but got Unknown
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Expected O, but got Unknown
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Expected O, but got Unknown
if (!ConfigSettings.disableUtilitySlot.Value)
{
utilitySlotData = ReservedItemSlotData.CreateReservedItemSlotData("utility", ConfigSettings.overrideItemSlotPriority.Value, ConfigSettings.overridePurchasePrice.Value);
ladderData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("연장형 사다리", (PlayerBone)0, default(Vector3), default(Vector3)));
jetpackData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("제트팩", (PlayerBone)0, default(Vector3), default(Vector3)));
stunGrenadeData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("기절 수류탄", (PlayerBone)0, default(Vector3), default(Vector3)));
homemadeFlashbangData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("사제 섬광탄", (PlayerBone)0, default(Vector3), default(Vector3)));
tzpInhalantData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("TZP-흡입기", (PlayerBone)0, default(Vector3), default(Vector3)));
radarBoosterData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("레이더 부스터", (PlayerBone)0, default(Vector3), default(Vector3)));
lockpickerData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("자물쇠 따개", (PlayerBone)0, default(Vector3), default(Vector3)));
remoteRadarData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Remote Radar", (PlayerBone)0, default(Vector3), default(Vector3)));
utilityBeltData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Utility Belt", (PlayerBone)0, default(Vector3), default(Vector3)));
hackingToolData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Hacking Tool", (PlayerBone)0, default(Vector3), default(Vector3)));
pingerData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Pinger", (PlayerBone)0, default(Vector3), default(Vector3)));
portableTeleData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Portable Tele", (PlayerBone)0, default(Vector3), default(Vector3)));
advancedPortableTeleData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Advanced Portable Tele", (PlayerBone)0, default(Vector3), default(Vector3)));
peeperData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Peeper", (PlayerBone)0, default(Vector3), default(Vector3)));
medkitData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Medkit", (PlayerBone)0, default(Vector3), default(Vector3)));
binocularsData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Binoculars", (PlayerBone)0, default(Vector3), default(Vector3)));
mapperData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Mapper", (PlayerBone)0, default(Vector3), default(Vector3)));
toothpasteData = utilitySlotData.AddItemToReservedItemSlot(new ReservedItemData("Toothpaste", (PlayerBone)0, default(Vector3), default(Vector3)));
}
if (!ConfigSettings.addKeySlot.Value)
{
return;
}
ReservedItemSlotData val = ReservedItemSlotData.CreateReservedItemSlotData("key_slot", ConfigSettings.overrideKeySlotPriority.Value, ConfigSettings.overrideKeySlotPrice.Value);
keyData = val.AddItemToReservedItemSlot(new ReservedItemData("열쇠", (PlayerBone)0, default(Vector3), default(Vector3)));
if (ConfigSettings.moveLockpickerToKeySlot.Value)
{
if (!ConfigSettings.disableUtilitySlot.Value)
{
val.AddItemToReservedItemSlot(lockpickerData);
utilitySlotData.RemoveItemFromReservedItemSlot(lockpickerData.itemName);
}
else
{
val.AddItemToReservedItemSlot(new ReservedItemData("자물쇠 따개", (PlayerBone)0, default(Vector3), default(Vector3)));
}
}
}
private void CreateAdditionalReservedItemSlots()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Expected O, but got Unknown
string[] array = ConfigSettings.ParseAdditionalItems();
string[] array2 = array;
foreach (string text in array2)
{
if (!utilitySlotData.ContainsItem(text))
{
LogWarning("Adding additional item to reserved item slot. Item: " + text);
ReservedItemData val = new ReservedItemData(text, (PlayerBone)0, default(Vector3), default(Vector3));
additionalItemData.Add(val);
utilitySlotData.AddItemToReservedItemSlot(val);
}
}
string[] array3 = ConfigSettings.ParseRemoveItems();
string[] array4 = array3;
foreach (string text2 in array4)
{
if (utilitySlotData.ContainsItem(text2))
{
LogWarning("Removing item from reserved item slot. Item: " + text2);
utilitySlotData.RemoveItemFromReservedItemSlot(text2);
}
}
if (keySlotData == null)
{
return;
}
string[] array5 = ConfigSettings.ParseAdditionalKeyItems();
string[] array6 = array5;
foreach (string text3 in array6)
{
if (!keySlotData.ContainsItem(text3))
{
LogWarning("Adding additional item to reserved key item slot. Item: " + text3);
ReservedItemData val2 = new ReservedItemData(text3, (PlayerBone)0, default(Vector3), default(Vector3));
additionalKeyItemData.Add(val2);
keySlotData.AddItemToReservedItemSlot(val2);
}
}
}
private void PatchAll()
{
IEnumerable<Type> enumerable;
try
{
enumerable = Assembly.GetExecutingAssembly().GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
enumerable = ex.Types.Where((Type t) => t != null);
}
foreach (Type item in enumerable)
{
_harmony.PatchAll(item);
}
}
private void CreateCustomLogger()
{
try
{
logger = Logger.CreateLogSource($"{((BaseUnityPlugin)this).Info.Metadata.Name}-{((BaseUnityPlugin)this).Info.Metadata.Version}");
}
catch
{
logger = ((BaseUnityPlugin)this).Logger;
}
}
public static void Log(string message)
{
logger.LogInfo((object)message);
}
public static void LogError(string message)
{
logger.LogError((object)message);
}
public static void LogWarning(string message)
{
logger.LogWarning((object)message);
}
public static bool IsModLoaded(string guid)
{
return Chainloader.PluginInfos.ContainsKey(guid);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "FlipMods.ReservedUtilitySlot";
public const string PLUGIN_NAME = "ReservedUtilitySlot";
public const string PLUGIN_VERSION = "1.0.3";
}
}
namespace ReservedUtilitySlot.Config
{
public static class ConfigSettings
{
public static ConfigEntry<int> overrideItemSlotPriority;
public static ConfigEntry<int> overridePurchasePrice;
public static ConfigEntry<string> additionalItemsInSlot;
public static ConfigEntry<string> removeItemsFromSlot;
public static ConfigEntry<bool> disableUtilitySlot;
public static ConfigEntry<bool> addKeySlot;
public static ConfigEntry<int> overrideKeySlotPriority;
public static ConfigEntry<int> overrideKeySlotPrice;
public static ConfigEntry<string> addAdditionalItemsToKeySlot;
public static ConfigEntry<bool> moveLockpickerToKeySlot;
public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();
public static void BindConfigSettings()
{
Plugin.Log("BindingConfigs");
overrideItemSlotPriority = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "UtilitySlotPriorityOverride", 80, "[Host only] Manually set the priority for this item slot. Higher priority slots will come first in the reserved item slots, which will appear below the other slots. Negative priority items will appear on the left side of the screen, this is disabled in the core mod's config."));
overridePurchasePrice = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "UtilitySlotPriceOverride", 200, "[Host only] Manually set the price for this item in the store. Setting 0 will force this item to be unlocked immediately after the game starts."));
additionalItemsInSlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "AdditionalItemsInSlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). When adding items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems. As of now, additional items added to reserved item slots cannot be seen on players while holstered.\nNOTE: IF YOU ARE USING A TRANSLATION MOD, YOU MAY NEED TO ADD THE TRANSLATED NAME OF ANY ITEM YOU WANT IN THIS SLOT."));
removeItemsFromSlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "RemoveItemsFromSlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). Removes the specified items from this reserved item slot.When removing items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems.\nCURRENT ITEMS IN SLOT: \"Extension ladder\", \"Lockpicker\", \"Jetpack\", \"Stun grenade\", \"Homemade flashbang\", \"TZP-Inhalant\", \"Radar-booster\", \"Remote Radar\", \"Utility Belt\", \"Hacking Tool\", \"Pinger\", \"Portable Tele\", \"Advanced Portable Tele\", \"Peeper\", \"Medkit\", \"Binoculars\", \"Mapper\", \"Toothpaste\" (you got a problem with toothpaste??)"));
disableUtilitySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "DisableUtilitySlot", false, "[Host only] Disables the utility slot. Use this if you only want the reserved key slot."));
addKeySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "AddKeySlot", false, "[Host only] Adds a reserved item slot for the key item. By default, the slot will appear on the left side of the screen, unless given a positive item slot priority."));
overrideKeySlotPriority = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "KeySlotPriorityOverride", -50, "[Host only] Manually set the priority for the key item slot. Higher priority slots will come first in the reserved item slots, which will appear below the other slots. Negative priority items will appear on the left side of the screen, this is disabled in the core mod's config."));
overrideKeySlotPrice = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "KeySlotPriceOverride", 50, "[Host only] Manually set the price for the key item in the store. Setting 0 will force this item to be unlocked immediately after the game starts."));
moveLockpickerToKeySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "MoveLockpickerToKeySlot", false, "[Host only] Moves the lockpicker to the key slot. This setting will do nothing if the reserved key slot is disabled in the config."));
addAdditionalItemsToKeySlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "AdditionalItemsInKeySlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). When adding items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems.\nNOTE: IF YOU ARE USING A TRANSLATION MOD, YOU MAY NEED TO ADD THE TRANSLATED NAME OF ANY ITEM YOU WANT IN THIS SLOT."));
additionalItemsInSlot.Value = additionalItemsInSlot.Value.Replace(", ", ",");
removeItemsFromSlot.Value = removeItemsFromSlot.Value.Replace(", ", ",");
TryRemoveOldConfigSettings();
}
public static ConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry)
{
currentConfigEntries.Add(((ConfigEntryBase)configEntry).Definition.Key, (ConfigEntryBase)(object)configEntry);
return configEntry;
}
public static string[] ParseAdditionalItems()
{
return ConfigSettings.ParseItemNames(additionalItemsInSlot.Value);
}
public static string[] ParseRemoveItems()
{
return ConfigSettings.ParseItemNames(removeItemsFromSlot.Value);
}
public static string[] ParseAdditionalKeyItems()
{
return ConfigSettings.ParseItemNames(addAdditionalItemsToKeySlot.Value);
}
public static void TryRemoveOldConfigSettings()
{
HashSet<string> hashSet = new HashSet<string>();
HashSet<string> hashSet2 = new HashSet<string>();
foreach (ConfigEntryBase value in currentConfigEntries.Values)
{
hashSet.Add(value.Definition.Section);
hashSet2.Add(value.Definition.Key);
}
try
{
ConfigFile config = ((BaseUnityPlugin)Plugin.instance).Config;
string configFilePath = config.ConfigFilePath;
if (!File.Exists(configFilePath))
{
return;
}
string text = File.ReadAllText(configFilePath);
string[] array = File.ReadAllLines(configFilePath);
string text2 = "";
for (int i = 0; i < array.Length; i++)
{
array[i] = array[i].Replace("\n", "");
if (array[i].Length <= 0)
{
continue;
}
if (array[i].StartsWith("["))
{
if (text2 != "" && !hashSet.Contains(text2))
{
text2 = "[" + text2 + "]";
int num = text.IndexOf(text2);
int num2 = text.IndexOf(array[i]);
text = text.Remove(num, num2 - num);
}
text2 = array[i].Replace("[", "").Replace("]", "").Trim();
}
else
{
if (!(text2 != ""))
{
continue;
}
if (i <= array.Length - 4 && array[i].StartsWith("##"))
{
int j;
for (j = 1; i + j < array.Length && array[i + j].Length > 3; j++)
{
}
if (hashSet.Contains(text2))
{
int num3 = array[i + j - 1].IndexOf("=");
string item = array[i + j - 1].Substring(0, num3 - 1);
if (!hashSet2.Contains(item))
{
int num4 = text.IndexOf(array[i]);
int num5 = text.IndexOf(array[i + j - 1]) + array[i + j - 1].Length;
text = text.Remove(num4, num5 - num4);
}
}
i += j - 1;
}
else if (array[i].Length > 3)
{
text = text.Replace(array[i], "");
}
}
}
if (!hashSet.Contains(text2))
{
text2 = "[" + text2 + "]";
int num6 = text.IndexOf(text2);
text = text.Remove(num6, text.Length - num6);
}
while (text.Contains("\n\n\n"))
{
text = text.Replace("\n\n\n", "\n\n");
}
File.WriteAllText(configFilePath, text);
config.Reload();
}
catch
{
}
}
}
}