diff options
8 files changed, 96 insertions, 62 deletions
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 f009533ba..874399cfd 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 @@ -9,7 +9,8 @@ import io.github.moulberry.moulconfig.annotations.ConfigOption; public class DisplayConfig { @Expose - @ConfigOption(name = "Hide Vanilla Scoreboard", desc = "Hide the vanilla scoreboard.") + @ConfigOption(name = "Hide Vanilla Scoreboard", desc = "Hide the vanilla scoreboard." + + "\n§cUsing mods that add their own scoreboard will not be affected by this setting!") @ConfigEditorBoolean @FeatureToggle public boolean hideVanillaScoreboard = true; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/InformationFilteringConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/InformationFilteringConfig.java index 02a8f83a0..47a0765fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/InformationFilteringConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/InformationFilteringConfig.java @@ -16,6 +16,11 @@ public class InformationFilteringConfig { public boolean hideConsecutiveEmptyLines = true; @Expose + @ConfigOption(name = "Hide empty lines at top/bottom", desc = "Hide empty lines at the top or bottom of the scoreboard.") + @ConfigEditorBoolean + public boolean hideEmptyLinesAtTopAndBottom = true; + + @Expose @ConfigOption(name = "Hide non relevant info", desc = "Hide lines that are not relevant to the current location." + "\n§cIt's generally not recommended to turn this off.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt index 0f19854f7..704f8ce77 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt @@ -15,8 +15,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraft.enchantment.Enchantment -import net.minecraft.enchantment.Enchantment.power import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -89,15 +87,15 @@ object MaxwellAPI { event.inventoryItems.values.find { powerSelectedPattern.matches(it.getLore().lastOrNull()) } ?: return - val displayName = selectedPowerStack.displayName.removeColor() + val displayName = selectedPowerStack.displayName.removeColor().trim() currentPower = getPowerByNameOrNull(displayName) ?: return ErrorManager.logErrorWithData( - UnknownMaxwellPower("Unknown power: $power"), - "Unknown power: $power", - "power" to power, + UnknownMaxwellPower("Unknown power: $displayName"), + "Unknown power: $displayName", "displayName" to displayName, - "lore" to selectedPowerStack.getLore() + "lore" to selectedPowerStack.getLore(), + noStackTrace = true ) return } @@ -126,11 +124,11 @@ object MaxwellAPI { val power = group("power") currentPower = getPowerByNameOrNull(power) ?: return@matchMatcher ErrorManager.logErrorWithData( - UnknownMaxwellPower("Unknown power: ${Enchantment.power}"), - "Unknown power: ${Enchantment.power}", - "power" to Enchantment.power, + UnknownMaxwellPower("Unknown power: ${stack.displayName}"), + "Unknown power: ${stack.displayName}", "displayName" to stack.displayName, - "lore" to stack.getLore() + "lore" to stack.getLore(), + noStackTrace = true ) return@matchMatcher } 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 5e15166c0..e0f260714 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 @@ -13,7 +13,8 @@ // - option to hide coins earned // - color options in the purse etc lines // - choose the amount of decimal places in shorten nums -// - very important bug fix: duplex is weird :( +// - ~~very important bug fix: duplex is weird :(~~ will be fixed with empas quiverapi overhaul +// - more anchor points (alignment enums in renderutils) // package at.hannibal2.skyhanni.features.gui.customscoreboard @@ -91,12 +92,13 @@ class CustomScoreboard { } private fun createLines() = buildList<ScoreboardElementType> { - for (element in config.scoreboardEntries) { + val configEntries = removeEmptyLinesFromEdges(config.scoreboardEntries) + for (element in configEntries) { val line = element.getVisiblePair() // Hide consecutive empty lines if ( - config.informationFilteringConfig.hideConsecutiveEmptyLines && + informationFilteringConfig.hideConsecutiveEmptyLines && line.isNotEmpty() && line[0].first == "<empty>" && lastOrNull()?.first?.isEmpty() == true ) { continue @@ -117,11 +119,21 @@ class CustomScoreboard { } } + private fun removeEmptyLinesFromEdges(entries: MutableList<ScoreboardElement>): List<ScoreboardElement> { + if (config.informationFilteringConfig.hideEmptyLinesAtTopAndBottom) { + return entries + .dropWhile { it.getVisiblePair().all { it.first == "<empty>" } } + .dropLastWhile { it.getVisiblePair().all { it.first == "<empty>" } } + } + return entries + } + // 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 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt index 2a2f009ac..c110e7cf1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt @@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11 class RenderBackground { fun renderBackground() { val position = config.position - val border = 5 + val border = backgroundConfig.borderSize val x = position.getAbsX() val y = position.getAbsY() @@ -38,7 +38,7 @@ class RenderBackground { position.set( Position( if (config.displayConfig.alignment.alignRight) - scaledWidth - elementWidth - (backgroundConfig.borderSize * 2) + scaledWidth - elementWidth - (border * 2) else x, if (config.displayConfig.alignment.alignCenterVertically) scaledHeight / 2 - elementHeight / 2 @@ -63,18 +63,18 @@ class RenderBackground { Minecraft.getMinecraft().textureManager.bindTexture(textureLocation) Utils.drawTexturedRect( - (x - backgroundConfig.borderSize).toFloat(), - (y - backgroundConfig.borderSize).toFloat(), - (elementWidth + backgroundConfig.borderSize * 3).toFloat(), + (x - border).toFloat(), + (y - border).toFloat(), + (elementWidth + border * 3).toFloat(), (elementHeight + border * 2).toFloat(), GL11.GL_NEAREST ) } else { RenderUtils.drawRoundRect( - x - backgroundConfig.borderSize, - y - backgroundConfig.borderSize, - elementWidth + backgroundConfig.borderSize * 3, - elementHeight + backgroundConfig.borderSize * 2, + x - border, + y - border, + elementWidth + border * 3, + elementHeight + border * 2, SpecialColour.specialToChromaRGB(backgroundConfig.color), backgroundConfig.roundedCornerSmoothness ) 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 801ba3249..abd5a04f1 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 @@ -130,7 +130,7 @@ enum class ScoreboardElement( POWER( ::getPowerDisplayPair, ::getPowerShowWhen, - "Power: Sighted" + "Power: §aSighted" ), COOKIE( ::getCookieDisplayPair, @@ -179,7 +179,7 @@ enum class ScoreboardElement( PARTY( ::getPartyDisplayPair, ::getPartyShowWhen, - "§9§lParty (4):\n §7- §fhannibal2\n §7- §fMoulberry\n §7- §fVahvl\n §7- §fJ10a1n15" + "§9§lParty (4):\n §7- §fhannibal2\n §7- §fMoulberry\n §7- §fVahvl\n §7- §fSkirtwearer" ), FOOTER( ::getFooterDisplayPair, @@ -191,6 +191,21 @@ enum class ScoreboardElement( ::getExtraShowWhen, "§cUnknown lines the mod is not detecting" ), + EMPTY_LINE4( + ::getEmptyLineDisplayPair, + { true }, + "" + ), + EMPTY_LINE5( + ::getEmptyLineDisplayPair, + { true }, + "" + ), + EMPTY_LINE6( + ::getEmptyLineDisplayPair, + { true }, + "" + ), ; override fun toString(): String { @@ -427,10 +442,10 @@ private fun getPowerDisplayPair() = listOf( null -> "§cOpen \"Your Bags\"!" else -> if (displayConfig.displayNumbersFirst) { - "${MaxwellAPI.currentPower?.replace("Power", "")} Power " + + "§a${MaxwellAPI.currentPower?.replace("Power", "")} Power " + "§7(§6${MaxwellAPI.magicalPower}§7)" } else { - "Power: ${MaxwellAPI.currentPower?.replace("Power", "")} " + + "Power: §a${MaxwellAPI.currentPower?.replace("Power", "")} " + "§7(§6${MaxwellAPI.magicalPower?.addSeparators()}§7)" } } to HorizontalAlignment.LEFT diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt index 0ca968a98..8035361af 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt @@ -3,13 +3,11 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI.sidebarCropPattern import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEvents.VOTING import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern import at.hannibal2.skyhanni.features.misc.ServerRestartTitle import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies -import at.hannibal2.skyhanni.utils.CollectionUtils.addIfNotNull import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.LorenzUtils.inAdvancedMiningIsland import at.hannibal2.skyhanni.utils.LorenzUtils.inDungeons @@ -90,10 +88,6 @@ enum class ScoreboardEvents(private val displayLine: Supplier<List<String>>, pri ::getSpookyLines, ::getSpookyShowWhen ), - ACTIVE_TABLIST_EVENTS( - ::getActiveEventLine, - ::getActiveEventShowWhen - ), BROODMOTHER( ::getBroodmotherLines, ::getBroodmotherShowWhen @@ -126,6 +120,10 @@ enum class ScoreboardEvents(private val displayLine: Supplier<List<String>>, pri ::getEffigiesLines, ::getEffigiesShowWhen ), + ACTIVE_TABLIST_EVENTS( + ::getActiveEventLine, + ::getActiveEventShowWhen + ), REDSTONE( ::getRedstoneLines, ::getRedstoneShowWhen @@ -155,7 +153,7 @@ private fun getVotingLines() = buildList { val sbLines = getSbLines() val yearLine = sbLines.firstOrNull { SbPattern.yearVotesPattern.matches(it) } ?: return emptyList<String>() - addIfNotNull(yearLine) + add(yearLine) if (sbLines.nextAfter(yearLine) == "§7Waiting for") { add("§7Waiting for") @@ -182,6 +180,7 @@ private fun getServerCloseShowWhen(): Boolean { } private fun getDungeonsLines() = listOf( + SbPattern.m7dragonsPattern, SbPattern.autoClosingPattern, SbPattern.startingInPattern, SbPattern.keysPattern, @@ -238,8 +237,8 @@ private fun getDarkAuctionLines() = buildList { getSbLines().firstOrNull { SbPattern.darkAuctionCurrentItemPattern.matches(it) } if (darkAuctionCurrentItemLine != null) { - addIfNotNull(darkAuctionCurrentItemLine) - addIfNotNull(getSbLines().nextAfter(darkAuctionCurrentItemLine)) + add(darkAuctionCurrentItemLine) + getSbLines().nextAfter(darkAuctionCurrentItemLine)?.let { add(it) } } } @@ -248,18 +247,16 @@ private fun getDarkAuctionShowWhen(): Boolean { } private fun getJacobContestLines() = buildList { - val jacobsContestLine = getSbLines().firstOrNull { SbPattern.jacobsContestPattern.matches(it) } - - jacobsContestLine?.let { - addIfNotNull(it) - addIfNotNull(getSbLines().nextAfter(it)) - addIfNotNull(getSbLines().nextAfter(it, 2)) - addIfNotNull(getSbLines().nextAfter(it, 3)) + getSbLines().firstOrNull { SbPattern.jacobsContestPattern.matches(it) }?.let { line -> + add(line) + getSbLines().nextAfter(line)?.let { add(it) } + getSbLines().nextAfter(line, 2)?.let { add(it) } + getSbLines().nextAfter(line, 3)?.let { add(it) } } } private fun getJacobContestShowWhen(): Boolean { - return sidebarCropPattern.anyMatches(getSbLines()) + return SbPattern.jacobsContestPattern.anyMatches(getSbLines()) } private fun getJacobMedalsLines(): List<String> { @@ -271,12 +268,12 @@ private fun getJacobMedalsShowWhen(): Boolean { } private fun getTrapperLines() = buildList { - addIfNotNull(getSbLines().firstOrNull { SbPattern.peltsPattern.matches(it) }) + getSbLines().firstOrNull { SbPattern.peltsPattern.matches(it) }?.let { add(it) } val trapperMobLocationLine = getSbLines().firstOrNull { SbPattern.mobLocationPattern.matches(it) } if (trapperMobLocationLine != null) { add("Tracker Mob Location:") - addIfNotNull(getSbLines().nextAfter(trapperMobLocationLine)) + getSbLines().nextAfter(trapperMobLocationLine)?.let { add(it) } } } @@ -311,12 +308,12 @@ private fun getFlightDurationShowWhen(): Boolean { } private fun getWinterLines() = buildList { - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterEventStartPattern.matches(it) }) - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterNextWavePattern.matches(it) && !it.endsWith("Soon!") }) - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterWavePattern.matches(it) }) - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterMagmaLeftPattern.matches(it) }) - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterTotalDmgPattern.matches(it) }) - addIfNotNull(getSbLines().firstOrNull { SbPattern.winterCubeDmgPattern.matches(it) }) + getSbLines().firstOrNull { SbPattern.winterEventStartPattern.matches(it) }?.let { add(it) } + getSbLines().firstOrNull { SbPattern.winterNextWavePattern.matches(it) && !it.endsWith("Soon!") }?.let { add(it) } + getSbLines().firstOrNull { SbPattern.winterWavePattern.matches(it) }?.let { add(it) } + getSbLines().firstOrNull { SbPattern.winterMagmaLeftPattern.matches(it) }?.let { add(it) } + getSbLines().firstOrNull { SbPattern.winterTotalDmgPattern.matches(it) }?.let { add(it) } + getSbLines().firstOrNull { SbPattern.winterCubeDmgPattern.matches(it) }?.let { add(it) } } private fun getWinterShowWhen(): Boolean { @@ -328,9 +325,9 @@ private fun getWinterShowWhen(): Boolean { } private fun getSpookyLines() = buildList { - addIfNotNull(getSbLines().firstOrNull { SbPattern.spookyPattern.matches(it) }) // Time - addIfNotNull("§7Your Candy: ") - addIfNotNull( + getSbLines().firstOrNull { SbPattern.spookyPattern.matches(it) }?.let { add(it) } // Time + add("§7Your Candy: ") + add( CustomScoreboardUtils.getTablistFooter() .split("\n") .firstOrNull { it.startsWith("§7Your Candy:") } 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 45c0aa01d..bdb609ead 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 @@ -88,6 +88,10 @@ object ScoreboardPattern { // dungeon scoreboard private val dungeonSb = scoreboardGroup.group("dungeon") + val m7dragonsPattern by dungeonSb.pattern( + "m7dragons", + "^(§cNo Alive Dragons|§8- (§.)+[\\w\\s]+Dragon§a \\w+§.❤)$" + ) val keysPattern by dungeonSb.pattern( "keys", "Keys: §.■ §.[✗✓] §.■ §a.x$" @@ -144,7 +148,7 @@ object ScoreboardPattern { ) val peltsPattern by farmingSb.pattern( "pelts", - "^(§.)*Pelts: (§.)*(?<pelts>[\\d,]+)( (§.)*\\([+-](?<diff>[\\w,.]+)\\))?\$" + "^(§.)*Pelts: (§.)*([\\d,]+).*$" ) val mobLocationPattern by farmingSb.pattern( "moblocation", @@ -154,10 +158,10 @@ object ScoreboardPattern { "jacobscontest", "^§eJacob's Contest$" ) - val plotPattern by farmingSb.pattern( - "plot", - "\\s*§aPlot §7-.*" - ) + val plotPattern by farmingSb.pattern( + "plot", + "\\s*§aPlot §7-.*" + ) // mining private val miningSb = scoreboardGroup.group("mining") @@ -313,11 +317,13 @@ object ScoreboardPattern { "objective", "^(§.)*(Objective|Quest).*" ) + // this thirdObjectiveLinePattern includes all those weird objective lines that go into a third scoreboard line val thirdObjectiveLinePattern by miscSb.pattern( "thirdobjectiveline", "(\\s*§.\\(§.\\w+§./§.\\w+§.\\)|§f Mages.*|§f Barbarians.*|§edefeat Kuudra|§eand stun him)" ) + // collection of lines that just randomly exist and I have no clue how on earth to effectively remove them val wtfAreThoseLinesPattern by miscSb.pattern( "wtfarethoselines", |