aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-01 12:16:14 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-01 12:16:14 +0100
commit3c1d534472fbd83a24799a3df7ce7c80c764597e (patch)
tree4b762ced0489728f938f1c21a2273242ef7d37c6
parent9f2118dfc218a6b97e4d7d67e7fb9dbd7431cf54 (diff)
downloadskyhanni-3c1d534472fbd83a24799a3df7ce7c80c764597e.tar.gz
skyhanni-3c1d534472fbd83a24799a3df7ce7c80c764597e.tar.bz2
skyhanni-3c1d534472fbd83a24799a3df7ce7c80c764597e.zip
Add support for hidden bingo tips.
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt (renamed from src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt)7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt49
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt54
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt4
6 files changed, 84 insertions, 33 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 0e2e49a9b..5d4f61e44 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -8,7 +8,6 @@ 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
@@ -53,6 +52,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod
import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard
import at.hannibal2.skyhanni.features.bazaar.BazaarOpenPriceWebsite
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper
+import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay
import at.hannibal2.skyhanni.features.bingo.BingoCardTips
import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index aa78bec09..1b0b46352 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
diff --git a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
index 5ba6c84dd..6941e7f57 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
@@ -1,15 +1,18 @@
-package at.hannibal2.skyhanni.data
+package at.hannibal2.skyhanni.features.bingo
-import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson
import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoRanksJson
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object BingoAPI {
private var ranks = mapOf<String, Int>()
+ var tips: Map<String, BingoJson.BingoTip> = emptyMap()
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
ranks = event.getConstant<BingoRanksJson>("BingoRanks").ranks
+ tips = event.getConstant<BingoJson>("Bingo").bingo_tips
}
fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value
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 8951272c1..d6d84ff82 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson.BingoTip
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
@@ -81,6 +82,8 @@ class BingoCardDisplay {
}
}
+ private fun BingoTip.getDescriptionLine() = "§7" + note.joinToString(" ")
+
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!LorenzUtils.isBingoProfile) return
@@ -90,9 +93,9 @@ class BingoCardDisplay {
personalGoals.clear()
communityGoals.clear()
for (stack in event.inventoryItems.values) {
- val personalGoal = stack.getLore().any { it.endsWith("Personal Goal") }
- val communityGoal = stack.getLore().any { it.endsWith("Community Goal") }
- if (!personalGoal && !communityGoal) continue
+ val isPersonalGoal = stack.getLore().any { it.endsWith("Personal Goal") }
+ val isCommunityGoal = stack.getLore().any { it.endsWith("Community Goal") }
+ if (!isPersonalGoal && !isCommunityGoal) continue
val name = stack.name?.removeColor() ?: continue
val lore = stack.getLore()
var index = 0
@@ -114,15 +117,49 @@ class BingoCardDisplay {
}
val done = stack.getLore().any { it.contains("GOAL REACHED") }
- if (personalGoal) {
- personalGoals.add(PersonalGoal(name, description, done))
+ if (isPersonalGoal) {
+ personalGoals.add(getPersonalGoal(name, description, done))
} else {
- communityGoals.add(CommunityGoal(name, description, done))
+ communityGoals.add(getCommunityGoal(name, description, done))
}
}
lastBingoCardOpenTime = SimpleTimeMark.now()
update()
+ for (goal in personalGoals) {
+ println("goal.displayName: '${goal.displayName}' - ${goal.description}")
+ }
+ }
+
+ private fun getPersonalGoal(
+ name: String,
+ description: String,
+ done: Boolean
+ ): PersonalGoal {
+ var personalGoal = PersonalGoal(name, description, done)
+ if (!done) {
+ personalHiddenGoalPattern.matchMatcher(description) {
+ BingoAPI.tips[name]?.let {
+ personalGoal = PersonalGoal(name, it.getDescriptionLine(), false)
+ }
+ }
+ }
+ return personalGoal
+ }
+
+ private fun getCommunityGoal(
+ name: String,
+ description: String,
+ done: Boolean
+ ): CommunityGoal {
+ if (!done) {
+ if (description == "§7This goal will be revealed §7when it hits Tier IV.") {
+ BingoAPI.tips[name]?.let {
+ return CommunityGoal(name, it.getDescriptionLine(), false)
+ }
+ }
+ }
+ return CommunityGoal(name, description, done)
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
index 2486166a5..22925b405 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
@@ -1,44 +1,52 @@
package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson.BingoTip
import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.getOrNull
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson
-import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson.BingoTip
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class BingoCardTips {
- private var tips: Map<String, BingoTip> = emptyMap()
-
- @SubscribeEvent
- fun onRepoReload(event: RepositoryReloadEvent) {
- tips = event.getConstant<BingoJson>("Bingo").bingo_tips
- }
@SubscribeEvent
fun onItemTooltipLow(event: ItemTooltipEvent) {
if (!isEnabled()) return
if (InventoryUtils.openInventoryName() != "Bingo Card") return
- val itemName = event.itemStack?.name ?: return
- tips[itemName.removeColor()]?.let {
- val difficulty = Difficulty.valueOf(it.difficulty.uppercase())
- event.toolTip[0] = event.toolTip[0] + " §7(" + difficulty.displayName + "§7)"
+ val itemName = event.itemStack?.name?.removeColor() ?: return
- var index = event.toolTip.indexOf("§5§o§7Reward") - 1
- event.toolTip.add(index++, "")
- event.toolTip.add(index++, "§eGuide:")
- for (line in it.note) {
- event.toolTip.add(index++, line)
- }
+ val toolTip = event.toolTip
+ val communityGoal = toolTip.getOrNull(1) == "§5§o§8Community Goal"
+ val bingoTip: BingoTip = if (communityGoal) {
+ BingoAPI.tips.filter { itemName.startsWith(it.key) }.values.firstOrNull() ?: return
+ } else {
+ BingoAPI.tips[itemName] ?: return
+ }
+
+ if (!communityGoal) {
+ val difficulty = Difficulty.valueOf(bingoTip.difficulty.uppercase())
+ toolTip[0] = toolTip[0] + " §7(" + difficulty.displayName + "§7)"
+ }
+
+ var index = if (!communityGoal) {
+ toolTip.indexOf("§5§o§7Reward")
+ } else {
+ toolTip.indexOfFirst { it.startsWith("§5§o§7Contribution Rewards") }
+ } - 1
+
+ toolTip.add(index++, "")
+ toolTip.add(index++, "§eGuide:")
+ for (line in bingoTip.note) {
+ toolTip.add(index++, line)
}
}
@@ -53,11 +61,13 @@ class BingoCardTips {
for (slot in chest.inventorySlots) {
if (slot == null) continue
if (slot.slotNumber != slot.slotIndex) continue
- if (slot.stack == null) continue
+ val stack = slot.stack ?: continue
- val itemName = slot.stack.name ?: continue
+ val itemName = stack.name ?: continue
+ val communityGoal = stack.getLore().getOrNull(1) == "§8Community Goal"
+ if (communityGoal) continue
- tips[itemName.removeColor()]?.let {
+ BingoAPI.tips[itemName.removeColor()]?.let {
val difficulty = Difficulty.valueOf(it.difficulty.uppercase())
slot highlight difficulty.color.addOpacity(120)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
index 9275b6ea7..2eac62d1f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
@@ -1,12 +1,13 @@
package at.hannibal2.skyhanni.features.misc.compacttablist
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.BingoAPI
import at.hannibal2.skyhanni.data.FriendAPI
import at.hannibal2.skyhanni.data.GuildAPI
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.PartyAPI
+import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorListJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.KeyboardManager
@@ -14,7 +15,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorListJson
import com.google.common.cache.CacheBuilder
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.concurrent.TimeUnit