Decompiled source of ItemTooltipDisplay v1.0.0

BepInEx/plugins/ItemTooltipDisplay.dll

Decompiled a day ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace SekkaMods;

[BepInPlugin("sekka.itemtooltipdisplay", "Item Tooltip Display", "1.0.0")]
public sealed class ItemTooltipDisplay : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		Harmony val = new Harmony("sekka.itemtooltipdisplay");
		try
		{
			val.PatchAll(typeof(ItemTooltipDisplay).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Tooltip display patch active: hides only the cheated-item notice. Item data is unchanged.");
		}
		catch (Exception ex)
		{
			val.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogError((object)("Tooltip display patch failed; patches removed: " + ex));
		}
	}
}
public static class TooltipText
{
	public static string RemoveNotice(string tooltip, string localizedNotice)
	{
		if (string.IsNullOrEmpty(tooltip) || string.IsNullOrEmpty(localizedNotice))
		{
			return tooltip;
		}
		string text = "\n<color=#808080><i>" + localizedNotice + "</i></color>";
		int num = tooltip.IndexOf(text, StringComparison.Ordinal);
		if (num >= 0)
		{
			return tooltip.Remove(num, text.Length);
		}
		return tooltip;
	}
}
[HarmonyPatch]
public static class ItemTooltipPatch
{
	public static MethodBase TargetMethod()
	{
		MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ItemData), "GetTooltip", new Type[6]
		{
			typeof(ItemData),
			typeof(int),
			typeof(bool),
			typeof(float),
			typeof(int),
			typeof(bool)
		}, (Type[])null);
		if (methodInfo == null)
		{
			throw new MissingMethodException("ItemData", "GetTooltip");
		}
		return methodInfo;
	}

	[HarmonyPriority(0)]
	public static void Postfix(ref string __result)
	{
		if (Localization.instance != null)
		{
			string localizedNotice = Localization.instance.Localize("$achievements_cheated_item_inventory");
			__result = TooltipText.RemoveNotice(__result, localizedNotice);
		}
	}
}