diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-08 17:00:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-08 17:00:49 +0200 |
| commit | d3805f080af87eb2bc7d2a2eac6c3f8db539324f (patch) | |
| tree | 2aaf95a14d1cb82096c1c2d675ebe6b7147dab48 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java | |
| parent | 827acac6fcf836c1dba5bea338f726694951d18e (diff) | |
| download | notenoughupdates-d3805f080af87eb2bc7d2a2eac6c3f8db539324f.tar.gz notenoughupdates-d3805f080af87eb2bc7d2a2eac6c3f8db539324f.tar.bz2 notenoughupdates-d3805f080af87eb2bc7d2a2eac6c3f8db539324f.zip | |
0.14 - Finished :) (#233)
Co-authored-by: nopo <noahogno@gmail.com>
Co-authored-by: jani270 <69345714+jani270@users.noreply.github.com>
Co-authored-by: Ascynx <78341107+Ascynx@users.noreply.github.com>
Co-authored-by: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java index 127edcde..b1ab11c1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java @@ -45,15 +45,18 @@ public class DamageCommas { }; private static final char STAR = '\u2727'; + private static final char OVERLOAD_STAR = '\u272F'; private static final Pattern PATTERN_CRIT = Pattern.compile( - "\u00a7f" + STAR + "((?:\u00a7.\\d)+)\u00a7." + STAR + "(.*)"); - private static final Pattern PATTERN_NO_CRIT = Pattern.compile("\u00a77(\\d+)(.*)"); + "\u00a7f" + STAR + "((?:\u00a7.\\d(?:ยง.,)?)+)\u00a7." + STAR + "(.*)"); + private static final Pattern PATTERN_NO_CRIT = Pattern.compile("(\u00a7.)([\\d+,]*)(.*)"); + private static final Pattern OVERLOAD_PATTERN = Pattern.compile("(\u00a7.)" + OVERLOAD_STAR + "((?:\u00a7.[\\d,])+)(\u00a7.)" + OVERLOAD_STAR + "\u00a7r"); public static IChatComponent replaceName(EntityLivingBase entity) { if (!entity.hasCustomName()) return entity.getDisplayName(); IChatComponent name = entity.getDisplayName(); - if (NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 0) return name; + if (!NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle2) return name; + if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return name; if (replacementMap.containsKey(entity)) { ChatComponentText component = replacementMap.get(entity); @@ -69,17 +72,23 @@ public class DamageCommas { String suffix; Matcher matcherCrit = PATTERN_CRIT.matcher(formatted); + Matcher matcherOverload = OVERLOAD_PATTERN.matcher(formatted); if (matcherCrit.matches()) { crit = true; - numbers = StringUtils.cleanColour(matcherCrit.group(1)); + numbers = StringUtils.cleanColour(matcherCrit.group(1)).replace(",", ""); prefix = "\u00a7f" + STAR; suffix = "\u00a7f" + STAR + matcherCrit.group(2); - } else { + } else if (matcherOverload.matches()) { + crit = true; + numbers = StringUtils.cleanColour(matcherOverload.group(2)).replace(",", ""); + prefix = matcherOverload.group(1) + OVERLOAD_STAR; + suffix = matcherOverload.group(3) + OVERLOAD_STAR + "\u00a7r"; + } else { Matcher matcherNoCrit = PATTERN_NO_CRIT.matcher(formatted); if (matcherNoCrit.matches()) { - numbers = matcherNoCrit.group(1); - prefix = "\u00A77"; - suffix = "\u00A7r" + matcherNoCrit.group(2); + numbers = matcherNoCrit.group(2).replace(",", ""); + prefix = matcherNoCrit.group(1); + suffix = "\u00A7r" + matcherNoCrit.group(3); } else { replacementMap.put(entity, null); return name; @@ -91,10 +100,10 @@ public class DamageCommas { try { int number = Integer.parseInt(numbers); - if (number > 999 && NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) { + if (number > 999) { newFormatted.append(Utils.shortNumberFormat(number, 0)); } else { - newFormatted.append(NumberFormat.getIntegerInstance().format(number)); + return name; } } catch (NumberFormatException e) { replacementMap.put(entity, null); |
