From 6d24f65c3a712ab992d098431a857c50fb6f8b9c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:52:45 +0100 Subject: Only saving one bingo card list now. --- .../hannibal2/skyhanni/features/bingo/BingoAPI.kt | 6 ++++-- .../skyhanni/features/bingo/BingoCardDisplay.kt | 21 ++++++++++----------- .../skyhanni/features/bingo/card/BingoGoal.kt | 3 +++ .../skyhanni/features/bingo/card/BingoGoals.kt | 4 ---- .../skyhanni/features/bingo/card/GoalType.kt | 7 +++++++ 5 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoal.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/bingo/card/GoalType.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt index 468adc0df..517b6e418 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoRanksJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bingo.card.BingoGoal +import at.hannibal2.skyhanni.features.bingo.card.GoalType import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object BingoAPI { private var ranks = mapOf() var tips: Map = emptyMap() - val personalGoals = mutableListOf() - val communityGoals = mutableListOf() + val bingoGoals = mutableListOf() + val personalGoals get() = bingoGoals.filter { it.type == GoalType.PERSONAL } + val communityGoals get() = bingoGoals.filter { it.type == GoalType.COMMUNITY } @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index 2dc3ca5a6..e0a2c7638 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.bingo.card.BingoGoal +import at.hannibal2.skyhanni.features.bingo.card.GoalType import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -54,8 +55,7 @@ class BingoCardDisplay { } private fun reload() { - BingoAPI.personalGoals.clear() - BingoAPI.communityGoals.clear() + BingoAPI.bingoGoals.clear() } fun toggleCommand() { @@ -86,8 +86,7 @@ class BingoCardDisplay { if (!config.enabled) return if (event.inventoryName != "Bingo Card") return - BingoAPI.personalGoals.clear() - BingoAPI.communityGoals.clear() + BingoAPI.bingoGoals.clear() for ((slot, stack) in event.inventoryItems) { val isPersonalGoal = stack.getLore().any { it.endsWith("Personal Goal") } val isCommunityGoal = stack.getLore().any { it.endsWith("Community Goal") } @@ -114,9 +113,9 @@ class BingoCardDisplay { val done = stack.getLore().any { it.contains("GOAL REACHED") } if (isPersonalGoal) { - BingoAPI.personalGoals.add(getPersonalGoal(name, description, slot, done)) + BingoAPI.bingoGoals.add(getPersonalGoal(name, description, slot, done)) } else { - BingoAPI.communityGoals.add(getCommunityGoal(name, description, slot, done)) + BingoAPI.bingoGoals.add(getCommunityGoal(name, description, slot, done)) } } lastBingoCardOpenTime = SimpleTimeMark.now() @@ -133,11 +132,11 @@ class BingoCardDisplay { if (!done) { personalHiddenGoalPattern.matchMatcher(description) { BingoAPI.tips[name]?.let { - return BingoGoal(name, it.getDescriptionLine(), slot, false) + return BingoGoal(name, it.getDescriptionLine(), GoalType.PERSONAL, slot, false) } } } - return BingoGoal(name, description, slot, done) + return BingoGoal(name, description, GoalType.PERSONAL, slot, done) } private fun getCommunityGoal( @@ -148,10 +147,10 @@ class BingoCardDisplay { ): BingoGoal { if (description == "§7This goal will be revealed §7when it hits Tier IV.") { BingoAPI.getCommunityTip(name)?.let { - return BingoGoal(name, it.getDescriptionLine(), slot, done) + return BingoGoal(name, it.getDescriptionLine(), GoalType.COMMUNITY, slot, done) } } - return BingoGoal(name, description, slot, done) + return BingoGoal(name, description, GoalType.COMMUNITY, slot, done) } @SubscribeEvent @@ -170,7 +169,7 @@ class BingoCardDisplay { private fun drawDisplay(): MutableList { val newList = mutableListOf() - if (BingoAPI.communityGoals.isEmpty()) { + if (BingoAPI.bingoGoals.isEmpty()) { newList.add("§6Bingo Goals:") newList.add("§cOpen the §e/bingo §ccard.") } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoal.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoal.kt new file mode 100644 index 000000000..c999e15ae --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoal.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.features.bingo.card + +class BingoGoal(val displayName: String, val description: String, val type: GoalType, val slot: Int, var done: Boolean) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt deleted file mode 100644 index 87a408714..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt +++ /dev/null @@ -1,4 +0,0 @@ -package at.hannibal2.skyhanni.features.bingo.card - - -class BingoGoal(val displayName: String, val description: String, val slot: Int, var done: Boolean) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/GoalType.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/GoalType.kt new file mode 100644 index 000000000..01b59e610 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/GoalType.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.features.bingo.card + +enum class GoalType { + COMMUNITY, + PERSONAL, + ; +} -- cgit