Make ItemUtil public (#2252)

This commit is contained in:
Haselnussbomber 2025-04-21 14:01:59 +02:00 committed by GitHub
parent c7cc771ee2
commit 39ac9f9dad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,14 +14,14 @@ namespace Dalamud.Utility;
/// <summary> /// <summary>
/// Utilities related to Items. /// Utilities related to Items.
/// </summary> /// </summary>
internal static class ItemUtil public static class ItemUtil
{ {
private static int? eventItemRowCount; private static int? eventItemRowCount;
/// <summary>Converts raw item ID to item ID with its classification.</summary> /// <summary>Converts raw item ID to item ID with its classification.</summary>
/// <param name="rawItemId">Raw item ID.</param> /// <param name="rawItemId">Raw item ID.</param>
/// <returns>Item ID and its classification.</returns> /// <returns>Item ID and its classification.</returns>
internal static (uint ItemId, ItemKind Kind) GetBaseId(uint rawItemId) public static (uint ItemId, ItemKind Kind) GetBaseId(uint rawItemId)
{ {
if (IsEventItem(rawItemId)) return (rawItemId, ItemKind.EventItem); // EventItem IDs are NOT adjusted if (IsEventItem(rawItemId)) return (rawItemId, ItemKind.EventItem); // EventItem IDs are NOT adjusted
if (IsHighQuality(rawItemId)) return (rawItemId - 1_000_000, ItemKind.Hq); if (IsHighQuality(rawItemId)) return (rawItemId - 1_000_000, ItemKind.Hq);
@ -33,7 +33,7 @@ internal static class ItemUtil
/// <param name="itemId">Item ID.</param> /// <param name="itemId">Item ID.</param>
/// <param name="kind">Item classification.</param> /// <param name="kind">Item classification.</param>
/// <returns>Raw Item ID.</returns> /// <returns>Raw Item ID.</returns>
internal static uint GetRawId(uint itemId, ItemKind kind) public static uint GetRawId(uint itemId, ItemKind kind)
{ {
return kind switch return kind switch
{ {
@ -50,7 +50,7 @@ internal static class ItemUtil
/// <param name="itemId">The item id to check.</param> /// <param name="itemId">The item id to check.</param>
/// <returns><c>true</c> when the item id belongs to a normal item.</returns> /// <returns><c>true</c> when the item id belongs to a normal item.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsNormalItem(uint itemId) public static bool IsNormalItem(uint itemId)
{ {
return itemId < 500_000; return itemId < 500_000;
} }
@ -61,7 +61,7 @@ internal static class ItemUtil
/// <param name="itemId">The item id to check.</param> /// <param name="itemId">The item id to check.</param>
/// <returns><c>true</c> when the item id belongs to a collectible item.</returns> /// <returns><c>true</c> when the item id belongs to a collectible item.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsCollectible(uint itemId) public static bool IsCollectible(uint itemId)
{ {
return itemId is >= 500_000 and < 1_000_000; return itemId is >= 500_000 and < 1_000_000;
} }
@ -72,7 +72,7 @@ internal static class ItemUtil
/// <param name="itemId">The item id to check.</param> /// <param name="itemId">The item id to check.</param>
/// <returns><c>true</c> when the item id belongs to a high quality item.</returns> /// <returns><c>true</c> when the item id belongs to a high quality item.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsHighQuality(uint itemId) public static bool IsHighQuality(uint itemId)
{ {
return itemId is >= 1_000_000 and < 2_000_000; return itemId is >= 1_000_000 and < 2_000_000;
} }
@ -83,7 +83,7 @@ internal static class ItemUtil
/// <param name="itemId">The item id to check.</param> /// <param name="itemId">The item id to check.</param>
/// <returns><c>true</c> when the item id belongs to an event item.</returns> /// <returns><c>true</c> when the item id belongs to an event item.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsEventItem(uint itemId) public static bool IsEventItem(uint itemId)
{ {
return itemId >= 2_000_000 && itemId - 2_000_000 < (eventItemRowCount ??= Service<DataManager>.Get().GetExcelSheet<EventItem>().Count); return itemId >= 2_000_000 && itemId - 2_000_000 < (eventItemRowCount ??= Service<DataManager>.Get().GetExcelSheet<EventItem>().Count);
} }
@ -95,7 +95,7 @@ internal static class ItemUtil
/// <param name="includeIcon">Whether to include the High Quality or Collectible icon.</param> /// <param name="includeIcon">Whether to include the High Quality or Collectible icon.</param>
/// <param name="language">An optional client language override.</param> /// <param name="language">An optional client language override.</param>
/// <returns>The item name.</returns> /// <returns>The item name.</returns>
internal static ReadOnlySeString GetItemName(uint itemId, bool includeIcon = true, ClientLanguage? language = null) public static ReadOnlySeString GetItemName(uint itemId, bool includeIcon = true, ClientLanguage? language = null)
{ {
var dataManager = Service<DataManager>.Get(); var dataManager = Service<DataManager>.Get();
@ -145,7 +145,7 @@ internal static class ItemUtil
/// <param name="itemId">The raw item Id.</param> /// <param name="itemId">The raw item Id.</param>
/// <param name="isEdgeColor">Wheather this color is used as edge color.</param> /// <param name="isEdgeColor">Wheather this color is used as edge color.</param>
/// <returns>The Color row id.</returns> /// <returns>The Color row id.</returns>
internal static uint GetItemRarityColorType(uint itemId, bool isEdgeColor = false) public static uint GetItemRarityColorType(uint itemId, bool isEdgeColor = false)
{ {
var rarity = 1u; var rarity = 1u;