From b07483e302a0bf056016302e2a3dcefc0e78c761 Mon Sep 17 00:00:00 2001 From: Madeleaan <70163122+Madeleaan@users.noreply.github.com> Date: Sat, 11 May 2024 14:46:40 +0200 Subject: Fix outline color of custom tooltips with formatting (#1158) --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 14a5072b..1e785f58 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1668,13 +1668,15 @@ public class Utils { public static char getPrimaryColourCode(String displayName) { int lastColourCode = -99; int currentColour = 0; + int colourIndex = 0; int[] mostCommon = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0; i < displayName.length(); i++) { char c = displayName.charAt(i); if (c == '\u00A7') { lastColourCode = i; } else if (lastColourCode == i - 1) { - currentColour = Math.max(0, "0123456789abcdef".indexOf(c)); + colourIndex = "0123456789abcdef".indexOf(c); + if (colourIndex != -1) currentColour = colourIndex; } else if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0) { if (currentColour > 0) { mostCommon[currentColour]++; -- cgit