diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-10 15:13:54 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-10 15:13:54 +0200 |
commit | 89800c13c199eabb403eee2a11873f1a60b64f70 (patch) | |
tree | 99c7d27a2a1af6044ab11cede9706f57e764c30d /src/main/java/at/hannibal2 | |
parent | a009b1082453841aa0784233fc158e82aba50fed (diff) | |
download | skyhanni-89800c13c199eabb403eee2a11873f1a60b64f70.tar.gz skyhanni-89800c13c199eabb403eee2a11873f1a60b64f70.tar.bz2 skyhanni-89800c13c199eabb403eee2a11873f1a60b64f70.zip |
Show tips and difficulty for bingo goals inside the bingo card inventory (Data from Bingo Splash Community)
Diffstat (limited to 'src/main/java/at/hannibal2')
4 files changed, 108 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 162e62e2f..02997ea82 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -11,10 +11,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper -import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay -import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper -import at.hannibal2.skyhanni.features.bingo.CompactBingoChat -import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper +import at.hannibal2.skyhanni.features.bingo.* import at.hannibal2.skyhanni.features.chat.ChatFilter import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter @@ -270,6 +267,7 @@ class SkyHanniMod { loadModule(InquisitorWaypointShare) loadModule(TrevorFeatures()) loadModule(TrevorSolver) + loadModule(BingoCardTips()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java b/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java index 4e973d7f7..c70346516 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java @@ -32,6 +32,15 @@ public class Bingo { public Property<Boolean> hideCommunityGoals = Property.of(false); @Expose + @ConfigOption( + name = "Show Guide", + desc = "Show tips and difficulty for bingo goals inside the bingo card inventory. " + + "§7(§ePowdered by Bingo Splash Community§7)" + ) + @ConfigEditorBoolean + public boolean bingoSplashGuide = true; + + @Expose public Position bingoCardPos = new Position(10, 10, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt new file mode 100644 index 000000000..769872409 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt @@ -0,0 +1,79 @@ +package at.hannibal2.skyhanni.features.bingo + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.jsonobjects.BingoJson +import at.hannibal2.skyhanni.utils.jsonobjects.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) { + event.getConstant<BingoJson>("Bingo")?.let { + tips = it.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)" + + 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) + } + } + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isEnabled()) return + if (InventoryUtils.openInventoryName() != "Bingo Card") return + + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + + for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + if (slot.stack == null) continue + + val itemName = slot.stack.name ?: continue + + tips[itemName.removeColor()]?.let { + val difficulty = Difficulty.valueOf(it.difficulty.uppercase()) + slot highlight difficulty.color.addOpacity(120) + } + } + } + + fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.bingo.bingoCard.bingoSplashGuide + + enum class Difficulty(rawName: String, val color: LorenzColor) { + EASY("Easy", LorenzColor.GREEN), + MEDIUM("Medium", LorenzColor.YELLOW), + HARD("Hard", LorenzColor.RED), + ; + + val displayName = color.getChatColor() + rawName + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java new file mode 100644 index 000000000..472993c46 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; +import java.util.Map; + +public class BingoJson { + @Expose + public Map<String, BingoTip> bingo_tips; + + public static class BingoTip { + @Expose + public String difficulty; + @Expose + public List<String> note; + } +} |