diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 5f3c425ed7..1bee3cc844 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -334,8 +334,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ public AsyncChatCommandDecorateEvent(boolean async, @Nullable Player player, @NotNull Component originalMessage, boolean isPreview, @NotNull Component result) { -+ super(async, player, originalMessage, isPreview, result); ++ @ApiStatus.Internal ++ public AsyncChatCommandDecorateEvent(boolean async, @Nullable Player player, @NotNull Component originalMessage, @NotNull Component result) { ++ super(async, player, originalMessage, result); + } + + @Override @@ -361,20 +362,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.server.ServerEvent; +import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** -+ * This event is fired when the server decorates a component for chat purposes. It can be called -+ * under the following circumstances: -+ * ++ * This event is fired when the server decorates a component for chat purposes. This is called ++ * before {@link AsyncChatEvent} and the other chat events. It is recommended that you modify the ++ * message here, and use the chat events for modifying receivers and later the chat type. If you ++ * want to keep the message as "signed" for the clients who get it, be sure to include the entire ++ * original message somewhere in the final message. + * @see AsyncChatCommandDecorateEvent for the decoration of messages sent via commands + */ +@ApiStatus.Experimental @@ -384,16 +381,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final Player player; + private final Component originalMessage; -+ private final boolean isPreview; + private Component result; + private boolean cancelled; + + @ApiStatus.Internal -+ public AsyncChatDecorateEvent(final boolean async, final @Nullable Player player, final @NotNull Component originalMessage, final boolean isPreview, final @NotNull Component result) { ++ public AsyncChatDecorateEvent(final boolean async, final @Nullable Player player, final @NotNull Component originalMessage, final @NotNull Component result) { + super(async); + this.player = player; + this.originalMessage = originalMessage; -+ this.isPreview = isPreview; + this.result = result; + } + @@ -443,9 +438,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * If this decorating is part of a preview request/response. + * + * @return true if part of previewing ++ * @deprecated chat preview was removed in 1.19.2 + */ ++ @Deprecated(forRemoval = true) ++ @Contract(value = "-> false", pure = true) + public boolean isPreview() { -+ return this.isPreview; ++ return false; + } + + @Override diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 8489b52989..89c8d0c1b5 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -157,13 +157,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public CompletableFuture process() { + return CompletableFuture.supplyAsync(() -> { + ChatDecorator.Result result = new ChatDecorator.ModernResult(this.originalMessage, true, false); -+ if (canYouHearMe(AsyncPlayerChatPreviewEvent.getHandlerList())) { ++ if (listenToLegacy()) { + result = this.processLegacy(result); + } + return this.processModern(result); + }, this.server.chatExecutor); + } + ++ @SuppressWarnings("deprecation") ++ private static boolean listenToLegacy() { ++ return canYouHearMe(AsyncPlayerChatPreviewEvent.getHandlerList()); ++ } ++ ++ @SuppressWarnings("deprecation") + private ChatDecorator.Result processLegacy(final ChatDecorator.Result input) { + if (this.player != null) { + final CraftPlayer player = this.player.getBukkitEntity(); @@ -188,12 +194,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + final Component initialResult = input.message().component(); + final AsyncChatDecorateEvent event; -+ //TODO + if (this.commandSourceStack != null) { + // TODO more command decorate context -+ event = new AsyncChatCommandDecorateEvent(true, player, this.originalMessage, false, initialResult); ++ event = new AsyncChatCommandDecorateEvent(true, player, this.originalMessage, initialResult); + } else { -+ event = new AsyncChatDecorateEvent(true, player, this.originalMessage, false, initialResult); ++ event = new AsyncChatDecorateEvent(true, player, this.originalMessage, initialResult); + } + this.post(event); + if (!event.isCancelled() && !event.result().equals(initialResult)) {