From 6a187104e5f88f61069c2c034fa8a1d2375e336e Mon Sep 17 00:00:00 2001 From: "Erymanthus[#5074] | (u/)RayDeeUx" <51521765+RayDeeUx@users.noreply.github.com> Date: Thu, 28 Sep 2023 03:07:33 -0400 Subject: Bugfix: Revise isSack() to rely on internal name instead (#510) Fixed Bazaar Item category "Ink Sack" gets wrongly detected as an item sack. #510 --- .../hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt | 6 +++--- .../skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt | 2 +- .../at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 203bfe9c9..49f1d4bfa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -337,7 +337,7 @@ class HideNotClickableItems { val name = stack.cleanName() reverseColor = true - if (ItemUtils.isSack(name)) return false + if (ItemUtils.isSack(stack)) return false hideReason = "This item is not a sack!" @@ -370,7 +370,7 @@ class HideNotClickableItems { val name = stack.cleanName() - if (ItemUtils.isSack(name)) { + if (ItemUtils.isSack(stack)) { hideReason = "Sacks cannot be traded!" return true } @@ -497,7 +497,7 @@ class HideNotClickableItems { val name = stack.cleanName() - if (ItemUtils.isSack(name)) { + if (ItemUtils.isSack(stack)) { hideReason = "Sacks cannot be auctioned!" return true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 37a44f6ed..44e5cf46f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -90,7 +90,7 @@ class ItemDisplayOverlayFeatures { } if (SkyHanniMod.feature.inventory.displaySackName) { - if (ItemUtils.isSack(itemName)) { + if (ItemUtils.isSack(item)) { val sackName = grabSackName(itemName) return (if (itemName.contains("Enchanted")) "ยง5" else "") + sackName.substring(0, 2) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt index 58b7924b1..7e34aa009 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt @@ -35,7 +35,7 @@ class PocketSackInASackDisplay { val itemStack = event.itemStack val applied = itemStack.getAppliedPocketSackInASack() ?: return - if (!ItemUtils.isSack(itemStack.displayName)) return + if (!ItemUtils.isSack(itemStack)) return val iterator = event.toolTip.listIterator() var next = false for (line in iterator) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 4fd35a330..ee753e17d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -21,8 +21,8 @@ object ItemUtils { fun ItemStack.cleanName() = this.displayName.removeColor() - fun isSack(name: String): Boolean = - name.endsWith(" Sack")//TODO use item id or api or something? or dont, its working fine now + fun isSack(stack: ItemStack): Boolean = + stack?.getInternalName()?.endsWith("_SACK") ?: false fun ItemStack.getLore(): List { val tagCompound = this.tagCompound ?: return emptyList() -- cgit