aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-08-10 00:50:32 +0200
committerGitHub <noreply@github.com>2024-08-10 00:50:32 +0200
commit894334db3abe18bb7260fcaac53f7ae548cd7c42 (patch)
treebe78e61cce6b9e8a75bf40b972e9c84d7b2aac3c /src/main/java/at
parentd167b0e7f493a05c12ffc032b27641e434e49a4b (diff)
downloadskyhanni-894334db3abe18bb7260fcaac53f7ae548cd7c42.tar.gz
skyhanni-894334db3abe18bb7260fcaac53f7ae548cd7c42.tar.bz2
skyhanni-894334db3abe18bb7260fcaac53f7ae548cd7c42.zip
Fix: Shift Clicking Items Triggering Pickup Log (#2305)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt
index fd2d4623b..6b45d5d9e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt
@@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.events.SackChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemNameResolver
@@ -38,16 +37,36 @@ import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
object ItemPickupLog {
- enum class DisplayLayout(private val display: String) {
- CHANGE_AMOUNT("§a+256"),
- ICON("§e✎"),
- ITEM_NAME("§d[:3] TransRights's Cake Soul"),
+ enum class DisplayLayout(private val display: String, val renderable: (PickupEntry, String) -> Renderable) {
+ CHANGE_AMOUNT(
+ "§a+256",
+ { entry, prefix ->
+ val formattedAmount = if (config.shorten) entry.amount.shortFormat() else entry.amount.addSeparators()
+ Renderable.string("${prefix}${formattedAmount}")
+ },
+ ),
+ ICON(
+ "§e✎",
+ { entry, _ ->
+ val itemIcon = entry.neuInternalName?.getItemStackOrNull()
+ if (itemIcon != null) {
+ Renderable.itemStack(itemIcon)
+ } else {
+ ItemNameResolver.getInternalNameOrNull(entry.name)?.let { Renderable.itemStack(it.getItemStack()) }
+ ?: Renderable.string("§c?")
+ }
+ },
+ ),
+ ITEM_NAME(
+ "§d[:3] TransRights's Cake Soul",
+ { entry, _ -> Renderable.string(entry.name) },
+ ),
;
override fun toString() = display
}
- private data class PickupEntry(val name: String, var amount: Long, val neuInternalName: NEUInternalName?) {
+ data class PickupEntry(val name: String, var amount: Long, val neuInternalName: NEUInternalName?) {
var timeUntilExpiry = SimpleTimeMark.now()
fun updateAmount(change: Long) {
@@ -117,6 +136,7 @@ object ItemPickupLog {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
+ if (InventoryUtils.inInventory()) return
val oldItemList = mutableMapOf<Int, Pair<ItemStack, Int>>()
@@ -183,25 +203,7 @@ object ItemPickupLog {
buildList {
val displayLayout: List<DisplayLayout> = config.displayLayout
for (item in displayLayout) {
- when (item) {
- DisplayLayout.ICON -> {
- val itemIcon = entry.neuInternalName?.getItemStackOrNull()
- if (itemIcon != null) {
- addItemStack(itemIcon)
- } else {
- ItemNameResolver.getInternalNameOrNull(entry.name)?.let { addItemStack(it) }
- }
- }
-
- DisplayLayout.CHANGE_AMOUNT -> {
- val formattedAmount = if (config.shorten) entry.amount.shortFormat() else entry.amount.addSeparators()
- add(Renderable.string("${prefix}${formattedAmount}"))
- }
-
- DisplayLayout.ITEM_NAME -> {
- add(Renderable.string(entry.name))
- }
- }
+ add(item.renderable(entry, prefix))
}
},
)