aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt3
3 files changed, 26 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
index eb351d7d4..1989c5442 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.SlayerChangeEvent
import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent
import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent
import at.hannibal2.skyhanni.features.slayer.SlayerType
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.nextAfter
@@ -17,7 +16,6 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import com.google.common.cache.CacheBuilder
-import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.concurrent.TimeUnit
@@ -49,9 +47,6 @@ object SlayerAPI {
// Spider
"Cobweb" -> true
- "String" -> true
- "Spider Eye" -> true
- "Bone" -> true
// Blaze
"Water Bottle" -> true
@@ -59,9 +54,7 @@ object SlayerAPI {
else -> false
}
- fun getItemNameAndPrice(stack: ItemStack): Pair<String, Double> {
- val internalName = stack.getInternalName()
- val amount = stack.stackSize
+ fun getItemNameAndPrice(internalName: NEUInternalName, amount: Int): Pair<String, Double> {
val key = internalName to amount
nameCache.getIfPresent(key)?.let {
return it
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
index 00b0f751d..6d4539ccf 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.PurseChangeCause
import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.events.SackChangeEvent
import at.hannibal2.skyhanni.events.SlayerChangeEvent
import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData
@@ -138,6 +139,22 @@ object SlayerItemProfitTracker {
update()
}
+ @SubscribeEvent
+ fun onSackChange(event: SackChangeEvent) {
+ if (!isEnabled()) return
+ if (!SlayerAPI.isInSlayerArea) return
+ if (!SlayerAPI.hasActiveSlayerQuest()) return
+
+ for (sackChange in event.sackChanges) {
+ val change = sackChange.delta
+ if (change > 0) {
+ val internalName = sackChange.internalName
+ println("added: $internalName +$change")
+ addItem(internalName, change)
+ }
+ }
+ }
+
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
fun onChatPacket(event: PacketEvent.ReceiveEvent) {
if (!isEnabled()) return
@@ -158,13 +175,17 @@ object SlayerItemProfitTracker {
val name = itemStack.name ?: return
if (SlayerAPI.ignoreSlayerDrop(name)) return
val internalName = itemStack.getInternalNameOrNull() ?: return
+ addItem(internalName, itemStack.stackSize)
+ }
+
+ private fun addItem(internalName: NEUInternalName, amount: Int) {
if (!isAllowedItem(internalName)) {
LorenzUtils.debug("Ignored non-slayer item pickup: '$internalName' '$itemLogCategory'")
return
}
- val (itemName, price) = SlayerAPI.getItemNameAndPrice(itemStack)
- addItemPickup(internalName, itemStack.stackSize)
+ val (itemName, price) = SlayerAPI.getItemNameAndPrice(internalName, amount)
+ addItemPickup(internalName, amount)
logger.log("Coins gained for picking up an item ($itemName) ${price.addSeparators()}")
if (config.priceInChat) {
if (price > config.minimumPrice) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
index 375b2e86c..de2e43627 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.slayer
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
@@ -42,7 +43,7 @@ class SlayerItemsOnGround {
if (itemStack.item == Items.spawn_egg) continue
if (itemStack.getInternalName_old() == "") continue
- val (itemName, price) = SlayerAPI.getItemNameAndPrice(itemStack)
+ val (itemName, price) = SlayerAPI.getItemNameAndPrice(itemStack.getInternalName(), itemStack.stackSize)
if (config.minimumPrice > price) continue
itemsOnGround.put(entityItem, location to itemName)