Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Essentials/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dependencies {
implementation 'org.checkerframework:checker-qual:3.21.0'
implementation 'nu.studer:java-ordered-properties:1.0.4'

implementation 'net.kyori:adventure-api:4.17.0'
implementation 'net.kyori:adventure-text-minimessage:4.17.0'
implementation 'net.kyori:adventure-platform-bukkit:4.3.3'
implementation 'net.kyori:adventure-api:4.18.0'
implementation 'net.kyori:adventure-text-minimessage:4.18.0'
implementation 'net.kyori:adventure-platform-bukkit:4.3.4'

// Providers
api project(':providers:BaseProviders')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
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;
Expand All @@ -25,25 +18,8 @@ public final class AdventureUtil {
private static MiniMessage miniMessageInstance;

static {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ protected void handleChatRecipients(AsyncPlayerChatEvent event) {
server.getPluginManager().callEvent(spyEvent);

if (!spyEvent.isCancelled()) {
final String legacyString = AdventureUtil.miniToLegacy(String.format(spyEvent.getFormat(), AdventureUtil.legacyToMini(user.getDisplayName()), AdventureUtil.escapeTags(spyEvent.getMessage())));
final String legacyString = AdventureUtil.miniToLegacy(String.format(spyEvent.getFormat(), AdventureUtil.legacyToMini(user.getDisplayName()), AdventureUtil.legacyToMini(AdventureUtil.escapeTags(spyEvent.getMessage()))));

for (final Player onlinePlayer : spyEvent.getRecipients()) {
onlinePlayer.sendMessage(legacyString);
Expand Down
Loading