From 6c113fc08517dc9781b93725816dda4cb043c12c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Oct 2023 20:55:50 +0200 Subject: add support for dynamic bingo ranks --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt | 18 +++++++++--------- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 12 +++--------- .../skyhanni/utils/jsonobjects/BingoRanks.java | 11 +++++++++++ 4 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index fd56e2bc0..df9171aa1 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.Features import at.hannibal2.skyhanni.config.SackData import at.hannibal2.skyhanni.config.commands.Commands.init import at.hannibal2.skyhanni.data.ActionBarStatsData +import at.hannibal2.skyhanni.data.BingoAPI import at.hannibal2.skyhanni.data.BlockData import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.CropAccessoryData @@ -361,6 +362,7 @@ class SkyHanniMod { loadModule(PurseAPI()) loadModule(RiftAPI) loadModule(SackAPI) + loadModule(BingoAPI) // features loadModule(BazaarOrderHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt index 8eac5b720..ca2557af0 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt @@ -1,17 +1,17 @@ package at.hannibal2.skyhanni.data -object BingoAPI { +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.jsonobjects.BingoRanks +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +object BingoAPI { private var ranks = mapOf() - init { - ranks = mapOf( - "§7Ⓑ" to 0, - "§aⒷ" to 1, - "§9Ⓑ" to 2, - "§5Ⓑ" to 3, - "§6Ⓑ" to 4, - ) + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + event.getConstant("BingoRanks")?.let { + ranks = it.ranks + } } fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 012a76f1c..e8ca2ab3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -142,16 +142,10 @@ class HypixelData { bingo = false for (line in ScoreboardData.sidebarLinesFormatted) { + if (BingoAPI.getRank(line) != null) { + bingo = true + } when (line) { - " §7Ⓑ §7Bingo", // No Rank - " §aⒷ §aBingo", // Rank 1 - " §9Ⓑ §9Bingo", // Rank 2 - " §5Ⓑ §5Bingo", // Rank 3 - " §6Ⓑ §6Bingo", // Rank 4 - -> { - bingo = true - } - " §7♲ §7Ironman" -> { ironman = true } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java new file mode 100644 index 000000000..a7b7dbecc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.Map; + +public class BingoRanks { + @Expose + public Map ranks; + +} -- cgit