mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-01 21:11:44 +01:00
Hotfix legacy serializer to include capitalized formatting code chars (#5711)
This commit is contained in:
parent
bd8c792fa4
commit
4219450705
@ -4,10 +4,17 @@ import net.ess3.api.IEssentials;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.flattener.ComponentFlattener;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.CharacterAndFormat;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.Reset;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class AdventureUtil {
|
||||
private static final LegacyComponentSerializer LEGACY_SERIALIZER;
|
||||
@ -18,7 +25,26 @@ public final class AdventureUtil {
|
||||
private static MiniMessage miniMessageInstance;
|
||||
|
||||
static {
|
||||
final LegacyComponentSerializer.Builder builder = LegacyComponentSerializer.builder().flattener(ComponentFlattener.basic()).useUnusualXRepeatedCharacterHexFormat();
|
||||
final List<CharacterAndFormat> formats = new ArrayList<>();
|
||||
formats.addAll(CharacterAndFormat.defaults());
|
||||
formats.addAll(Arrays.asList(
|
||||
CharacterAndFormat.characterAndFormat('A', NamedTextColor.GREEN),
|
||||
CharacterAndFormat.characterAndFormat('B', NamedTextColor.AQUA),
|
||||
CharacterAndFormat.characterAndFormat('C', NamedTextColor.RED),
|
||||
CharacterAndFormat.characterAndFormat('D', NamedTextColor.LIGHT_PURPLE),
|
||||
CharacterAndFormat.characterAndFormat('E', NamedTextColor.YELLOW),
|
||||
CharacterAndFormat.characterAndFormat('F', NamedTextColor.WHITE),
|
||||
CharacterAndFormat.characterAndFormat('K', TextDecoration.OBFUSCATED),
|
||||
CharacterAndFormat.characterAndFormat('L', TextDecoration.BOLD),
|
||||
CharacterAndFormat.characterAndFormat('M', TextDecoration.STRIKETHROUGH),
|
||||
CharacterAndFormat.characterAndFormat('N', TextDecoration.UNDERLINED),
|
||||
CharacterAndFormat.characterAndFormat('O', TextDecoration.ITALIC),
|
||||
CharacterAndFormat.characterAndFormat('R', Reset.INSTANCE)
|
||||
));
|
||||
final LegacyComponentSerializer.Builder builder = LegacyComponentSerializer.builder()
|
||||
.flattener(ComponentFlattener.basic())
|
||||
.formats(formats)
|
||||
.useUnusualXRepeatedCharacterHexFormat();
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_16_1_R01)) {
|
||||
builder.hexColors();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user