Fix URL replacement in vanilla format

This commit is contained in:
OptimisticDeving 2024-06-25 03:23:12 +00:00
parent 90ef97a6c0
commit fb209a44c3
Signed by: opt
SSH key fingerprint: SHA256:efAXeDMyuFt1iia2xaqlrcHPlsXcjQEWNA2tmvVTqK8

View file

@ -41,10 +41,6 @@ public final class PlayerChat implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
void onAsyncChatEventRenderer(final AsyncChatEvent event) {
if (PlayerPrefix.isUsingVanillaFormat(event.getPlayer())) {
return;
}
event.renderer(CHAT_RENDERER);
}
@ -87,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;