-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement: Add ability to use /shedittracker
with CorpseTracker
#2582
Changes from 1 commit
a06b234
e5c827f
98e59d9
5c23c64
93fc440
6652b71
1e2200b
316bccb
48a5b1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ package at.hannibal2.skyhanni.features.mining.glacitemineshaft | |
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.data.IslandType | ||
import at.hannibal2.skyhanni.data.MiningAPI | ||
import at.hannibal2.skyhanni.data.ProfileStorageData | ||
import at.hannibal2.skyhanni.events.GuiRenderEvent | ||
import at.hannibal2.skyhanni.events.IslandChangeEvent | ||
import at.hannibal2.skyhanni.events.ItemAddEvent | ||
import at.hannibal2.skyhanni.events.mining.CorpseLootedEvent | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.test.command.ErrorManager | ||
import at.hannibal2.skyhanni.utils.ChatUtils | ||
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut | ||
import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString | ||
import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues | ||
|
@@ -136,6 +140,20 @@ object CorpseTracker { | |
} | ||
} | ||
|
||
@SubscribeEvent | ||
fun onItemAdd(event: ItemAddEvent) { | ||
if (!isEnabled()) return | ||
ProfileStorageData.profileSpecific?.mining?.mineshaft?.corpseProfitTracker?.let { trackerData -> | ||
trackerData.getSelectedBucket()?.let { | ||
tracker.addItem(it, event.internalName, event.amount) | ||
ChatUtils.chat("Added ${event.internalName.itemName} §8x${event.amount} to Corpse Tracker §8(${it.displayName}§8)§e.") | ||
} ?: ChatUtils.chat( | ||
"§cYou do not have a Corpse Type selected, and cannot add loot to this tracker generically.\n" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this will clash with the default answer messages from /shedittracker |
||
"§eSelect a type in the GUI in your inventory, then re-run this command." | ||
) | ||
} ?: ErrorManager.skyHanniError("Could not fetch profile storage data for CorpseTracker.") | ||
} | ||
|
||
fun resetCommand() { | ||
tracker.resetCommand() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ class SkyHanniBucketedItemTracker<E : Enum<E>, BucketedData : BucketedItemTracke | |
addItem(bucket, SKYBLOCK_COIN, coins) | ||
} | ||
|
||
fun addItem(bucket: E, internalName: NEUInternalName, amount: Int) { | ||
fun addItem(bucket: E, internalName: NEUInternalName, amount: Int, manuallyAdded: Boolean = false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned before, i recomment moving this into skyhanni item tracker, avoiding the code duplication alltogether |
||
modify { | ||
it.addItem(bucket, internalName, amount) | ||
} | ||
|
@@ -46,10 +46,10 @@ class SkyHanniBucketedItemTracker<E : Enum<E>, BucketedData : BucketedItemTracke | |
} | ||
|
||
val (itemName, price) = SlayerAPI.getItemNameAndPrice(internalName, amount) | ||
if (config.warnings.chat && price >= config.warnings.minimumChat) { | ||
if (config.warnings.chat && price >= config.warnings.minimumChat && !manuallyAdded) { | ||
ChatUtils.chat("§a+Tracker Drop§7: §r$itemName") | ||
} | ||
if (config.warnings.title && price >= config.warnings.minimumTitle) { | ||
if (config.warnings.title && price >= config.warnings.minimumTitle && !manuallyAdded) { | ||
LorenzUtils.sendTitle("§a+ $itemName", 5.seconds) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be abstracted into the bucketed item tracker.
ideally the bucketed item tracker would reuse the logic from skyhann iitem tracker so that this unique chat message is not necessary in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't re-use the logic - they're entirely separate trackers. The item trackers just have the concept of one set of global "loot" that's added to - this is an enum driven base of buckets, the logic doesn't fit. The only way I could think to do this was using the currently-selected bucket.
Best I could do would be to abstract it back to the bucketed item tracker, however that message is going to end up having to be very generic. We can't do it in
SkyhanniItemTracker
and expect it to work here - theaddItem
signatures are already overridden forSkyhanniBucketedItemTracker
, as it takes a bucket as first param.We also don't have the context of the
tracker
instance in the tracker itself, which would prevent actually moving this into the genericSkyhanniBucketedItemTracker
, as we need to know the currently selected bucket;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I could think to do this was using the currently-selected bucket.
I was not expecting anything more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about abstracting the existing item tracker class and creating a new "single bucketed tracker" for everything else?