Interface ChatDecorator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ChatDecorator
Chat decorator decorates the chat server-side. Currently, only one chat decorator can exist at a time. The chat decorator that is currently used can be obtained by MinecraftServer.getChatDecorator().

For the chat decorator to produce a signed message, both the server and the sender's client need to have chat previews enabled, Otherwise, the decorated content is considered unsigned, and if the clients require chat messages to be signed via the "Only Show Secure Chat" option, they will see the undecorated message. Therefore, chat decorator is not recommended for censoring messages.

It is very important that the decorator return the same text when previewed and sent. If this is not followed correctly, the server detects that the client sent a forged text and discards the message. For example, a decorator that appends the time the decoration was applied would be likely to fail, since there is usually a delay between the previewing and the submission. One way to solve this issue is to make it cache the result on preview, so that when the sent message needs decorating, the cached value can be used.

Mappings:
Namespace Name
official rg
intermediary net/minecraft/class_7492
named net/minecraft/network/ChatDecorator
  • Field Details

    • NOOP

      static final ChatDecorator NOOP
      An empty chat decorator that does not decorate anything.
      Mappings:
      Namespace Name Mixin selector
      official a Lrg;a:Lrg;
      intermediary field_39384 Lnet/minecraft/class_7492;field_39384:Lnet/minecraft/class_7492;
      named NOOP Lnet/minecraft/network/ChatDecorator;NOOP:Lnet/minecraft/network/ChatDecorator;
  • Method Details

    • decorate

      Returns the signed chat message with unsigned content set as decorated message.

      If the received player requires signed chat message, they will see the original content.

      Returns:
      the signed chat message with unsigned content set as decorated message
      Mappings:
      Namespace Name Mixin selector
      official decorate Lrg;decorate(Lafp;Lrm;)Ljava/util/concurrent/CompletableFuture;
      intermediary decorate Lnet/minecraft/class_7492;decorate(Lnet/minecraft/class_3222;Lnet/minecraft/class_2561;)Ljava/util/concurrent/CompletableFuture;
      named decorate Lnet/minecraft/network/ChatDecorator;decorate(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/text/Text;)Ljava/util/concurrent/CompletableFuture;
    • decorateFiltered

      Returns the decorated signed chat message from undecorated message.

      If previewed is false, the returned message will have the original content as signed and the decorated content as unsigned. This means that if the received player requires signed chat message, they will see the original content.

      If message has a filtered part, this will decorate both the raw and the filtered text.

      Returns:
      the decorated signed chat message from undecorated message
      Mappings:
      Namespace Name Mixin selector
      official decorateFiltered Lrg;decorateFiltered(Lafp;Lagd;)Ljava/util/concurrent/CompletableFuture;
      intermediary decorateFiltered Lnet/minecraft/class_7492;decorateFiltered(Lnet/minecraft/class_3222;Lnet/minecraft/class_5837;)Ljava/util/concurrent/CompletableFuture;
      named decorateFiltered Lnet/minecraft/network/ChatDecorator;decorateFiltered(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/server/filter/FilteredMessage;)Ljava/util/concurrent/CompletableFuture;
    • decorateChat

      default CompletableFuture<FilteredMessage<SignedChatMessage>> decorateChat(@Nullable @Nullable ServerPlayerEntity sender, FilteredMessage<Text> message, ChatMessageSignature signature, boolean previewed)
      Returns the decorated signed chat message from undecorated message.

      If previewed is false, the returned message will have the original content as signed and the decorated content as unsigned. This means that if the received player requires signed chat message, they will see the original content.

      Parameters:
      previewed - whether the decoration was previewed by the sender's client
      Returns:
      the decorated signed chat message from undecorated message
      Mappings:
      Namespace Name Mixin selector
      official decorateChat Lrg;decorateChat(Lafp;Lagd;Lrr;Z)Ljava/util/concurrent/CompletableFuture;
      intermediary decorateChat Lnet/minecraft/class_7492;decorateChat(Lnet/minecraft/class_3222;Lnet/minecraft/class_5837;Lnet/minecraft/class_7469;Z)Ljava/util/concurrent/CompletableFuture;
      named decorateChat Lnet/minecraft/network/ChatDecorator;decorateChat(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/server/filter/FilteredMessage;Lnet/minecraft/network/encryption/ChatMessageSignature;Z)Ljava/util/concurrent/CompletableFuture;