aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt132
1 files changed, 71 insertions, 61 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
index 6f835b760..9be8907d8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
@@ -46,6 +46,7 @@ class HoppityCollectionStats {
private var display = emptyList<Renderable>()
private val loggedRabbits = mutableMapOf<String, RabbitCollectionInfo>()
+ private var totalRabbits = 0
private var inInventory = false
private var currentPage = 0
@@ -55,43 +56,55 @@ class HoppityCollectionStats {
if (!pagePattern.matches(event.inventoryName)) return
inInventory = true
+ display = buildDisplay(event)
+ }
- var totalAmount = 0
-
- for ((_, item) in event.inventoryItems) {
- val itemName = item.displayName ?: continue
- val itemLore = item.getLore()
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ inInventory = false
+ }
- var duplicatesFound = 0
- var rabbitRarity: RabbitCollectionRarity? = null
- var found = true
+ @SubscribeEvent
+ fun onProfileChange(event: ProfileJoinEvent) {
+ display = emptyList()
+ loggedRabbits.clear()
+ currentPage = 0
+ inInventory = false
+ }
- for (line in itemLore) {
- rabbitRarityPattern.matchMatcher(line) {
- rabbitRarity = RabbitCollectionRarity.fromDisplayName(group("rarity"))
- }
- duplicatesFoundPattern.matchMatcher(line) {
- duplicatesFound = group("duplicates").formatInt()
- }
- if (rabbitNotFoundPattern.matches(line)) found = false
+ @SubscribeEvent
+ fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
+ if (!inInventory) return
- rabbitsFoundPattern.matchMatcher(line) {
- totalAmount = group("total").formatInt()
- }
- }
+ config.hoppityStatsPosition.renderRenderables(
+ display,
+ extraSpace = 5,
+ posLabel = "Hoppity's Collection Stats"
+ )
+ }
- val rarity = rabbitRarity ?: continue
+ private fun buildDisplay(event: InventoryFullyOpenedEvent): MutableList<Renderable> {
+ val totalAmount = logRabbits(event)
- if (itemName == "§dEinstein" && found) {
- ChocolateFactoryAPI.profileStorage?.timeTowerCooldown = 7
- }
+ val newList = mutableListOf<Renderable>()
+ newList.add(Renderable.string("§eHoppity Rabbit Collection§f:"))
+ newList.add(LorenzUtils.fillTable(getRabbitStats(), padding = 5))
- val duplicates = duplicatesFound.coerceAtLeast(0)
- loggedRabbits[itemName] = RabbitCollectionInfo(rarity, found, duplicates)
+ if (totalAmount != totalRabbits) {
+ newList.add(Renderable.string(""))
+ newList.add(
+ Renderable.wrappedString(
+ "§cPlease Scroll through \n" +
+ "§call pages!",
+ width = 200,
+ )
+ )
}
+ return newList
+ }
+ private fun getRabbitStats(): MutableList<DisplayTableEntry> {
var totalAmountFound = 0
- var totalRabbits = 0
var totalDuplicates = 0
var totalChocolatePerSecond = 0
var totalChocolateMultiplier = 0.0
@@ -143,47 +156,44 @@ class HoppityCollectionStats {
)
)
}
+ return table
+ }
- val newList = mutableListOf<Renderable>()
- newList.add(Renderable.string("§eHoppity Rabbit Collection§f:"))
- newList.add(LorenzUtils.fillTable(table, padding = 5))
+ private fun logRabbits(event: InventoryFullyOpenedEvent): Int {
+ var totalAmount = 0
- if (totalAmount != totalRabbits) {
- newList.add(Renderable.string(""))
- newList.add(
- Renderable.wrappedString(
- "§cPlease Scroll through \n" +
- "§call pages!",
- width = 200,
- )
- )
- }
+ for ((_, item) in event.inventoryItems) {
+ val itemName = item.displayName ?: continue
+ val itemLore = item.getLore()
- display = newList
- }
+ var duplicatesFound = 0
+ var rabbitRarity: RabbitCollectionRarity? = null
+ var found = true
- @SubscribeEvent
- fun onInventoryClose(event: InventoryCloseEvent) {
- inInventory = false
- }
+ for (line in itemLore) {
+ rabbitRarityPattern.matchMatcher(line) {
+ rabbitRarity = RabbitCollectionRarity.fromDisplayName(group("rarity"))
+ }
+ duplicatesFoundPattern.matchMatcher(line) {
+ duplicatesFound = group("duplicates").formatInt()
+ }
+ if (rabbitNotFoundPattern.matches(line)) found = false
- @SubscribeEvent
- fun onProfileChange(event: ProfileJoinEvent) {
- display = emptyList()
- loggedRabbits.clear()
- currentPage = 0
- inInventory = false
- }
+ rabbitsFoundPattern.matchMatcher(line) {
+ totalAmount = group("total").formatInt()
+ }
+ }
- @SubscribeEvent
- fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
- if (!inInventory) return
+ val rarity = rabbitRarity ?: continue
- config.hoppityStatsPosition.renderRenderables(
- display,
- extraSpace = 5,
- posLabel = "Hoppity's Collection Stats"
- )
+ if (itemName == "§dEinstein" && found) {
+ ChocolateFactoryAPI.profileStorage?.timeTowerCooldown = 7
+ }
+
+ val duplicates = duplicatesFound.coerceAtLeast(0)
+ loggedRabbits[itemName] = RabbitCollectionInfo(rarity, found, duplicates)
+ }
+ return totalAmount
}
private fun isEnabled() = LorenzUtils.inSkyBlock && config.hoppityCollectionStats