aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-27 20:12:25 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-27 20:12:25 +0100
commit2b330c3505f34b2b9ac7fed116237983eacc098d (patch)
tree41780b250b7222ee5cc77c009030d0f013ced0a2 /src/main/java/at/hannibal2/skyhanni/features
parent898947156b64e45cc5a0133c12aa73811d3e16f5 (diff)
downloadskyhanni-2b330c3505f34b2b9ac7fed116237983eacc098d.tar.gz
skyhanni-2b330c3505f34b2b9ac7fed116237983eacc098d.tar.bz2
skyhanni-2b330c3505f34b2b9ac7fed116237983eacc098d.zip
Add catacombs class level color to party finder
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt
new file mode 100644
index 000000000..796f93ef4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt
@@ -0,0 +1,55 @@
+package at.hannibal2.skyhanni.features.dungeon
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.inventory.ContainerChest
+import net.minecraftforge.event.entity.player.ItemTooltipEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class DungeonLevelColor {
+
+ private val pattern = Pattern.compile(" §.(.*)§f: §e(.*)§b \\(§e(.*)§b\\)")
+
+ @SubscribeEvent
+ fun onItemTooltip(event: ItemTooltipEvent) {
+ if (!LorenzUtils.inSkyblock) return
+ if (!SkyHanniMod.feature.dungeon.partyFinderColoredClassLevel) return
+
+ if (event.toolTip == null) return
+ val guiChest = Minecraft.getMinecraft().currentScreen
+ if (guiChest !is GuiChest) return
+ val chest = guiChest.inventorySlots as ContainerChest
+ val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
+ if (chestName != "Party Finder") return
+
+ val stack = event.itemStack
+ var index = 0
+ for (line in stack.getLore()) {
+ index++
+ val matcher = pattern.matcher(line)
+ if (!matcher.matches()) continue
+
+ val playerName = matcher.group(1)
+ val className = matcher.group(2)
+ val level = matcher.group(3).toInt()
+ val color = getColor(level)
+ event.toolTip[index] = " §b$playerName§f: §e$className $color$level"
+ }
+ }
+
+ 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 "§b"
+ if (level >= 30) return "§5"
+ if (level >= 25) return "§9"
+ if (level >= 20) return "§a"
+ if (level >= 10) return "§f"
+ return "§7"
+ }
+}