diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-13 20:31:33 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-13 20:31:33 +0200 |
commit | d9855518373e208b56257934083654d03ed3e6ea (patch) | |
tree | 45b0ed7f9e77c3d011d8c4c489fd55ae00ecc16b /src/main/java | |
parent | 879fa4ac49edd41470e06db9a14eaa593d0a33ca (diff) | |
download | skyhanni-d9855518373e208b56257934083654d03ed3e6ea.tar.gz skyhanni-d9855518373e208b56257934083654d03ed3e6ea.tar.bz2 skyhanni-d9855518373e208b56257934083654d03ed3e6ea.zip |
Fixed feature that replaces the sack stitched lore message (ty hypixel)
Diffstat (limited to 'src/main/java')
-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 } } } |