diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2023-09-26 11:47:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 11:47:58 +0200 |
commit | 2ed9e4a59ed99f3b9927a3cd6cda3f19d652fd30 (patch) | |
tree | acbf1fc5f97e590448e1d50490811dd5e50785e7 /src/main/java/at/hannibal2/skyhanni | |
parent | 5b4f020ec6aaae0afea309b772bf89fb1493e4d3 (diff) | |
download | skyhanni-2ed9e4a59ed99f3b9927a3cd6cda3f19d652fd30.tar.gz skyhanni-2ed9e4a59ed99f3b9927a3cd6cda3f19d652fd30.tar.bz2 skyhanni-2ed9e4a59ed99f3b9927a3cd6cda3f19d652fd30.zip |
Feature: Color class levels in tab list (#398)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
5 files changed, 65 insertions, 19 deletions
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 { @@ -169,6 +166,20 @@ public class DungeonConfig { 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).") @ConfigEditorBoolean 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(?<playerName>.*) §r§f\\(§r§d(?<className>.*) (?<classLevel>.*)§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 +} |