diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/tracker')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt | 38 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt index 4b871377b..bce63e2d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt @@ -24,12 +24,17 @@ abstract class ItemTrackerData : TrackerData() { resetItems() } - fun addItem(internalName: NEUInternalName, stackSize: Int) { + fun addItem(internalName: NEUInternalName, amount: Int, command: Boolean) { val item = items.getOrPut(internalName) { TrackedItem() } - item.timesGained++ - item.totalAmount += stackSize + if (!command) { + item.timesGained++ + } + item.totalAmount += amount item.lastTimeUpdated = SimpleTimeMark.now() + if (command && item.totalAmount <= 0) { + items.remove(internalName) + } } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 684a7eb00..e7af81cea 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -3,11 +3,13 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.SlayerAPI +import at.hannibal2.skyhanni.data.TrackerManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemPriceSource import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.readableInternalName import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector @@ -26,23 +28,29 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( ) : SkyHanniTracker<Data>(name, createNewSession, getStorage, drawDisplay) { companion object { - val SKYBLOCK_COIN = NEUInternalName.SKYBLOCK_COIN } - fun addCoins(coins: Int) { - addItem(SKYBLOCK_COIN, coins) - } - - fun addItem(internalName: NEUInternalName, amount: Int) { + fun addItem(internalName: NEUInternalName, amount: Int, command: Boolean) { modify { - it.addItem(internalName, amount) + it.addItem(internalName, amount, command) } - getSharedTracker()?.let { - val hidden = it.get(DisplayMode.TOTAL).items[internalName]!!.hidden - it.get(DisplayMode.SESSION).items[internalName]!!.hidden = hidden + getSharedTracker()?.let { sharedData -> + sharedData.get(DisplayMode.TOTAL).items[internalName]?.let { data -> + sharedData.get(DisplayMode.SESSION).items[internalName]!!.hidden = data.hidden + } } + if (command) { + TrackerManager.commandEditTrackerSuccess = true + val displayName = internalName.itemName + if (amount > 0) { + ChatUtils.chat("Manually added to $name: §r$displayName §7(${amount}x§7)") + } else { + ChatUtils.chat("Manually removed from $name: §r$displayName §7(${-amount}x§7)") + } + return + } // TODO move the function to common val (itemName, price) = SlayerAPI.getItemNameAndPrice(internalName, amount) if (config.warnings.chat && price >= config.warnings.minimumChat) { @@ -62,7 +70,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( onChange = { config.priceSource = ItemPriceSource.entries[it.ordinal] // todo avoid ordinal update() - } + }, ) } } @@ -140,7 +148,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( } update() - } + }, ) else Renderable.string(displayName) lists.addAsSingletonList(renderable) @@ -172,6 +180,12 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( } add("§eClick to " + (if (hidden) "show" else "hide") + "!") add("§eControl + Click to remove this item!") + + add("") + add("§7Use §e/shedittracker ${internalName.readableInternalName} <amount>") + add("§7to edit the number.") + add("§7Use negative numbers to remove items.") + if (SkyHanniMod.feature.dev.debug.enabled) { add("") add("§7${internalName}") |