diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index dfc73601d6..9e1fe92d39 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -204,15 +204,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.player; + -+import java.util.Set; +import io.papermc.paper.chat.ChatRenderer; +import net.kyori.adventure.audience.Audience; ++import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; + ++import java.util.Set; ++ +import static java.util.Objects.requireNonNull; + +/** @@ -221,16 +223,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public abstract class AbstractChatEvent extends PlayerEvent implements Cancellable { + private final Set viewers; + private final Component originalMessage; ++ private final SignedMessage signedMessage; + private ChatRenderer renderer; + private Component message; + private boolean cancelled = false; + -+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) { ++ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + super(player, async); + this.viewers = viewers; + this.renderer = renderer; + this.message = message; + this.originalMessage = originalMessage; ++ this.signedMessage = signedMessage; + } + + /** @@ -304,6 +308,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.originalMessage; + } + ++ /** ++ * Gets the signed message. ++ * Changes made in this event will not update ++ * the signed message. ++ * ++ * @return the signed message ++ */ ++ @NotNull ++ public final SignedMessage signedMessage() { ++ return this.signedMessage; ++ } ++ + @Override + public final boolean isCancelled() { + return this.cancelled; @@ -481,6 +497,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Set; +import io.papermc.paper.chat.ChatRenderer; +import net.kyori.adventure.audience.Audience; ++import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; @@ -492,8 +509,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public final class AsyncChatEvent extends AbstractChatEvent { + private static final HandlerList HANDLERS = new HandlerList(); + -+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) { -+ super(async, player, viewers, renderer, message, originalMessage); ++ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { ++ super(async, player, viewers, renderer, message, originalMessage, signedMessage); + } + + @NotNull @@ -518,6 +535,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Set; +import io.papermc.paper.chat.ChatRenderer; +import net.kyori.adventure.audience.Audience; ++import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.text.Component; +import org.bukkit.Warning; +import org.bukkit.entity.Player; @@ -534,8 +552,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public final class ChatEvent extends AbstractChatEvent { + private static final HandlerList HANDLERS = new HandlerList(); + -+ public ChatEvent(final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) { -+ super(false, player, viewers, renderer, message, originalMessage); ++ public ChatEvent(final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { ++ super(false, player, viewers, renderer, message, originalMessage, signedMessage); + } + + @NotNull diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 7337e2e762..5da3d4123a 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -427,7 +427,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + private void processModern(final ChatRenderer renderer, final Set viewers, final Component message, final Player player, final boolean cancelled) { -+ final AsyncChatEvent ae = new AsyncChatEvent(this.async, player, viewers, renderer, message, this.paper$originalMessage); ++ final PlayerChatMessage.AdventureView signedMessage = this.message.adventureView(); ++ final AsyncChatEvent ae = new AsyncChatEvent(this.async, player, viewers, renderer, message, this.paper$originalMessage, signedMessage); + ae.setCancelled(cancelled); // propagate cancelled state + this.post(ae); + final boolean listenersOnSyncEvent = canYouHearMe(ChatEvent.getHandlerList()); @@ -435,7 +436,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.queueIfAsyncOrRunImmediately(new Waitable() { + @Override + protected Void evaluate() { -+ final ChatEvent se = new ChatEvent(player, ae.viewers(), ae.renderer(), ae.message(), ChatProcessor.this.paper$originalMessage/*, ae.usePreviewComponent()*/); ++ final ChatEvent se = new ChatEvent(player, ae.viewers(), ae.renderer(), ae.message(), ChatProcessor.this.paper$originalMessage/*, ae.usePreviewComponent()*/, signedMessage); + se.setCancelled(ae.isCancelled()); // propagate cancelled state + ChatProcessor.this.post(se); + ChatProcessor.this.readModernModifications(se, renderer);