From d9855518373e208b56257934083654d03ed3e6ea Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 13 Aug 2023 20:31:33 +0200 Subject: Fixed feature that replaces the sack stitched lore message (ty hypixel) --- .../features/misc/PocketSackInASackDisplay.kt | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt index 8507deb6e..0ed156362 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt @@ -6,14 +6,13 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PocketSackInASackDisplay { private val config get() = SkyHanniMod.feature.misc.pocketSackInASack - private val valPattern = "§5§o§7This sack is stitched with (?.*)§7.".toPattern() + private val maxedStitched = 3 @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { @@ -49,17 +48,22 @@ class PocketSackInASackDisplay { fun onTooltip(event: LorenzToolTipEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.replaceLore) return - if (!ItemUtils.isSack(event.itemStack.displayName)) return - val it = event.toolTip.listIterator() - for (line in it) { - valPattern.matchMatcher(line) { - val replace = when (group("number")) { - "a" -> "§c1" - "two" -> "§62" - "three" -> "§a3" - else -> "0" - } - it.set(line.replace(Regex("\\b${group("number")}\\b"), "$replace§7/§b3")) + val itemStack = event.itemStack + val applied = itemStack.getAppliedPocketSackInASack() ?: return + + if (!ItemUtils.isSack(itemStack.displayName)) return + val iterator = event.toolTip.listIterator() + var next = false + for (line in iterator) { + if (line.contains("7This sack is")) { + val color = if (applied == maxedStitched) "§a" else "§b" + iterator.set("§7This sack is stitched $color$applied§7/$color$maxedStitched") + next = true + continue + } + if (next) { + iterator.set("§7times with a §cPocket Sack-in-a-Sack§7.") + return } } } -- cgit