Fix default ChatRenderer when no plugins are installed (#5702)

This commit is contained in:
Jason Penilla 2021-05-21 18:08:18 -07:00
parent de5d8a76fe
commit ee0bafc6a3
2 changed files with 11 additions and 3 deletions

View File

@ -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}.
+ *

View File

@ -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