From 3375bdeca7e47924616c976b23d017c7f52dc071 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:30:11 +0100 Subject: Improvement + Fix: Custom Scoreboard Fixed and Additions Part 2 (#1174) --- .../gui/customscoreboard/BackgroundConfig.java | 2 +- .../gui/customscoreboard/DisplayConfig.java | 18 +++++++++----- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 1 + .../gui/customscoreboard/CustomScoreboard.kt | 17 ++++++------- .../gui/customscoreboard/ScoreboardElements.kt | 29 +++++++++------------- .../gui/customscoreboard/ScoreboardPattern.kt | 2 +- .../gui/customscoreboard/UnknownLinesHandler.kt | 10 +++++--- 7 files changed, 41 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java index 3b4924511..966912d6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java @@ -22,7 +22,7 @@ public class BackgroundConfig { desc = "The color of the background." ) @ConfigEditorColour - public String color = "0:102:0:0:0"; + public String color = "0:80:0:0:0"; @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 874399cfd..e960c5703 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 @@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class DisplayConfig { @@ -31,12 +32,6 @@ public class DisplayConfig { @ConfigEditorBoolean public boolean showAllActiveEvents = false; - @Expose - @ConfigOption(name = "Cache Scoreboard on Island Switch", - desc = "Will stop the Scoreboard from updating while switching islands.\nRemoves the shaking when loading data.") - @ConfigEditorBoolean - public boolean cacheScoreboardOnIslandSwitch = false; - @Expose @ConfigOption(name = "Number Format", desc = "") @ConfigEditorDropdown @@ -85,6 +80,17 @@ public class DisplayConfig { @ConfigEditorBoolean public boolean colorArrowAmount = false; + @Expose + @ConfigOption(name = "Line Spacing", desc = "The amount of space between each line.") + @ConfigEditorSlider(minValue = 0, maxValue = 20, minStep = 1) + public int lineSpacing = 10; + + @Expose + @ConfigOption(name = "Cache Scoreboard on Island Switch", + desc = "Will stop the Scoreboard from updating while switching islands.\nRemoves the shaking when loading data.") + @ConfigEditorBoolean + public boolean cacheScoreboardOnIslandSwitch = false; + @Expose @ConfigOption(name = "Alignment Options", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index c347fcdba..9617d4e37 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -248,6 +248,7 @@ class HypixelData { if (inSkyBlock) { checkIsland() checkSidebar() + getCurrentServerId() } if (inSkyBlock == skyBlock) return 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 96e501d7c..e260976e0 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 @@ -53,7 +53,7 @@ class CustomScoreboard { } else { display } - config.position.renderStringsAlignedWidth(render, posLabel = guiName) + config.position.renderStringsAlignedWidth(render, posLabel = guiName, extraSpace = displayConfig.lineSpacing - 10) } @SubscribeEvent @@ -74,7 +74,7 @@ class CustomScoreboard { // Creating the lines if (event.isMod(5)) { - display = createLines() + display = createLines().removeEmptyLinesFromEdges() if (TabListData.fullyLoaded) { cache = display.toList() } @@ -92,8 +92,7 @@ class CustomScoreboard { } private fun createLines() = buildList { - val configEntries = removeEmptyLinesFromEdges(config.scoreboardEntries) - for (element in configEntries) { + for (element in config.scoreboardEntries) { val line = element.getVisiblePair() // Hide consecutive empty lines @@ -119,13 +118,13 @@ class CustomScoreboard { } } - private fun removeEmptyLinesFromEdges(entries: MutableList): List { + private fun List.removeEmptyLinesFromEdges(): List { if (config.informationFilteringConfig.hideEmptyLinesAtTopAndBottom) { - return entries - .dropWhile { it.getVisiblePair().all { it.first == "" } } - .dropLastWhile { it.getVisiblePair().all { it.first == "" } } + return this + .dropWhile { it.first.isEmpty() } + .dropLastWhile { it.first.isEmpty() } } - return entries + return this } // Thank you Apec for showing that the ElementType of the stupid scoreboard is FUCKING HELMET WTF 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 abd5a04f1..15ce71ed9 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 @@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Comp import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.informationFilteringConfig import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern -import at.hannibal2.skyhanni.mixins.hooks.tryToReplaceScoreboardLine import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.LorenzUtils.inAdvancedMiningIsland @@ -389,15 +388,11 @@ private fun getIslandDisplayPair() = private fun getLocationDisplayPair() = buildList { add( - (tryToReplaceScoreboardLine( - getGroupFromPattern( - ScoreboardData.sidebarLinesFormatted, - ScoreboardPattern.locationPattern, - "location" - ) - )?.trim() - ?: "") to HorizontalAlignment.LEFT - ) + getGroupFromPattern( + ScoreboardData.sidebarLinesFormatted, + ScoreboardPattern.locationPattern, + "location" + ).trim() to HorizontalAlignment.LEFT) val plotLine = ScoreboardData.sidebarLinesFormatted.firstOrNull { ScoreboardPattern.plotPattern.matches(it) } if (plotLine != null) add(plotLine to HorizontalAlignment.LEFT) @@ -427,14 +422,14 @@ private fun getTimeDisplayPair(): List { } private fun getLobbyDisplayPair(): List { - val lobbyCode = getGroupFromPattern( - ScoreboardData.sidebarLinesFormatted, - ScoreboardPattern.lobbyCodePattern, - "code" + val lobbyCode = HypixelData.serverId ?: "" + return listOf( + if (lobbyCode == "") { + "" + } else { + "§8$lobbyCode" + } to HorizontalAlignment.LEFT ) - - val displayValue = if (lobbyCode == "0") "" else "§8$lobbyCode" - return listOf(displayValue to HorizontalAlignment.LEFT) } private fun getPowerDisplayPair() = listOf( diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt index 62d633523..e5b1a9686 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt @@ -79,7 +79,7 @@ object ScoreboardPattern { ) val instanceShutdownPattern by multiUseSb.pattern( "instanceshutdown", - "(§.)*Instance Shutdown: (§.)*(?