From 12fdc80608962c0ae70e0deb246076c1d40f7d8a Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:31:40 +1000 Subject: fix 9 and b getting overridden (#276) --- .../listener/ItemTooltipListener.java | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java index 5d6a2bdc..c522e70a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -382,6 +382,7 @@ public class ItemTooltipListener { } } if (hasEnchantments || hasAttributes) { + ArrayList addedEnchants = new ArrayList<>(); for (String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) { List colourOps = GuiEnchantColour.splitter.splitToList(op); String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); @@ -475,20 +476,22 @@ public class ItemTooltipListener { String extraMods = extraModifiersBuilder.toString(); if (!colourCode.equals("z")) { - line = line.replace("\u00A79" + enchantText, "\u00A7" + colourCode + extraMods + enchantText); - line = line.replace("\u00A7b" + enchantText, "\u00A7" + colourCode + extraMods + enchantText); - line = line.replace( - "\u00A79\u00A7d\u00A7l" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); - line = line.replace( - "\u00A7b\u00A7d\u00A7l" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); - line = line.replace( - "\u00A7l\u00A7d\u00A7l" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); + if (!addedEnchants.contains(enchantText)) { + line = line.replace("\u00A79" + enchantText, "\u00A7" + colourCode + extraMods + enchantText); + line = line.replace("\u00A7b" + enchantText, "\u00A7" + colourCode + extraMods + enchantText); + line = line.replace( + "\u00A79\u00A7d\u00A7l" + enchantText, + "\u00A7" + colourCode + extraMods + enchantText + ); + line = line.replace( + "\u00A7b\u00A7d\u00A7l" + enchantText, + "\u00A7" + colourCode + extraMods + enchantText + ); + line = line.replace( + "\u00A7l\u00A7d\u00A7l" + enchantText, + "\u00A7" + colourCode + extraMods + enchantText + ); + } } else { int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( "\\u00A79" + enchantText + ".*", @@ -516,6 +519,7 @@ public class ItemTooltipListener { Utils.chromaString(enchantText, offset / 12f + index, true) ); } + addedEnchants.add(enchantText); } } } -- cgit