diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt | 30 |
1 files changed, 17 insertions, 13 deletions
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 (?<number>.*)§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 } } } |