diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java index 89052d3..62747cb 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java @@ -83,11 +83,24 @@ public final class PlayerChat implements Listener { LegacyComponentSerializer .legacyAmpersand(); + private Component renderVanilla(@Nonnull Component displayName, + @Nonnull Component component) { + return Component.translatable( + "chat.type.text", + displayName, + component.replaceText(URL_REPLACEMENT_CONFIG) + ); + } + @Override public @Nonnull Component render(@Nonnull Player player, @Nonnull Component displayName, @Nonnull Component component, @Nonnull Audience audience) { + if (PlayerPrefix.isUsingVanillaFormat(player)) { + return renderVanilla(displayName, component); + } + Component newComponent = Component.empty(); final Component prefix; Component prefix1; diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerPrefix.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerPrefix.java index d67e59b..1e5a7fd 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerPrefix.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerPrefix.java @@ -74,6 +74,14 @@ public final class PlayerPrefix implements Listener { return prefix; } + public static boolean isUsingVanillaFormat(Player player) { + final UUID playerUUID = player.getUniqueId(); + final String stringifiedUUID = playerUUID.toString(); + final String legacyPrefix = PREFIX_CONFIG.getString(stringifiedUUID); + + return legacyPrefix != null && legacyPrefix.equals("%"); + } + public static Component getPrefix(Player player) throws IOException { final UUID playerUUID = player.getUniqueId(); final String stringifiedUUID = playerUUID.toString(); @@ -94,7 +102,10 @@ public final class PlayerPrefix implements Listener { private static void onUpdate(Player player) throws IOException { final Component component = Component.empty() - .append(getPrefix(player)) + .append( + isUsingVanillaFormat(player) ? + Component.empty() : getPrefix(player) + ) .append(player.displayName()); player.playerListName(component);