From 2ed9e4a59ed99f3b9927a3cd6cda3f19d652fd30 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:47:58 +0200 Subject: Feature: Color class levels in tab list (#398) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 3 +- .../skyhanni/config/features/DungeonConfig.java | 19 +++++++++--- .../skyhanni/config/features/GardenConfig.java | 4 +-- .../skyhanni/features/dungeon/DungeonLevelColor.kt | 24 +++++++-------- .../features/dungeon/DungeonRankTabListColor.kt | 34 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 29179b902..3506fffa3 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -107,7 +107,7 @@ import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.* import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand -import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.EntityOutlineRenderer import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded import at.hannibal2.skyhanni.utils.TabListData @@ -404,6 +404,7 @@ class SkyHanniMod { loadModule(PowderTracker()) loadModule(GlowingDroppedItems()) loadModule(DungeonTeammateOutlines()) + loadModule(DungeonRankTabListColor()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java index c8033a642..ef19d81b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java @@ -3,10 +3,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; -import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.*; public class DungeonConfig { @@ -168,6 +165,20 @@ public class DungeonConfig { @FeatureToggle public boolean partyFinderColoredClassLevel = true; + @Expose + @ConfigOption(name = "Tab List", desc = "") + @Accordion + public TabListConfig tabList = new TabListConfig(); + + public static class TabListConfig { + + @Expose + @ConfigOption(name = "Colored Class Level", desc = "Color class levels in tab list. (Also hides rank colors and emblems, because who needs that in dungeon anyway?)") + @ConfigEditorBoolean + @FeatureToggle + public boolean coloredClassLevel = true; + } + @Expose @ConfigOption(name = "Moving Skeleton Skulls", desc = "Highlight Skeleton Skulls when combining into an " + "orange Skeletor (not useful when combined with feature Hide Skeleton Skull).") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java index 7acca7e23..ab7f31448 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -1375,9 +1375,9 @@ public class GardenConfig { @Expose @ConfigOption(name = "Garden Plot Icon", desc = "") @Accordion - public PlotIcon plotIcon = new PlotIcon(); + public PlotIconConfig plotIcon = new PlotIconConfig(); - public static class PlotIcon { + public static class PlotIconConfig { @Expose @ConfigOption(name = "Enable", desc = "Enable icon replacement in the Configure Plots menu.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt index 4f5ca684f..2a044adef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt @@ -34,16 +34,16 @@ class DungeonLevelColor { } } } - - private fun getColor(level: Int): String { - if (level >= 50) return "§c§l" - if (level >= 45) return "§c" - if (level >= 40) return "§d" - if (level >= 35) return "§6" - if (level >= 30) return "§5" - if (level >= 25) return "§9" - if (level >= 20) return "§a" - if (level >= 10) return "§f" - return "§7" - } } + +fun getColor(level: Int): String { + if (level >= 50) return "§c§l" + if (level >= 45) return "§c" + if (level >= 40) return "§d" + if (level >= 35) return "§6" + if (level >= 30) return "§5" + if (level >= 25) return "§9" + if (level >= 20) return "§a" + if (level >= 10) return "§f" + return "§7" +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt new file mode 100644 index 000000000..9a28dcc06 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt @@ -0,0 +1,34 @@ +package at.hannibal2.skyhanni.features.dungeon + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.TabListLineRenderEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class DungeonRankTabListColor { + private val config get() = SkyHanniMod.feature.dungeon.tabList + private val pattern = "§r(?.*) §r§f\\(§r§d(?.*) (?.*)§r§f\\)§r".toPattern() + + @SubscribeEvent + fun onTabListText(event: TabListLineRenderEvent) { + if (!isEnabled()) return + + pattern.matchMatcher(event.text) { + val playerName = group("playerName") + val split = playerName.split(" ") + val sbLevel = split[0] + val cleanName = split[1].cleanPlayerName() + + val className = group("className") + val level = group("classLevel").romanToDecimal() + val color = getColor(level) + + event.text = "$sbLevel §b$cleanName §7(§e$className $color$level§7)" + } + } + + fun isEnabled() = LorenzUtils.inDungeons && config.coloredClassLevel +} -- cgit