From 031dc17d1cfbf4700aeed10f13b408b6807e7e3c Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:55:45 +0100 Subject: [PATCH 1/7] use clickTypeEnum Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt | 6 ++---- .../features/garden/visitor/VisitorRewardWarning.kt | 2 +- .../hannibal2/skyhanni/features/inventory/HarpFeatures.kt | 5 +++-- .../inventory/chocolatefactory/ChocolateFactoryInventory.kt | 2 +- .../inventory/chocolatefactory/ChocolateFactoryKeybinds.kt | 2 +- .../at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt | 3 ++- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt index 14d90a6e9c67..ae8808187670 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt @@ -77,13 +77,11 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: val slot: Slot?, val slotId: Int, val clickedButton: Int, - @Deprecated("old", ReplaceWith("clickTypeEnum")) - val clickType: Int, - val clickTypeEnum: ClickType? = ClickType.getTypeById(clickType), + val clickType: ClickType?, ) : GuiContainerEvent(gui, container) { fun makePickblock() { - if (this.clickedButton == 2 && this.clickTypeEnum == ClickType.MIDDLE) return + if (this.clickedButton == 2 && this.clickType == ClickType.MIDDLE) return slot?.slotNumber?.let { slotNumber -> InventoryUtils.clickSlot(slotNumber, container.windowId, 2, 3) isCanceled = true diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt index 56e85b582463..504e5a03793c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt @@ -71,7 +71,7 @@ object VisitorRewardWarning { } // all but shift click types work for accepting visitor - if (event.clickTypeEnum == GuiContainerEvent.ClickType.SHIFT) return + if (event.clickType == GuiContainerEvent.ClickType.SHIFT) return if (isRefuseSlot) { VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.REFUSED, "refused") // fallback if tab list is disabled diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt index 1fc8a25b4c06..2d52ebd71b7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt @@ -158,7 +158,7 @@ object HarpFeatures { if (isHarpGui(InventoryUtils.openInventoryName())) { if (config.keybinds) { // needed to not send duplicate clicks via keybind feature - if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) { + if (event.clickType == GuiContainerEvent.ClickType.HOTBAR) { event.cancel() return } @@ -172,8 +172,9 @@ object HarpFeatures { event.container.inventory.filterNotNull().indexOfFirst { songSelectedPattern.anyMatches(it.getLore()) }.takeIf { it != -1 }?.let { + val clickType = event.clickType?.id ?: return event.cancel() - InventoryUtils.clickSlot(it, event.container.windowId, event.clickedButton, event.clickType) + InventoryUtils.clickSlot(it, event.container.windowId, event.clickedButton, clickType) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt index 46deb6987ffd..6d10b7d633c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt @@ -101,7 +101,7 @@ object ChocolateFactoryInventory { ) return // this would break ChocolateFactoryKeybinds otherwise - if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) return + if (event.clickType == GuiContainerEvent.ClickType.HOTBAR) return // if the user is holding shift, we don't want to pickblock, handled by hypixel as +10 levels for rabbits if (KeyboardManager.isShiftKeyDown() && slotNumber in ChocolateFactoryAPI.rabbitSlots.keys) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt index 50d548763ec1..248f848f409b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt @@ -45,7 +45,7 @@ object ChocolateFactoryKeybinds { if (!ChocolateFactoryAPI.inChocolateFactory) return // needed to not send duplicate clicks via keybind feature - if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) { + if (event.clickType == GuiContainerEvent.ClickType.HOTBAR) { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt index 1fd951c8bb36..a3ddc8800f6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.mixins.hooks import at.hannibal2.skyhanni.data.GuiData import at.hannibal2.skyhanni.events.DrawScreenAfterEvent import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.GuiContainerEvent.ClickType import at.hannibal2.skyhanni.events.GuiContainerEvent.CloseWindowEvent import at.hannibal2.skyhanni.events.GuiContainerEvent.SlotClickEvent import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests @@ -68,7 +69,7 @@ class GuiContainerHook(guiAny: Any) { fun onMouseClick(slot: Slot?, slotId: Int, clickedButton: Int, clickType: Int, ci: CallbackInfo) { val item = gui.inventorySlots?.inventory?.takeIf { it.size > slotId && slotId >= 0 }?.get(slotId) - if (SlotClickEvent(gui, gui.inventorySlots, item, slot, slotId, clickedButton, clickType).postAndCatch() + if (SlotClickEvent(gui, gui.inventorySlots, item, slot, slotId, clickedButton, ClickType.getTypeById(clickType)).postAndCatch() ) ci.cancel() } From de8def6fb60b4eba1f739455b9ea55e690a0a3d8 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:07:31 +0100 Subject: [PATCH 2/7] use widgetUpdateEvent in repu helper Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../skyhanni/data/model/TabWidget.kt | 2 +- .../CrimsonIsleReputationHelper.kt | 25 +++++++++---------- .../nether/reputationhelper/FactionType.kt | 12 ++++++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt index 66ca5e9d051b..e2a1be42bc8c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -224,7 +224,7 @@ enum class TabWidget( ), REPUTATION( // language=RegExp - "(?:§.)*(Barbarian|Mage) Reputation:", + "(?:§.)*(?Barbarian|Mage) Reputation:", ), FACTION_QUESTS( // language=RegExp diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 37cff1b21bc4..fe874af67998 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -7,11 +7,13 @@ import at.hannibal2.skyhanni.config.features.crimsonisle.ReputationHelperConfig. import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SackChangeEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.QuestLoader import at.hannibal2.skyhanni.features.nether.reputationhelper.kuudra.DailyKuudraBossHelper @@ -24,6 +26,7 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -95,6 +98,15 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { dirty = true } + @HandleEvent + fun onWidgetUpdate(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.REPUTATION)) return + + event.widget.pattern.firstMatcher(event.lines) { + factionType = FactionType.fromName(group("faction")) + } + } + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!IslandType.CRIMSON_ISLE.isInIsland()) return @@ -106,19 +118,6 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { dirty = false updateRender() } - - if (event.repeatSeconds(3)) { - val list = TabListData.getTabList().filter { it.contains("Reputation:") } - for (line in list) { - factionType = if (line.contains("Mage")) { - FactionType.MAGE - } else if (line.contains("Barbarian")) { - FactionType.BARBARIAN - } else { - FactionType.NONE - } - } - } } private fun updateRender() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/FactionType.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/FactionType.kt index d531aa8f4996..cde3ddd4c132 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/FactionType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/FactionType.kt @@ -1,8 +1,12 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper -enum class FactionType { - BARBARIAN, - MAGE, +enum class FactionType(val factionName: String) { + BARBARIAN("Barbarian"), + MAGE("Mage"), + NONE("None"), + ; - NONE + companion object { + fun fromName(name: String) = entries.firstOrNull { it.factionName.equals(name, ignoreCase = true) } ?: NONE + } } From 4d87705ef5c66e99aa413b1dd79812a17e3c257e Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:31:38 +0100 Subject: [PATCH 3/7] use renderables in repu helper Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../CrimsonIsleReputationHelper.kt | 47 ++++++++++--------- .../dailyquest/DailyQuestHelper.kt | 32 +++++++------ .../kuudra/DailyKuudraBossHelper.kt | 24 ++++++---- .../miniboss/DailyMiniBossHelper.kt | 25 ++++++---- 4 files changed, 75 insertions(+), 53 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index fe874af67998..dc174911ea2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -19,7 +19,7 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.QuestLo import at.hannibal2.skyhanni.features.nether.reputationhelper.kuudra.DailyKuudraBossHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld @@ -27,8 +27,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiInventory @@ -45,7 +45,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { var factionType = FactionType.NONE - private var display = emptyList>() + private var display = emptyList() private var dirty = true var tabListQuestsMissing = false @@ -121,23 +121,28 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { } private fun updateRender() { - val newList = mutableListOf>() - - // TODO test - if (factionType == FactionType.NONE) return - - newList.addAsSingletonList("§e§lReputation Helper") - if (tabListQuestsMissing) { - newList.addAsSingletonList("§cFaction Quests Widget not found!") - newList.addAsSingletonList("§7Open §e/tab §7and enable it!") - } else { - questHelper.render(newList) - miniBossHelper.render(newList) - kuudraBossHelper.render(newList) + display = buildList { + addString("§e§lReputation Helper") + if (factionType == FactionType.NONE) { + addString("§cFaction not found!") + return + } + + if (tabListQuestsMissing) { + addString("§cFaction Quests Widget not found!") + addString("§7Open §e/tab §7and enable it!") + } else { + questHelper.run { + addQuests() + } + miniBossHelper.run { + addDailyMiniBoss() + } + kuudraBossHelper.run { + addKuudraBoss() + } + } } - - - display = newList } @SubscribeEvent(priority = EventPriority.LOWEST) @@ -149,7 +154,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { return } - config.position.renderStringsAndItems( + config.position.renderRenderables( display, posLabel = "Crimson Isle Reputation Helper", ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index c0ab56af3c5c..42cf88cbe66d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -29,7 +29,8 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.T import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.UnknownQuest import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName @@ -45,6 +46,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -227,23 +229,23 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { state == QuestState.READY_TO_COLLECT || (this is RescueMissionQuest && state == QuestState.ACCEPTED) } - fun render(display: MutableList>) { + fun MutableList.addQuests() { if (greatSpook) { - display.addAsSingletonList("") - display.addAsSingletonList("§7Daily Quests (§cdisabled§7)") - display.addAsSingletonList(" §5§lThe Great Spook §7happened :O") + addString("") + addString("§7Daily Quests (§cdisabled§7)") + addString(" §5§lThe Great Spook §7happened :O") return } val done = quests.count { it.state == QuestState.COLLECTED } - display.addAsSingletonList("") - display.addAsSingletonList("§7Daily Quests (§e$done§8/§e5 collected§7)") + addString("") + addString("§7Daily Quests (§e$done§8/§e5 collected§7)") if (done != 5) { val filteredQuests = quests.filter { !config.hideComplete.get() || it.state != QuestState.COLLECTED } - filteredQuests.mapTo(display) { renderQuest(it) } + addAll(filteredQuests.map { renderQuest(it) }) } } - private fun renderQuest(quest: Quest): List { + private fun renderQuest(quest: Quest): Renderable { val category = quest.category val state = quest.state.displayName val stateColor = quest.state.color @@ -275,7 +277,6 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { "" } - val result = mutableListOf() val item = quest.displayItem.getItemStack() val displayName = if (category == QuestCategory.FETCH || category == QuestCategory.FISHING) { @@ -287,10 +288,13 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { val categoryName = category.displayName - result.add(" $stateText$categoryName: ") - result.add(item) - result.add("§f$displayName$progressText$sacksText") - return result + return Renderable.horizontalContainer( + buildList { + addString(" $stateText$categoryName: ") + addItemStack(item) + addString("§f$displayName$progressText$sacksText") + }, + ) } fun finishMiniBoss(miniBoss: CrimsonMiniBoss) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt index ed9e6ebc2421..e34b2bfee4e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt @@ -10,13 +10,15 @@ import at.hannibal2.skyhanni.events.kuudra.KuudraCompleteEvent import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -52,21 +54,25 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH reputationHelper.update() } - fun render(display: MutableList>) { + fun MutableList.addKuudraBoss() { val done = kuudraTiers.count { it.doneToday } - display.addAsSingletonList("") - display.addAsSingletonList("§7Daily Kuudra (§e$done§8/§e5 killed§7)") + addString("") + addString("§7Daily Kuudra (§e$done§8/§e5 killed§7)") if (done < 5) { for (tier in kuudraTiers) { if (config.hideComplete.get() && tier.doneToday) continue val result = if (tier.doneToday) "§aDone" else "§bTodo" val displayName = tier.getDisplayName() val displayItem = tier.displayItem - val lineList = mutableListOf() - lineList.add(" ") - lineList.add(displayItem.getItemStack()) - lineList.add("$displayName: $result") - display.add(lineList) + + val row = Renderable.horizontalContainer( + buildList { + addString(" ") + addItemStack(displayItem.getItemStack()) + addString("$displayName: $result") + }, + ) + add(row) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index e2376ca196dd..5a25faf61098 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -10,7 +10,8 @@ import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorMana import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.MiniBossQuest import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.QuestState -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -18,6 +19,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -64,10 +66,12 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel reputationHelper.update() } - fun render(display: MutableList>) { + fun MutableList.addDailyMiniBoss() { val done = miniBosses.count { it.doneToday } - display.addAsSingletonList("") - display.addAsSingletonList("§7Daily Bosses (§e$done§8/§e5 killed§7)") + + addString("") + addString("§7Daily Bosses (§e$done§8/§e5 killed§7)") + if (done != 5) { for (miniBoss in miniBosses) { if (config.hideComplete.get() && miniBoss.doneToday) continue @@ -75,11 +79,14 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel val displayName = miniBoss.displayName val displayItem = miniBoss.displayItem - val lineList = mutableListOf() - lineList.add(" ") - lineList.add(displayItem.getItemStack()) - lineList.add("§5$displayName§7: $result") - display.add(lineList) + val row = Renderable.horizontalContainer( + buildList { + addString(" ") + addItemStack(displayItem.getItemStack()) + addString("§5$displayName§7: $result") + }, + ) + add(row) } } } From a95133f1c44cb5a2957d2a86a38800add74a278b Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:46:05 +0100 Subject: [PATCH 4/7] update baseline Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- versions/1.8.9/detekt/baseline.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index 05f1fbb4a71f..8b74f0d22912 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -24,7 +24,6 @@ CyclomaticComplexMethod:PacketTest.kt$PacketTest$private fun Packet<*>.print() CyclomaticComplexMethod:ParkourHelper.kt$ParkourHelper$fun render(event: LorenzRenderWorldEvent) CyclomaticComplexMethod:Renderable.kt$Renderable.Companion$internal fun shouldAllowLink(debug: Boolean = false, bypassChecks: Boolean): Boolean - CyclomaticComplexMethod:SkillProgress.kt$SkillProgress$private fun drawDisplay() CyclomaticComplexMethod:VampireSlayerFeatures.kt$VampireSlayerFeatures$private fun EntityOtherPlayerMP.process() CyclomaticComplexMethod:VisualWordGui.kt$VisualWordGui$override fun drawScreen(unusedX: Int, unusedY: Int, partialTicks: Float) InjectDispatcher:ClipboardUtils.kt$ClipboardUtils$IO @@ -61,7 +60,6 @@ MemberNameEqualsClassName:TestBingo.kt$TestBingo$var testBingo = false MemberNameEqualsClassName:Text.kt$Text$fun text(text: String, init: IChatComponent.() -> Unit = {}) NoNameShadowing:BucketedItemTrackerData.kt$BucketedItemTrackerData${ it.hidden = !it.hidden } - NoNameShadowing:BurrowWarpHelper.kt$BurrowWarpHelper${ it.startsWith("§bWarp to ") } NoNameShadowing:ContributorManager.kt$ContributorManager${ it.isAllowed() } NoNameShadowing:Graph.kt$Graph.Companion${ out.name("Name").value(it) } NoNameShadowing:Graph.kt$Graph.Companion${ out.name("Tags") out.beginArray() for (tagName in it) { out.value(tagName) } out.endArray() } @@ -202,8 +200,6 @@ RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "cleared", "§aCleared your quiver!|§c§lYour quiver is now completely empty!", ) RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "ranout", "§c§lQUIVER! §cYou have run out of §f(?<type>.*)s§c!", ) RepoPatternRegexTest:RestorePieceOfWizardPortalLore.kt$RestorePieceOfWizardPortalLore$by RepoPattern.pattern( "misc.restore.wizard.portal.earned", "§7Earned by:.*" ) - RepoPatternRegexTest:RiftBloodEffigies.kt$RiftBloodEffigies$by patternGroup.pattern( "heart", "Effigies: (?<hearts>(?:(?:§[7c])?⧯)*)" ) - RepoPatternRegexTest:RiftBloodEffigies.kt$RiftBloodEffigies$by patternGroup.pattern( "respawn", "§eRespawn §c(?<time>.*) §7\\(or click!\\)" ) RepoPatternRegexTest:ScoreboardPattern.kt$ScoreboardPattern$by dungeonSb.pattern( "cleared", "(?:§.)*Cleared: (?:§.)*(?<percent>[\\w,.]+)% (?:§.)*\\((?:§.)*(?<score>[\\w,.]+)(?:§.)*\\)", ) RepoPatternRegexTest:ScoreboardPattern.kt$ScoreboardPattern$by dungeonSb.pattern( "keys", "Keys: §.■ §.[✗✓] §.■ §a.x", ) RepoPatternRegexTest:ScoreboardPattern.kt$ScoreboardPattern$by dungeonSb.pattern( "teammates", "(?:§.)*(?<classAbbv>\\[\\w]) (?:§.)*(?<username>\\w{2,16}) (?:(?:§.)*(?<classLevel>\\[Lvl?(?<level>[\\w,.]+)?]?)|(?:§.)*(?<health>[\\w,.]+)(?:§.)*.?)", ) From 11ab5d6849dde03d098ad6ad9651af8fc4379596 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:04:43 +0100 Subject: [PATCH 5/7] use thunders method Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../nether/reputationhelper/CrimsonIsleReputationHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index dc174911ea2b..d5262dc073d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -102,7 +102,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { fun onWidgetUpdate(event: WidgetUpdateEvent) { if (!event.isWidget(TabWidget.REPUTATION)) return - event.widget.pattern.firstMatcher(event.lines) { + TabWidget.REPUTATION.matchMatcherFirstLine(){ factionType = FactionType.fromName(group("faction")) } } From 7a0d0c0be4d0c68387aae07958857bf273a275f6 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:11:39 +0100 Subject: [PATCH 6/7] detekt Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../nether/reputationhelper/CrimsonIsleReputationHelper.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index d5262dc073d8..a5144f7df01a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -26,7 +26,6 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -102,7 +101,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { fun onWidgetUpdate(event: WidgetUpdateEvent) { if (!event.isWidget(TabWidget.REPUTATION)) return - TabWidget.REPUTATION.matchMatcherFirstLine(){ + TabWidget.REPUTATION.matchMatcherFirstLine() { factionType = FactionType.fromName(group("faction")) } } From a719cb31d11c6641027514e952a6ec0a3913a747 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:12:01 +0100 Subject: [PATCH 7/7] detekt Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../nether/reputationhelper/CrimsonIsleReputationHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index a5144f7df01a..a6702de9d530 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -101,7 +101,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { fun onWidgetUpdate(event: WidgetUpdateEvent) { if (!event.isWidget(TabWidget.REPUTATION)) return - TabWidget.REPUTATION.matchMatcherFirstLine() { + TabWidget.REPUTATION.matchMatcherFirstLine { factionType = FactionType.fromName(group("faction")) } }