Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix + Backend: Profit Tracker rendering #3287

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public class ArmorDropTrackerConfig {

@Expose
@ConfigLink(owner = ArmorDropTrackerConfig.class, field = "enabled")
// TODO rename to position
public Position pos = new Position(16, -232, false, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.config.features.combat.EnderNodeConfig.EnderNodeDis
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.events.SackChangeEvent
Expand Down Expand Up @@ -174,11 +173,8 @@ object EnderNodeTracker {
miteGelInInventory = newMiteGelInInventory
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return

tracker.renderDisplay(config.position)
init {
tracker.initRenderer(config.position) { isEnabled() }
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDropsJson
import at.hannibal2.skyhanni.data.model.TabWidget
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.PurseChangeCause
import at.hannibal2.skyhanni.events.PurseChangeEvent
Expand Down Expand Up @@ -282,11 +281,8 @@ object GhostTracker {
parseBestiaryWidget(event.lines)
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return

tracker.renderDisplay(config.position)
init {
tracker.initRenderer(config.position) { isEnabled() }
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.ElectionAPI.getElectionYear
import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.data.jsonobjects.repo.DianaDropsJson
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ItemAddEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
Expand All @@ -22,6 +21,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderDisplayHelper
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.renderables.Renderable
Expand Down Expand Up @@ -154,16 +154,21 @@ object DianaProfitTracker {
}
}

@HandleEvent(onlyOnSkyblock = true)
fun onRenderOverlay(event: GuiRenderEvent) {
if (!config.enabled) return
val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false
if (!DianaAPI.isDoingDiana() && !spadeInHand) return
if (spadeInHand) {
tracker.firstUpdate()
}

tracker.renderDisplay(config.position)
init {
RenderDisplayHelper(
outsideInventory = true,
inOwnInventory = true,
condition = { config.enabled },
onRender = {
val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false
if (!DianaAPI.isDoingDiana() && !spadeInHand) return@RenderDisplayHelper
if (spadeInHand) {
tracker.firstUpdate()
}

tracker.renderDisplay(config.position)
},
)
}

private fun isAllowedItem(internalName: NEUInternalName): Boolean = internalName in allowedDrops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.ElectionAPI.getElectionYear
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
Expand All @@ -16,6 +15,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderDisplayHelper
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.renderables.Searchable
Expand Down Expand Up @@ -132,16 +132,21 @@ object MythologicalCreatureTracker {
}
}

@HandleEvent(onlyOnSkyblock = true)
fun onRenderOverlay(event: GuiRenderEvent) {
if (!config.enabled) return
val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false
if (!DianaAPI.isDoingDiana() && !spadeInHand) return
if (spadeInHand) {
tracker.firstUpdate()
}

tracker.renderDisplay(config.position)
init {
RenderDisplayHelper(
outsideInventory = true,
inOwnInventory = true,
condition = { config.enabled },
onRender = {
val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false
if (!DianaAPI.isDoingDiana() && !spadeInHand) return@RenderDisplayHelper
if (spadeInHand) {
tracker.firstUpdate()
}

tracker.renderDisplay(config.position)
},
)
}

fun resetCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.config.features.event.winter.FrozenTreasureConfig.F
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
import at.hannibal2.skyhanni.events.minecraft.WorldChangeEvent
Expand Down Expand Up @@ -168,13 +167,16 @@ object FrozenTreasureTracker {
}
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!config.enabled) return
if (!onJerryWorkshop()) return
if (config.onlyInCave && !inGlacialCave()) return
init {
tracker.initRenderer(config.position) { shouldShowDisplay() }
}

private fun shouldShowDisplay(): Boolean {
if (!config.enabled) return false
if (!onJerryWorkshop()) return false
if (config.onlyInCave && !inGlacialCave()) return false

tracker.renderDisplay(config.position)
return true
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.data.jsonobjects.repo.FishingProfitItemsJson
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ItemAddEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
Expand All @@ -23,6 +22,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderDisplayHelper
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
Expand Down Expand Up @@ -215,14 +215,18 @@ object FishingProfitTracker {
lastCatchTime = SimpleTimeMark.now()
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return

val recentPickup = config.showWhenPickup && lastCatchTime.passedSince() < 3.seconds
if (recentPickup || FishingAPI.isFishing(checkRodInHand = false)) {
tracker.renderDisplay(config.position)
}
init {
RenderDisplayHelper(
outsideInventory = true,
inOwnInventory = true,
condition = { isEnabled() },
onRender = {
val recentPickup = config.showWhenPickup && lastCatchTime.passedSince() < 3.seconds
if (recentPickup || FishingAPI.isFishing(checkRodInHand = false)) {
tracker.renderDisplay(config.position)
}
},
)
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.features.fishing.tracker
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.fishing.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.fishing.SeaCreatureFishEvent
Expand Down Expand Up @@ -179,12 +178,15 @@ object SeaCreatureTracker {
tracker.firstUpdate()
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
if (!FishingAPI.isFishing(checkRodInHand = false)) return
init {
tracker.initRenderer(config.position) { shouldShowDisplay() }
}

private fun shouldShowDisplay(): Boolean {
if (!isEnabled()) return false
if (!FishingAPI.isFishing(checkRodInHand = false)) return false

tracker.renderDisplay(config.position)
return true
}

fun resetCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropInfo
import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropsJson
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
Expand Down Expand Up @@ -98,14 +97,17 @@ object ArmorDropTracker {
}
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!GardenAPI.inGarden()) return
if (!config.enabled) return
if (!hasArmor) return
if (!GardenAPI.hasFarmingToolInHand()) return
init {
tracker.initRenderer(config.pos) { shouldShowDisplay() }
}

private fun shouldShowDisplay(): Boolean {
if (!GardenAPI.inGarden()) return false
if (!config.enabled) return false
if (!hasArmor) return false
if (!GardenAPI.hasFarmingToolInHand()) return false

tracker.renderDisplay(config.pos)
return true
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
Expand Down Expand Up @@ -168,12 +167,15 @@ object DicerRngDropTracker {
}
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
if (cropInHand == null) return
init {
tracker.initRenderer(config.pos) { shouldShowDisplay() }
}

private fun shouldShowDisplay(): Boolean {
if (!isEnabled()) return false
if (cropInHand == null) return false

tracker.renderDisplay(config.pos)
return true
}

class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Pattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderDisplayHelper
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.renderables.Searchable
Expand Down Expand Up @@ -136,14 +135,7 @@ object PestProfitTracker {
}

init {
RenderDisplayHelper(
outsideInventory = true,
inOwnInventory = true,
condition = { shouldShowDisplay() },
onRender = {
tracker.renderDisplay(config.position)
},
)
tracker.initRenderer(config.position) { shouldShowDisplay() }
}

private fun shouldShowDisplay(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
Expand Down Expand Up @@ -134,7 +133,7 @@ object ChocolateFactoryStrayTracker {
*/
val doradoEscapeStrayPattern by ChocolateFactoryAPI.patternGroup.pattern(
"stray.doradoescape",
".*(?:§.)*(?:but he escaped and left behind|Legend of (?:§.)*El Dorado (?:§.)*grows!).*"
".*(?:§.)*(?:but he escaped and left behind|Legend of (?:§.)*El Dorado (?:§.)*grows!).*",
)
// </editor-fold>

Expand Down Expand Up @@ -212,7 +211,7 @@ object ChocolateFactoryStrayTracker {
"mountain" to { count, list -> list.add("§b$count §6Chocolate ${StringUtils.pluralize(count, "Mountain")}") },
"dorado" to { count, list -> list.add("§b$count §6El Dorado ${StringUtils.pluralize(count, "Sighting")}") },
"stampede" to { count, list -> list.add("§b$count §6${StringUtils.pluralize(count, "Stampede")}") },
"goldenclick" to { count, list -> list.add("§b$count §6Golden ${StringUtils.pluralize(count, "Click")}") }
"goldenclick" to { count, list -> list.add("§b$count §6Golden ${StringUtils.pluralize(count, "Click")}") },
)
}

Expand Down Expand Up @@ -302,10 +301,8 @@ object ChocolateFactoryStrayTracker {
incrementGoldenType("sidedish")
}

@HandleEvent
fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
if (!isEnabled()) return
tracker.renderDisplay(config.strayRabbitTrackerPosition)
init {
tracker.initRenderer(config.strayRabbitTrackerPosition) { isEnabled() }
}

@HandleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
Expand Down Expand Up @@ -246,11 +245,8 @@ object ExperimentsProfitTracker {
tracker.addPriceFromButton(this)
}

@HandleEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return

tracker.renderDisplay(config.position)
init {
tracker.initRenderer(config.position) { isEnabled() }
}

@HandleEvent
Expand Down
Loading
Loading