diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-09-09 15:07:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 15:07:12 +0200 |
commit | 2b4011efc9ef79fc478b44bce4959dc37424138a (patch) | |
tree | ac14c0c20615bb074378e6ea3558a6ffda041f3c | |
parent | 8fb2fbf7e06f6d711a9093334f7fa14df794be20 (diff) | |
download | skyhanni-2b4011efc9ef79fc478b44bce4959dc37424138a.tar.gz skyhanni-2b4011efc9ef79fc478b44bce4959dc37424138a.tar.bz2 skyhanni-2b4011efc9ef79fc478b44bce4959dc37424138a.zip |
Feature: Show Custom Scoreboard outside SkyBlock (#1881)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
8 files changed, 78 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index b67713435..c881cc578 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 56 + const val CONFIG_VERSION = 57 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt b/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt index e334785c5..9180273aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt @@ -18,10 +18,11 @@ enum class OutsideSbFeature(private val displayName: String) { FOLLOWING_LINE("Following Line"), ARROW_TRAIL("Arrow Trail"), HIGHLIGHT_PARTY_MEMBERS("Highlight Party Members"), - MOVEMENT_SPEED("Movement Speed"); + MOVEMENT_SPEED("Movement Speed"), + CUSTOM_SCOREBOARD("Custom Scoreboard (only on Hypixel)"), + ; override fun toString() = displayName - fun isSelected() = - Minecraft.getMinecraft().thePlayer != null && SkyHanniMod.feature.misc.showOutsideSB.contains(this) + fun isSelected() = Minecraft.getMinecraft().thePlayer != null && SkyHanniMod.feature.misc.showOutsideSB.get().contains(this) } 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 0d61401ee..2f0eb502e 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 @@ -71,6 +71,11 @@ public class DisplayConfig { public boolean hideCoinsDifference = false; @Expose + @ConfigOption(name = "Use Custom Lines", desc = "Use custom lines instead of the default ones.") + @ConfigEditorBoolean + public boolean useCustomLines = true; + + @Expose @ConfigOption(name = "Show unclaimed bits", desc = "Show the amount of available Bits that can still be claimed.") @ConfigEditorBoolean public boolean showUnclaimedBits = false; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/TitleAndFooterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/TitleAndFooterConfig.java index 6bb517d6f..1c3bb4304 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/TitleAndFooterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/TitleAndFooterConfig.java @@ -23,10 +23,14 @@ public class TitleAndFooterConfig { public Property<String> customTitle = Property.of("&6&lSKYBLOCK"); @Expose - @ConfigOption(name = "Hypixel's Title Animation", desc = "Will overwrite the custom title with Hypixel's title animation." + - "\nWill also include \"COOP\" if you are in a coop.") + @ConfigOption(name = "Use Custom Title", desc = "Use a custom title instead of the default Hypixel title.") @ConfigEditorBoolean - public boolean useHypixelTitleAnimation = false; + public boolean useCustomTitle = true; + + @Expose + @ConfigOption(name = "Use Custom Title Outside SkyBlock", desc = "Use a custom title outside of SkyBlock.") + @ConfigEditorBoolean + public boolean useCustomTitleOutsideSkyBlock = false; @Expose @ConfigOption(name = "Custom Footer", desc = "What should be displayed as the footer of the scoreboard." + diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index a06055f97..1464d35ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -15,6 +15,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; @@ -121,7 +122,7 @@ public class MiscConfig { @Expose @ConfigOption(name = "Show Outside SkyBlock", desc = "Show these features outside of SkyBlock.") @ConfigEditorDraggableList - public List<OutsideSbFeature> showOutsideSB = new ArrayList<>(); + public Property<List<OutsideSbFeature>> showOutsideSB = Property.of(new ArrayList<>()); @Expose @ConfigOption(name = "Exp Bottles", desc = "Hide all the experience orbs lying on the ground.") 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 93a5b2a13..a3da970c6 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 @@ -12,6 +12,8 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.enums.OutsideSbFeature +import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.GuiPositionMovedEvent @@ -61,7 +63,7 @@ object CustomScoreboard { if (display.isEmpty()) return val render = - if (!TabListData.fullyLoaded && displayConfig.cacheScoreboardOnIslandSwitch && cache.isNotEmpty()) { + if (LorenzUtils.inSkyBlock && !TabListData.fullyLoaded && displayConfig.cacheScoreboardOnIslandSwitch && cache.isNotEmpty()) { cache } else { display @@ -128,7 +130,7 @@ object CustomScoreboard { } // Remove Known Lines, so we can get the unknown ones - UnknownLinesHandler.handleUnknownLines() + if (LorenzUtils.inSkyBlock && displayConfig.useCustomLines) UnknownLinesHandler.handleUnknownLines() } @SubscribeEvent @@ -150,12 +152,27 @@ object CustomScoreboard { internal val informationFilteringConfig get() = config.informationFiltering internal val backgroundConfig get() = config.background - private fun createLines() = buildList<ScoreboardElementType> { + private fun createLines() = when { + !LorenzUtils.inSkyBlock -> addAllNonSkyBlockLines() + !displayConfig.useCustomLines -> addDefaultSkyBlockLines() + else -> addCustomSkyBlockLines() + } + + private fun addAllNonSkyBlockLines() = buildList { + addAll(ScoreboardElement.TITLE.getVisiblePair()) + addAll(activeLines.map { it to HorizontalAlignment.LEFT }) + } + + private fun addDefaultSkyBlockLines() = buildList { + add(ScoreboardData.objectiveTitle to displayConfig.titleAndFooter.alignTitleAndFooter) + addAll(activeLines.map { it to HorizontalAlignment.LEFT }) + } + + private fun addCustomSkyBlockLines() = buildList<ScoreboardElementType> { for (element in config.scoreboardEntries) { val lines = element.getVisiblePair() if (lines.isEmpty()) continue - // Hide consecutive empty lines if ( informationFilteringConfig.hideConsecutiveEmptyLines && lines.first().first == "<empty>" && lastOrNull()?.first?.isEmpty() == true @@ -163,13 +180,11 @@ object CustomScoreboard { continue } - // Adds empty lines if (lines.first().first == "<empty>") { add("" to HorizontalAlignment.LEFT) continue } - // Does not display this line if (lines.any { it.first == "<hidden>" }) { continue } @@ -205,7 +220,11 @@ object CustomScoreboard { @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - ConditionalUtils.onToggle(config.enabled, displayConfig.hideVanillaScoreboard) { + ConditionalUtils.onToggle( + config.enabled, + displayConfig.hideVanillaScoreboard, + SkyHanniMod.feature.misc.showOutsideSB, + ) { if (!isHideVanillaScoreboardEnabled()) dirty = true } } @@ -213,7 +232,7 @@ object CustomScoreboard { @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { runDelayed(2.seconds) { - if (!LorenzUtils.inSkyBlock) dirty = true + if (!LorenzUtils.inSkyBlock || !(LorenzUtils.onHypixel && OutsideSbFeature.CUSTOM_SCOREBOARD.isSelected())) dirty = true } } @@ -235,7 +254,9 @@ object CustomScoreboard { } } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled.get() + private fun isEnabled() = + (LorenzUtils.inSkyBlock || (OutsideSbFeature.CUSTOM_SCOREBOARD.isSelected() && LorenzUtils.onHypixel)) && config.enabled.get() + private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard.get() @SubscribeEvent @@ -327,5 +348,12 @@ object CustomScoreboard { array.add(JsonPrimitive(ScoreboardEvent.NEW_YEAR.name)) array } + event.move( + 57, + "$displayPrefix.titleAndFooter.useHypixelTitleAnimation", + "$displayPrefix.titleAndFooter.useCustomTitle", + ) { + JsonPrimitive(!it.asBoolean) + } } } 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 369fca62e..7636d43eb 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 @@ -64,6 +64,8 @@ internal var unconfirmedUnknownLines = listOf<String>() internal var unknownLinesSet = TimeLimitedSet<String>(1.seconds) { onRemoval(it) } private fun onRemoval(line: String) { + if (!LorenzUtils.inSkyBlock) return + if (!unconfirmedUnknownLines.contains(line)) return if (line !in unconfirmedUnknownLines) return unconfirmedUnknownLines = unconfirmedUnknownLines.filterNot { it == line } confirmedUnknownLines = confirmedUnknownLines.editCopy { add(line) } @@ -360,17 +362,23 @@ enum class ScoreboardElement( } } -private fun getTitleDisplayPair(): List<ScoreboardElementType> = - if (displayConfig.titleAndFooter.useHypixelTitleAnimation) { - listOf(ScoreboardData.objectiveTitle to displayConfig.titleAndFooter.alignTitleAndFooter) - } else { - listOf( - displayConfig.titleAndFooter.customTitle.get().toString() - .replace("&", "§") - .split("\\n") - .map { it to displayConfig.titleAndFooter.alignTitleAndFooter }, +private fun getTitleDisplayPair(): List<ScoreboardElementType> { + val alignment = displayConfig.titleAndFooter.alignTitleAndFooter + + if (!LorenzUtils.inSkyBlock && !displayConfig.titleAndFooter.useCustomTitleOutsideSkyBlock) { + return listOf(ScoreboardData.objectiveTitle to alignment) + } + + return if (displayConfig.titleAndFooter.useCustomTitle) { + listOf(displayConfig.titleAndFooter.customTitle.get().toString() + .replace("&", "§") + .split("\\n") + .map { it to alignment } ).flatten() + } else { + listOf(ScoreboardData.objectiveTitle to alignment) } +} private fun getProfileDisplayPair() = listOf( CustomScoreboardUtils.getProfileTypeSymbol() + HypixelData.profileName.firstLetterUppercase() diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt index 4e102ee34..fa693f648 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.features.misc.ServerRestartTitle import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeResets import java.util.regex.Pattern @@ -18,10 +19,7 @@ object UnknownLinesHandler { fun handleUnknownLines() { val sidebarLines = CustomScoreboard.activeLines - var unknownLines = sidebarLines - .map { it.removeResets() } - .filter { it.isNotBlank() } - .filter { it.trim().length > 3 } + var unknownLines = sidebarLines.map { it.removeResets() }.filter { it.isNotBlank() }.filter { it.trim().length > 3 } /** * Remove known lines with patterns @@ -214,7 +212,9 @@ object UnknownLinesHandler { unknownLines = unknownLines.filter { it !in unknownLinesSet } unknownLines.forEach { - ChatUtils.debug("Unknown Scoreboard line: '$it'") + if (LorenzUtils.inSkyBlock) { + ChatUtils.debug("Unknown Scoreboard line: '$it'") + } unknownLinesSet.add(it) } } |