<tier-name> fixed

This commit is contained in:
Roch Blonndiaux 2022-11-09 16:50:25 +01:00
parent 077a4ce0ef
commit 5ed21155ea
2 changed files with 7 additions and 1 deletions

View File

@ -32,11 +32,12 @@ public class DisplayName extends StringStat implements GemStoneStat {
// Bake // Bake
String format = data.toString() String format = data.toString()
.replace("<tier-name>", tier != null ? ChatColor.stripColor(tier.getName()) : "") .replace("<tier-name>", tier != null ? ColorUtils.stripColors(tier.getName()) : "")
.replace("<tier-color>", tier != null ? ChatColor.getLastColors(tier.getName()) : "&f") .replace("<tier-color>", tier != null ? ChatColor.getLastColors(tier.getName()) : "&f")
.replace("<tier-color-cleaned>", tier != null ? ColorUtils.stripDecoration(ChatColor.getLastColors(tier.getName())) : "&f"); .replace("<tier-color-cleaned>", tier != null ? ColorUtils.stripDecoration(ChatColor.getLastColors(tier.getName())) : "&f");
if (tier != null) { if (tier != null) {
System.out.println("Name: " + tier.getName());
System.out.println("Format: " + format); System.out.println("Format: " + format);
System.out.println("Last Colors: " + ChatColor.getLastColors(tier.getName()) + " w: " + ColorUtils.stripDecoration(ChatColor.getLastColors(tier.getName()))); System.out.println("Last Colors: " + ChatColor.getLastColors(tier.getName()) + " w: " + ColorUtils.stripDecoration(ChatColor.getLastColors(tier.getName())));
System.out.println("===================\n"); System.out.println("===================\n");

View File

@ -14,8 +14,13 @@ import java.util.regex.Pattern;
public class ColorUtils { public class ColorUtils {
private static final Pattern STRIP_DECORATION_PATTERN = Pattern.compile("(?i)" + '§' + "[K-O]"); private static final Pattern STRIP_DECORATION_PATTERN = Pattern.compile("(?i)" + '§' + "[K-O]");
private static final Pattern COLOR_TAG_PATTERN = Pattern.compile("(?i)<.*>");
public static @NotNull String stripDecoration(@NotNull String input) { public static @NotNull String stripDecoration(@NotNull String input) {
return "%s%s".formatted(ChatColor.RESET, STRIP_DECORATION_PATTERN.matcher(input).replaceAll("")).replace('§', '&'); return "%s%s".formatted(ChatColor.RESET, STRIP_DECORATION_PATTERN.matcher(input).replaceAll("")).replace('§', '&');
} }
public static @NotNull String stripColors(@NotNull String input) {
return ChatColor.stripColor(COLOR_TAG_PATTERN.matcher(input).replaceAll(""));
}
} }