From ee0bafc6a3142a8355d56ecf035e32cffd19614a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 21 May 2021 18:08:18 -0700 Subject: [PATCH] Fix default ChatRenderer when no plugins are installed (#5702) --- Spigot-API-Patches/Adventure.patch | 12 ++++++++++-- Spigot-Server-Patches/Adventure.patch | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Spigot-API-Patches/Adventure.patch b/Spigot-API-Patches/Adventure.patch index 5c4dc1b51..fcb4253a4 100644 --- a/Spigot-API-Patches/Adventure.patch +++ b/Spigot-API-Patches/Adventure.patch @@ -191,8 +191,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@FunctionalInterface +public interface ChatRenderer { -+ ChatRenderer DEFAULT = viewerUnaware((source, sourceDisplayName, message) -> Component.translatable("chat.type.text", sourceDisplayName, message)); -+ + /** + * Renders a chat message. This will be called once for each receiving {@link Audience}. + * @@ -206,6 +204,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer); + + /** ++ * Create a new instance of the default {@link ChatRenderer}. ++ * ++ * @return a new {@link ChatRenderer} ++ */ ++ @NotNull ++ static ChatRenderer defaultRenderer() { ++ return viewerUnaware((source, sourceDisplayName, message) -> Component.translatable("chat.type.text", sourceDisplayName, message)); ++ } ++ ++ /** + * Creates a new viewer-unaware {@link ChatRenderer}, which will render the chat message a single time, + * displaying the same rendered message to every viewing {@link Audience}. + * diff --git a/Spigot-Server-Patches/Adventure.patch b/Spigot-Server-Patches/Adventure.patch index 72ab1a101..62337c9c7 100644 --- a/Spigot-Server-Patches/Adventure.patch +++ b/Spigot-Server-Patches/Adventure.patch @@ -189,7 +189,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // no legacy events called, all nice and fresh! + () -> { + this.processModern( -+ ChatRenderer.DEFAULT, ++ ChatRenderer.defaultRenderer(), + new LazyPlayerSet(this.server), + Component.text(this.message).replaceText(URL_REPLACEMENT_CONFIG), + false