From 2789a24295d1e24a17344a4b3c045f0182c61723 Mon Sep 17 00:00:00 2001 From: filoghost Date: Fri, 21 Jan 2022 23:20:48 +0100 Subject: [PATCH] Fix custom placeholders --- .../plugin/config/HologramLineParser.java | 6 ++++-- .../holographicdisplays/plugin/format/DisplayFormat.java | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/config/HologramLineParser.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/config/HologramLineParser.java index 4f5c48b4..c8027430 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/config/HologramLineParser.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/config/HologramLineParser.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.plugin.config; +import me.filoghost.fcommons.Colors; import me.filoghost.fcommons.MaterialsHelper; import me.filoghost.fcommons.Strings; import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; @@ -32,8 +33,9 @@ public class HologramLineParser { hologramLine = hologram.createItemLine(icon, serializedLine); } else { - // Don't apply display format inside placeholders - String displayText = StringWithPlaceholders.withEscapes(serializedLine).replaceStrings(DisplayFormat::apply); + String displayText = DisplayFormat.apply(serializedLine, false); + // Apply colors only outside placeholders + displayText = StringWithPlaceholders.withEscapes(displayText).replaceStrings(Colors::colorize); hologramLine = hologram.createTextLine(displayText, serializedLine); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java index f5864eef..5635dee0 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java @@ -25,13 +25,19 @@ import java.util.List; public class DisplayFormat { public static String apply(String input) { + return apply(input, true); + } + + public static String apply(String input, boolean addColors) { if (input == null) { return null; } input = StaticReplacements.searchAndReplace(input); input = input.replace("&u", "{rainbow}"); - input = Colors.colorize(input); + if (addColors) { + input = Colors.colorize(input); + } return input; }