aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-15 11:57:20 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-15 11:57:20 +0100
commit3604594ba19899e7732b405f047c69ad7b1ab3da (patch)
tree7b7b434f8c579a304cbb8d4f8fd31f2708ed827f /src/main
parent3d5c4d59d61c099cfc74cf04c0a875158bfec895 (diff)
downloadskyhanni-3604594ba19899e7732b405f047c69ad7b1ab3da.tar.gz
skyhanni-3604594ba19899e7732b405f047c69ad7b1ab3da.tar.bz2
skyhanni-3604594ba19899e7732b405f047c69ad7b1ab3da.zip
Fixed Maximum FF Needed display not showing in Jacob NPC menu.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt2
3 files changed, 24 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
index 4218f0e41..9ee04d3fc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
@@ -1,11 +1,13 @@
package at.hannibal2.skyhanni.features.garden.contest
enum class ContestBracket(val color: String) {
+ DIAMOND("b"),
+ PLATINUM("3"),
GOLD("6"),
SILVER("f"),
BRONZE("c"),
;
val displayName = "§$color§l$name"
- val pattern = "$displayName §7\\(§bTop \\d{1,2}%§7\\): §$color(?<amount>.*)".toPattern()
-} \ No newline at end of file
+ val pattern = "$displayName §7\\(§bTop \\d{1,2}%§7\\): §6(?<amount>.*)".toPattern()
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
index 50985ecfe..c5bb8d2a8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -120,12 +121,15 @@ object FarmingContestAPI {
cropPattern.matchMatcher(it) { CropType.getByName(group("crop")) }
} ?: error("Crop not found in lore!")
- val brackets = ContestBracket.entries.associateWith { bracket ->
- lore.firstNotNullOfOrNull {
- bracket.pattern.matchMatcher(it) {
- group("amount").replace(",", "").toInt()
- }
- } ?: error("Farming contest bracket not found in lore!")
+ val brackets = buildMap {
+ for (bracket in ContestBracket.entries) {
+ val amount = lore.firstNotNullOfOrNull {
+ bracket.pattern.matchMatcher(it) {
+ group("amount").replace(",", "").toInt()
+ }
+ } ?: continue
+ put(bracket, amount)
+ }
}
return FarmingContest(time, crop, brackets)
@@ -137,15 +141,18 @@ object FarmingContestAPI {
fun calculateAverages(crop: CropType): Pair<Int, Map<ContestBracket, Int>> {
var amount = 0
- val map = mutableMapOf<ContestBracket, Int>()
+ val crops = mutableMapOf<ContestBracket, Int>()
+ val contests = mutableMapOf<ContestBracket, Int>()
for (contest in getContestsOfType(crop).associateWith { it.time }.sortedDesc().keys) {
amount++
- for ((bracket, count) in contest.brackets) {
- val old = map.getOrDefault(bracket, 0)
- map[bracket] = count + old
+ val brackets = contest.brackets
+ for ((bracket, count) in brackets) {
+ val old = crops.getOrDefault(bracket, 0)
+ crops[bracket] = count + old
+ contests.addOrPut(bracket, 1)
}
if (amount == 10) break
}
- return Pair(amount, map.mapValues { (_, counter) -> counter / amount })
+ return Pair(amount, crops.mapValues { (bracket, counter) -> counter / contests[bracket]!! })
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
index e02b358b9..bcdc6b216 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
@@ -116,7 +116,7 @@ class JacobContestFFNeededDisplay {
}
private fun getLine(bracket: ContestBracket, map: Map<ContestBracket, Int>, crop: CropType): String {
- val counter = map[bracket]!!
+ val counter = map[bracket] ?: return " ${bracket.displayName}§f: §8Not found!"
val blocksPerSecond = crop.getRealBlocksPerSecond()
val cropsPerSecond = counter.toDouble() / blocksPerSecond / 60
val farmingFortune = formatFarmingFortune(cropsPerSecond * 100 / 20 / crop.baseDrops)