diff options
Diffstat (limited to 'src/main/java')
3 files changed, 22 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java index 0c2b8d6c6..3545f790c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java @@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; public class CompactTabListConfig { @Expose @@ -13,7 +14,7 @@ public class CompactTabListConfig { //made tablist one word here so both searches will pick it up @ConfigEditorBoolean @FeatureToggle - public boolean enabled = false; + public Property<Boolean> enabled = Property.of(false); @Expose @ConfigOption( 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 |