Skip to content

Commit

Permalink
Update ColoredTextPlaceholder.java
Browse files Browse the repository at this point in the history
  • Loading branch information
iiAhmedYT committed Jun 25, 2024
1 parent 06140d0 commit 0e7408f
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@

public class ColoredTextPlaceholder extends Placeholder {

/**
* Represents a map of decoration properties.
*/
private final static Map<String, String> DECORATIONS_PROPERTIES = new HashMap<String, String>() {
{
for (final ChatColor color : ChatColor.values()) {
final String name = color.name().toLowerCase();
put("<" + name + ">", "&" + color.getChar());
private final static LegacyComponentSerializer SECTION_SERIALIZER = LegacyComponentSerializer
.builder()
.character('§')
.hexCharacter('#')
.hexColors()
.useUnusualXRepeatedCharacterHexFormat()
.build();

if (name.contains("_")) {
put("<" + name.replaceAll("_", "") + ">", "&" + color.getChar());
}
}
}
};
private final static LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer
.builder()
.character('&')
.hexCharacter('#')
.hexColors()
.build();

private final String miniText, legacyText, consoleText;

Expand All @@ -38,11 +37,11 @@ public ColoredTextPlaceholder(final String value) {

final Component component = Utilities.MM.deserialize(value);
// legacy text creation
this.legacyText = LegacyComponentSerializer.legacyAmpersand().serialize(
this.legacyText = AMPERSAND_SERIALIZER.serialize(
component
);

this.consoleText = LegacyComponentSerializer.legacySection().serialize(
this.consoleText = SECTION_SERIALIZER.serialize(
component
);
}
Expand Down

0 comments on commit 0e7408f

Please sign in to comment.