From ca4e3dcf0bdf78a48131cd2e925b81904cd86a4b Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:03:34 +0200 Subject: Fix: SkyHanni forcing Vanilla Scoreboard to show while using Apec (#1592) --- .../customscoreboard/CustomScoreboardConfig.java | 3 ++- .../gui/customscoreboard/DisplayConfig.java | 3 ++- .../gui/customscoreboard/CustomScoreboard.kt | 25 ++++++++++++++++++---- .../gui/customscoreboard/ScoreboardElements.kt | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java index 126d4646e..b6151bd85 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java @@ -9,6 +9,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; import java.util.ArrayList; import java.util.List; @@ -21,7 +22,7 @@ public class CustomScoreboardConfig { ) @ConfigEditorBoolean @FeatureToggle - public boolean enabled = false; + public Property enabled = Property.of(false); @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java index 1c04dacd6..30008a0d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java @@ -7,6 +7,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; public class DisplayConfig { @@ -51,7 +52,7 @@ public class DisplayConfig { "\nĀ§cUsing mods that add their own scoreboard will not be affected by this setting!") @ConfigEditorBoolean @FeatureToggle - public boolean hideVanillaScoreboard = true; + public Property hideVanillaScoreboard = Property.of(true); @Expose @ConfigOption(name = "Display Numbers First", desc = "Determines whether the number or line name displays first. " + diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt index 957808fb5..4182b37bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt @@ -21,11 +21,13 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.GuiPositionMovedEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAlignedWidth @@ -142,11 +144,26 @@ class CustomScoreboard { return this } + private var dirty = false + // Thank you Apec for showing that the ElementType of the stupid scoreboard is FUCKING HELMET WTF @SubscribeEvent fun onRenderScoreboard(event: RenderGameOverlayEvent.Post) { if (event.type == RenderGameOverlayEvent.ElementType.HELMET) { - GuiIngameForge.renderObjective = !isHideVanillaScoreboardEnabled() + if (isHideVanillaScoreboardEnabled()) { + GuiIngameForge.renderObjective = false + } + if (dirty) { + GuiIngameForge.renderObjective = true + dirty = false + } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + onToggle(config.enabled, displayConfig.hideVanillaScoreboard) { + if (!isHideVanillaScoreboardEnabled()) dirty = true } } @@ -154,7 +171,7 @@ class CustomScoreboard { fun onDebugDataCollect(event: DebugDataCollectEvent) { event.title("Custom Scoreboard") event.addIrrelevant { - if (!config.enabled) { + if (!config.enabled.get()) { add("Custom Scoreboard disabled.") } else { ScoreboardElement.entries.map { element -> @@ -168,8 +185,8 @@ class CustomScoreboard { } } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled.get() + private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard.get() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 41e946a17..e3569a856 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -786,6 +786,7 @@ private fun getExtraDisplayPair(): List { "Unknown Lines" to unknownLines, "Island" to HypixelData.skyBlockIsland, "Area" to HypixelData.skyBlockArea, + "Full Scoreboard" to ScoreboardData.sidebarLinesFormatted, noStackTrace = true, betaOnly = true, ) -- cgit