Skip to content

Commit

Permalink
Fix: Powder Tracker IndexOutOfBoundsException (hannibal002#2678)
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Oct 6, 2024
1 parent df1bff9 commit a07ad3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ enum class PowderChestReward(val displayName: String, pattern: String) {
"§9FTX 3070",
" {4}§r§9FTX 3070(?: §r§8x(?<amount>.*))?",
),

// TODO: Fix typo
ELECTRON_TRANSIMTTER(
"§9Electron Transmitter",
" {4}§r§9Electron Transmitter(?: §r§8x(?<amount>.*))?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ object PowderTracker {
}
}

private val tracker =
SkyHanniTracker("Powder Tracker", { Data() }, { it.powderTracker }) { formatDisplay(drawDisplay(it)) }
private val tracker = SkyHanniTracker("Powder Tracker", { Data() }, { it.powderTracker }) { formatDisplay(drawDisplay(it)) }

class Data : TrackerData() {

Expand Down Expand Up @@ -316,13 +315,11 @@ object PowderTracker {
addSearchString("§d${data.totalChestPicked.addSeparators()} Total Chests Picked §7($chestPerHour/h)")
addSearchString("§bDouble Powder: ${if (doublePowder) "§aActive! §7($powderTimer)" else "§cInactive!"}")

val entries = PowderChestReward.entries
val rewards = data.rewards
addPerHour(rewards, entries[0], mithrilInfo)
addPerHour(rewards, entries[1], gemstoneInfo)
addPerHour(rewards, PowderChestReward.GEMSTONE_POWDER, gemstoneInfo)
addSearchString("")
addPerHour(rewards, entries[46], diamondEssenceInfo)
addPerHour(rewards, entries[47], goldEssenceInfo)
addPerHour(rewards, PowderChestReward.DIAMOND_ESSENCE, diamondEssenceInfo)
addPerHour(rewards, PowderChestReward.GOLD_ESSENCE, goldEssenceInfo)
addSearchString("")
val hardStonePerHour = format(hardStoneInfo.perHour)
addSearchString("§b${data.totalHardStoneCompacted.addSeparators()} §fHard Stone §bCompacted §7($hardStonePerHour/h)", "Hard Stone")
Expand All @@ -347,7 +344,14 @@ object PowderTracker {
}

var totalParts = 0L
for (reward in entries.subList(26, 32)) { // robots part
for (reward in listOf(
PowderChestReward.FTX_3070,
PowderChestReward.ELECTRON_TRANSIMTTER,
PowderChestReward.ROBOTRON_REFLECTOR,
PowderChestReward.SUPERLITE_MOTOR,
PowderChestReward.CONTROL_SWITCH,
PowderChestReward.SYNTHETIC_HEART,
)) {
val count = rewards.getOrDefault(reward, 0)
totalParts += count
val name = reward.displayName
Expand All @@ -362,7 +366,17 @@ object PowderTracker {
val blueEgg = rewards.getOrDefault(PowderChestReward.BLUE_GOBLIN_EGG, 0)
addSearchString("§3$blueEgg§7-§c$redEgg§7-§e$yellowEgg§f-§a$greenEgg§f-§9$goblinEgg §fGoblin Egg")

for (reward in entries.subList(37, 46)) {
for (reward in listOf(
PowderChestReward.WISHING_COMPASS,
PowderChestReward.SLUDGE_JUICE,
PowderChestReward.ASCENSION_ROPE,
PowderChestReward.TREASURITE,
PowderChestReward.JUNGLE_HEART,
PowderChestReward.PICKONIMBUS_2000,
PowderChestReward.YOGGIE,
PowderChestReward.PREHISTORIC_EGG,
PowderChestReward.OIL_BARREL,
)) {
val count = rewards.getOrDefault(reward, 0).addSeparators()
val name = reward.displayName
addSearchString("§b$count $name", name)
Expand Down

0 comments on commit a07ad3e

Please sign in to comment.