diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt | 22 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt | 4 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt index 758c20110..88ac4bc1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.StringUtils.removeSFormattingCode @@ -49,12 +51,12 @@ object TabListReader { val renderColumns = mutableListOf<RenderColumn>() - @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { + + private fun updateTablistData(tablist: List<String>? = null) { if (!LorenzUtils.inSkyBlock) return - if (!config.enabled) return + if (!config.enabled.get()) return - var tabLines = event.tabList + var tabLines = tablist ?: TabListData.getTabList() if (tabLines.size < 80) return @@ -75,6 +77,11 @@ object TabListReader { combineColumnsToRender(columns, renderColumn) } + @SubscribeEvent + fun onTabListUpdate(event: TabListUpdateEvent) { + updateTablistData(event.tabList) + } + private fun parseColumns(original: List<String>): MutableList<TabColumn> { val columns = mutableListOf<TabColumn>() val fullTabList = AdvancedPlayerList.newSorting(original) @@ -244,4 +251,11 @@ object TabListReader { } } } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(config.enabled) { + updateTablistData() + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt index ccb70bd8f..8bd2bfefe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt @@ -31,7 +31,7 @@ object TabListRenderer { fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { if (!LorenzUtils.inSkyBlock) return if (event.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return - if (!config.enabled) return + if (!config.enabled.get()) return event.isCanceled = true if (config.toggleTab) return @@ -45,7 +45,7 @@ object TabListRenderer { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - if (!config.enabled) return + if (!config.enabled.get()) return if (!config.toggleTab) return if (Minecraft.getMinecraft().currentScreen != null) return |