Fix custom placeholders

This commit is contained in:
filoghost 2022-01-21 23:20:48 +01:00
parent 58907f075f
commit 2789a24295
2 changed files with 11 additions and 3 deletions

View File

@ -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);
}

View File

@ -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;
}