Skip to content

Commit

Permalink
sack item amount
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Dec 29, 2023
1 parent 453f114 commit 264ce4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class NeedsConfig {
@ConfigEditorBoolean
public boolean showPrice = true;

@Expose
@ConfigOption(name = "Show Sack Count", desc = "Show the amount of this item that you already have in your sacks. " +
"§eOnly updates on sack change messages.")
@ConfigEditorBoolean
public boolean showSackCount = true;

@Expose
@ConfigOption(name = "Item Preview", desc = "Show the base type for the required items next to new visitors. §cNote that some visitors may require any crop.")
@ConfigEditorBoolean
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.SackChangeEvent
import at.hannibal2.skyhanni.events.SackDataUpdateEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity
import at.hannibal2.skyhanni.features.inventory.SackDisplay
Expand Down Expand Up @@ -300,6 +301,8 @@ object SackAPI {
private fun saveSackData() {
ProfileStorageData.sackProfiles?.sackContents = sackData
SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS, "saving-data")

SackDataUpdateEvent().postAndCatch()
}

data class SackGemstone(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package at.hannibal2.skyhanni.events

class SackDataUpdateEvent : LorenzEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package at.hannibal2.skyhanni.features.garden.visitor
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.HighlightMode
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.SackAPI
import at.hannibal2.skyhanni.data.SackStatus
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.events.SackDataUpdateEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptedEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent
Expand Down Expand Up @@ -177,6 +180,18 @@ class GardenVisitorFeatures {
list.add(" §7(§6$format§7)")
}

if (config.needs.showSackCount) {
val sackItemData = SackAPI.fetchSackItem(internalName)
val itemStatus = sackItemData.getStatus()
val itemAmount = sackItemData.amount
if (itemStatus == SackStatus.OUTDATED) {
list.add(" §cdata outdated, open sacks")
} else {
val textColour = if (itemAmount > amount) "a" else "e"
list.add(" §${textColour}x${sackItemData.amount.addSeparators()} §7in your sack")
}
}

add(list)
}
if (totalPrice > 0) {
Expand Down Expand Up @@ -239,6 +254,11 @@ class GardenVisitorFeatures {
}
}

@SubscribeEvent
fun onSackUpdate(event: SackDataUpdateEvent) {
update()
}

@SubscribeEvent
fun onVisitorRefused(event: VisitorRefusedEvent) {
update()
Expand Down

0 comments on commit 264ce4e

Please sign in to comment.