From 02fb33c3ee8378b2c57434a341ef760d86b9f2ab Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Sat, 14 Dec 2024 18:44:07 +0100 Subject: [PATCH] net.minecraft.network.chat --- .../network/chat/ChatDecorator.java.patch | 20 +++++++++ .../network/chat/Component.java.patch | 14 +++--- .../chat/ComponentSerialization.java.patch | 26 +++++------ .../network/chat/ComponentUtils.java.patch | 33 +++++++++----- .../network/chat/MessageSignature.java.patch | 2 +- .../network/chat/MutableComponent.java.patch | 12 ++--- .../chat/OutgoingChatMessage.java.patch | 43 ++++++++++++++++++ .../network/chat/PlayerChatMessage.java.patch | 11 ++--- .../chat/SignedMessageChain.java.patch | 16 +++---- .../network/chat/TextColor.java.patch | 34 ++++++++++++++ .../network/chat/ChatDecorator.java.patch | 23 ---------- .../chat/OutgoingChatMessage.java.patch | 44 ------------------- .../network/chat/TextColor.java.patch | 37 ---------------- 13 files changed, 156 insertions(+), 159 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/Component.java.patch (58%) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/ComponentSerialization.java.patch (90%) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/ComponentUtils.java.patch (57%) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/MessageSignature.java.patch (96%) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/MutableComponent.java.patch (50%) create mode 100644 paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/PlayerChatMessage.java.patch (89%) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/chat/SignedMessageChain.java.patch (91%) create mode 100644 paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/network/chat/ChatDecorator.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/network/chat/OutgoingChatMessage.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/network/chat/TextColor.java.patch diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch new file mode 100644 index 0000000000..26ba981ff1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/network/chat/ChatDecorator.java ++++ b/net/minecraft/network/chat/ChatDecorator.java +@@ -5,7 +_,14 @@ + + @FunctionalInterface + public interface ChatDecorator { +- ChatDecorator PLAIN = (player, message) -> message; +- +- Component decorate(@Nullable ServerPlayer player, Component message); ++ ChatDecorator PLAIN = (sender, message) -> java.util.concurrent.CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events ++ ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack) ++ java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, Component message); // Paper - adventure; support async chat decoration events ++ ++ // Paper start - adventure; support async chat decoration events ++ default java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) { ++ throw new UnsupportedOperationException("Must override this implementation"); ++ } ++ // Paper end - adventure; support async chat decoration events + } diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/Component.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch similarity index 58% rename from paper-server/patches/unapplied/net/minecraft/network/chat/Component.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch index 5db0b612a2..96b7d8debc 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/Component.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch @@ -1,23 +1,19 @@ --- a/net/minecraft/network/chat/Component.java +++ b/net/minecraft/network/chat/Component.java -@@ -37,9 +37,23 @@ - import net.minecraft.resources.ResourceLocation; +@@ -37,7 +_,19 @@ import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.level.ChunkPos; -+// CraftBukkit start -+import java.util.stream.Stream; -+// CraftBukkit end -public interface Component extends Message, FormattedText { +public interface Component extends Message, FormattedText, Iterable { // CraftBukkit + + // CraftBukkit start -+ default Stream stream() { -+ return com.google.common.collect.Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); ++ default java.util.stream.Stream stream() { ++ return com.google.common.collect.Streams.concat(new java.util.stream.Stream[]{java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); + } - ++ + @Override -+ default Iterator iterator() { ++ default java.util.Iterator iterator() { + return this.stream().iterator(); + } + // CraftBukkit end diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/ComponentSerialization.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch similarity index 90% rename from paper-server/patches/unapplied/net/minecraft/network/chat/ComponentSerialization.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch index 4136889ef4..1ae5d92462 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/ComponentSerialization.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/ComponentSerialization.java +++ b/net/minecraft/network/chat/ComponentSerialization.java -@@ -37,9 +37,31 @@ +@@ -37,9 +_,31 @@ public class ComponentSerialization { public static final Codec CODEC = Codec.recursive("Component", ComponentSerialization::createCodec); @@ -34,8 +34,8 @@ public static final StreamCodec> TRUSTED_OPTIONAL_STREAM_CODEC = TRUSTED_STREAM_CODEC.apply( ByteBufCodecs::optional ); -@@ -100,7 +122,27 @@ - return ExtraCodecs.orCompressed(mapCodec3, mapCodec2); +@@ -102,7 +_,25 @@ + return ExtraCodecs.orCompressed(mapCodec2, mapCodec1); } + // Paper start - adventure; create separate codec for each locale @@ -48,23 +48,21 @@ + return LOCALIZED_CODECS.computeIfAbsent(locale, + loc -> Codec.recursive("Component", selfCodec -> createCodec(selfCodec, loc))); + } -+ -+ + // Paper end - adventure; create separate codec for each locale + - private static Codec createCodec(Codec selfCodec) { + private static Codec createCodec(Codec codec) { + // Paper start - adventure; create separate codec for each locale -+ return createCodec(selfCodec, null); ++ return createCodec(codec, null); + } + -+ private static Codec createCodec(Codec selfCodec, @javax.annotation.Nullable java.util.Locale locale) { ++ private static Codec createCodec(Codec codec, @javax.annotation.Nullable java.util.Locale locale) { + // Paper end - adventure; create separate codec for each locale ComponentContents.Type[] types = new ComponentContents.Type[]{ PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE }; -@@ -113,6 +155,34 @@ - ) - .apply(instance, MutableComponent::new) +@@ -115,6 +_,34 @@ + ) + .apply(instance, MutableComponent::new) ); + // Paper start - adventure; create separate codec for each locale + final Codec origCodec = codec; @@ -94,6 +92,6 @@ + } + }; + // Paper end - adventure; create separate codec for each locale - return Codec.either(Codec.either(Codec.STRING, ExtraCodecs.nonEmptyList(selfCodec.listOf())), codec) - .xmap(either -> either.map(either2 -> either2.map(Component::literal, ComponentSerialization::createFromList), text -> (Component)text), text -> { - String string = text.tryCollapseToString(); + return Codec.either(Codec.either(Codec.STRING, ExtraCodecs.nonEmptyList(codec.listOf())), codec1) + .xmap( + either -> either.map(either1 -> either1.map(Component::literal, ComponentSerialization::createFromList), component -> (Component)component), diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/ComponentUtils.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch similarity index 57% rename from paper-server/patches/unapplied/net/minecraft/network/chat/ComponentUtils.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch index c7b1b54e5a..e3ea7a636b 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/ComponentUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/network/chat/ComponentUtils.java +++ b/net/minecraft/network/chat/ComponentUtils.java -@@ -33,14 +33,39 @@ +@@ -33,6 +_,7 @@ } } + @io.papermc.paper.annotation.DoNotUse // Paper - validate separators - right now this method is only used for separator evaluation. Error on build if this changes to re-evaluate. - public static Optional updateForEntity(@Nullable CommandSourceStack source, Optional text, @Nullable Entity sender, int depth) throws CommandSyntaxException { - return text.isPresent() ? Optional.of(updateForEntity(source, text.get(), sender, depth)) : Optional.empty(); + public static Optional updateForEntity( + @Nullable CommandSourceStack commandSourceStack, Optional optionalComponent, @Nullable Entity entity, int recursionDepth + ) throws CommandSyntaxException { +@@ -41,12 +_,40 @@ + : Optional.empty(); } + // Paper start - validate separator @@ -14,13 +17,16 @@ + if (text.isEmpty() || !isValidSelector(text.get())) return Optional.empty(); + return Optional.of(updateForEntity(source, text.get(), sender, depth)); + } ++ + public static boolean isValidSelector(final Component component) { + final ComponentContents contents = component.getContents(); + -+ if (contents instanceof net.minecraft.network.chat.contents.NbtContents || contents instanceof net.minecraft.network.chat.contents.SelectorContents) return false; ++ if (contents instanceof net.minecraft.network.chat.contents.NbtContents || contents instanceof net.minecraft.network.chat.contents.SelectorContents) ++ return false; + if (contents instanceof final net.minecraft.network.chat.contents.TranslatableContents translatableContents) { + for (final Object arg : translatableContents.getArgs()) { -+ if (arg instanceof final Component argumentAsComponent && !isValidSelector(argumentAsComponent)) return false; ++ if (arg instanceof final Component argumentAsComponent && !isValidSelector(argumentAsComponent)) ++ return false; + } + } + @@ -28,15 +34,18 @@ + } + // Paper end - validate separator + - public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException { - if (depth > 100) { - return text.copy(); + public static MutableComponent updateForEntity( + @Nullable CommandSourceStack commandSourceStack, Component component, @Nullable Entity entity, int recursionDepth + ) throws CommandSyntaxException { + if (recursionDepth > 100) { + return component.copy(); } else { + // Paper start - adventure; pass actual vanilla component -+ if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { -+ text = adventureComponent.deepConverted(); ++ if (component instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { ++ component = adventureComponent.deepConverted(); + } + // Paper end - adventure; pass actual vanilla component - MutableComponent mutableComponent = text.getContents().resolve(source, sender, depth + 1); ++ + MutableComponent mutableComponent = component.getContents().resolve(commandSourceStack, entity, recursionDepth + 1); - for (Component component : text.getSiblings()) { + for (Component component1 : component.getSiblings()) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/MessageSignature.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch similarity index 96% rename from paper-server/patches/unapplied/net/minecraft/network/chat/MessageSignature.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch index 2b6f690732..af25ad25c9 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/MessageSignature.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/MessageSignature.java +++ b/net/minecraft/network/chat/MessageSignature.java -@@ -13,6 +13,7 @@ +@@ -13,6 +_,7 @@ import net.minecraft.util.SignatureValidator; public record MessageSignature(byte[] bytes) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/MutableComponent.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch similarity index 50% rename from paper-server/patches/unapplied/net/minecraft/network/chat/MutableComponent.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch index c4694faca6..99e4fad8ac 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/MutableComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/network/chat/MutableComponent.java +++ b/net/minecraft/network/chat/MutableComponent.java -@@ -94,6 +94,11 @@ +@@ -94,6 +_,11 @@ @Override - public boolean equals(Object object) { + public boolean equals(Object other) { + // Paper start - make AdventureComponent equivalent -+ if (object instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { -+ object = adventureComponent.deepConverted(); ++ if (other instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { ++ other = adventureComponent.deepConverted(); + } + // Paper end - make AdventureComponent equivalent - return this == object - || object instanceof MutableComponent mutableComponent + return this == other + || other instanceof MutableComponent mutableComponent && this.contents.equals(mutableComponent.contents) diff --git a/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch new file mode 100644 index 0000000000..4dd32b8b49 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/network/chat/OutgoingChatMessage.java ++++ b/net/minecraft/network/chat/OutgoingChatMessage.java +@@ -7,6 +_,12 @@ + + void sendToPlayer(ServerPlayer player, boolean filtered, ChatType.Bound boundType); + ++ // Paper start ++ default void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) { ++ this.sendToPlayer(sender, filterMaskEnabled, params); ++ } ++ // Paper end ++ + static OutgoingChatMessage create(PlayerChatMessage message) { + return (OutgoingChatMessage)(message.isSystem() + ? new OutgoingChatMessage.Disguised(message.decoratedContent()) +@@ -16,7 +_,12 @@ + public record Disguised(@Override Component content) implements OutgoingChatMessage { + @Override + public void sendToPlayer(ServerPlayer player, boolean filtered, ChatType.Bound boundType) { +- player.connection.sendDisguisedChatMessage(this.content, boundType); ++ // Paper start ++ this.sendToPlayer(player, filtered, boundType, null); ++ } ++ public void sendToPlayer(ServerPlayer player, boolean filtered, ChatType.Bound boundType, @javax.annotation.Nullable Component unsigned) { ++ player.connection.sendDisguisedChatMessage(unsigned != null ? unsigned : this.content, boundType); ++ // Paper end + } + } + +@@ -28,7 +_,13 @@ + + @Override + public void sendToPlayer(ServerPlayer player, boolean filtered, ChatType.Bound boundType) { ++ // Paper start ++ this.sendToPlayer(player, filtered, boundType, null); ++ } ++ public void sendToPlayer(ServerPlayer player, boolean filtered, ChatType.Bound boundType, @javax.annotation.Nullable Component unsigned) { ++ // Paper end + PlayerChatMessage playerChatMessage = this.message.filter(filtered); ++ playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper + if (!playerChatMessage.isFullyFiltered()) { + player.connection.sendPlayerChatMessage(playerChatMessage, boundType); + } diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/PlayerChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch similarity index 89% rename from paper-server/patches/unapplied/net/minecraft/network/chat/PlayerChatMessage.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch index 8722bc8269..bf7ae66175 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/PlayerChatMessage.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/PlayerChatMessage.java +++ b/net/minecraft/network/chat/PlayerChatMessage.java -@@ -17,6 +17,42 @@ +@@ -17,6 +_,43 @@ public record PlayerChatMessage( SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask ) { @@ -40,14 +40,15 @@ + return new AdventureView(); + } + // Paper end - adventure; support signed messages ++ public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( - SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link), -@@ -47,7 +83,14 @@ + SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link), +@@ -47,7 +_,14 @@ } - public PlayerChatMessage withUnsignedContent(Component unsignedContent) { -- Component component = !unsignedContent.equals(Component.literal(this.signedContent())) ? unsignedContent : null; + public PlayerChatMessage withUnsignedContent(Component message) { +- Component component = !message.equals(Component.literal(this.signedContent())) ? message : null; + // Paper start - adventure + final Component component; + if (unsignedContent instanceof io.papermc.paper.adventure.AdventureComponent advComponent) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch similarity index 91% rename from paper-server/patches/unapplied/net/minecraft/network/chat/SignedMessageChain.java.patch rename to paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch index 9404843b29..39e328fbef 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/SignedMessageChain.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/network/chat/SignedMessageChain.java +++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -40,14 +40,14 @@ +@@ -40,14 +_,14 @@ if (signature == null) { throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.MISSING_PROFILE_KEY); - } else if (playerPublicKey.data().hasExpired()) { + } else if (publicKey.data().hasExpired()) { - throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY); + throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes } else { @@ -17,21 +17,21 @@ } else { SignedMessageChain.this.lastTimeStamp = body.timeStamp(); PlayerChatMessage playerChatMessage = new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH); -@@ -80,9 +80,16 @@ +@@ -80,8 +_,15 @@ static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); -- public DecodeException(Component message) { +- public DecodeException(Component component) { +- super(component); + // Paper start + public final org.bukkit.event.player.PlayerKickEvent.Cause kickCause; + public DecodeException(Component message, org.bukkit.event.player.PlayerKickEvent.Cause event) { - super(message); ++ super(message); + this.kickCause = event; - } ++ } + // Paper end + public DecodeException(Component message) { + this(message, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); // Paper -+ } + } } - @FunctionalInterface diff --git a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch new file mode 100644 index 0000000000..b9e08a06cf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/network/chat/TextColor.java ++++ b/net/minecraft/network/chat/TextColor.java +@@ -17,23 +_,29 @@ + public static final Codec CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); + private static final Map LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()) + .filter(ChatFormatting::isColor) +- .collect(ImmutableMap.toImmutableMap(Function.identity(), formatting -> new TextColor(formatting.getColor(), formatting.getName()))); ++ .collect(ImmutableMap.toImmutableMap(Function.identity(), formatting -> new TextColor(formatting.getColor(), formatting.getName(), formatting))); // CraftBukkit + private static final Map NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values() + .stream() + .collect(ImmutableMap.toImmutableMap(textColor -> textColor.name, Function.identity())); + private final int value; + @Nullable + public final String name; ++ // CraftBukkit start ++ @Nullable ++ public final ChatFormatting format; + +- private TextColor(int value, String name) { ++ private TextColor(int value, String name, ChatFormatting format) { + this.value = value & 16777215; + this.name = name; ++ this.format = format; + } + + private TextColor(int value) { + this.value = value & 16777215; + this.name = null; ++ this.format = null; + } ++ // CraftBukkit end + + public int getValue() { + return this.value; diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/ChatDecorator.java.patch b/paper-server/patches/unapplied/net/minecraft/network/chat/ChatDecorator.java.patch deleted file mode 100644 index 8fe79b8a75..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/ChatDecorator.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/network/chat/ChatDecorator.java -+++ b/net/minecraft/network/chat/ChatDecorator.java -@@ -2,10 +2,18 @@ - - import javax.annotation.Nullable; - import net.minecraft.server.level.ServerPlayer; -+import java.util.concurrent.CompletableFuture; // Paper - - @FunctionalInterface - public interface ChatDecorator { -- ChatDecorator PLAIN = (sender, message) -> message; -+ ChatDecorator PLAIN = (sender, message) -> CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events - -- Component decorate(@Nullable ServerPlayer sender, Component message); -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack) -+ CompletableFuture decorate(@Nullable ServerPlayer sender, Component message); // Paper - adventure; support async chat decoration events -+ -+ // Paper start - adventure; support async chat decoration events -+ default CompletableFuture decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) { -+ throw new UnsupportedOperationException("Must override this implementation"); -+ } -+ // Paper end - adventure; support async chat decoration events - } diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/OutgoingChatMessage.java.patch b/paper-server/patches/unapplied/net/minecraft/network/chat/OutgoingChatMessage.java.patch deleted file mode 100644 index 3192e18db3..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/OutgoingChatMessage.java.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/network/chat/OutgoingChatMessage.java -+++ b/net/minecraft/network/chat/OutgoingChatMessage.java -@@ -7,6 +7,12 @@ - - void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params); - -+ // Paper start -+ default void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) { -+ this.sendToPlayer(sender, filterMaskEnabled, params); -+ } -+ // Paper end -+ - static OutgoingChatMessage create(PlayerChatMessage message) { - return (OutgoingChatMessage)(message.isSystem() - ? new OutgoingChatMessage.Disguised(message.decoratedContent()) -@@ -16,8 +22,13 @@ - public static record Disguised(@Override Component content) implements OutgoingChatMessage { - @Override - public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params) { -- sender.connection.sendDisguisedChatMessage(this.content, params); -+ // Paper start -+ this.sendToPlayer(sender, filterMaskEnabled, params, null); - } -+ public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) { -+ sender.connection.sendDisguisedChatMessage(unsigned != null ? unsigned : this.content, params); -+ // Paper end -+ } - } - - public static record Player(PlayerChatMessage message) implements OutgoingChatMessage { -@@ -28,7 +39,13 @@ - - @Override - public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params) { -+ // Paper start -+ this.sendToPlayer(sender, filterMaskEnabled, params, null); -+ } -+ public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) { -+ // Paper end - PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled); -+ playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper - if (!playerChatMessage.isFullyFiltered()) { - sender.connection.sendPlayerChatMessage(playerChatMessage, params); - } diff --git a/paper-server/patches/unapplied/net/minecraft/network/chat/TextColor.java.patch b/paper-server/patches/unapplied/net/minecraft/network/chat/TextColor.java.patch deleted file mode 100644 index 014fd3eb10..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/chat/TextColor.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/network/chat/TextColor.java -+++ b/net/minecraft/network/chat/TextColor.java -@@ -17,7 +17,7 @@ - private static final String CUSTOM_COLOR_PREFIX = "#"; - public static final Codec CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); - private static final Map LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(ChatFormatting.values()).filter(ChatFormatting::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { -- return new TextColor(enumchatformat.getColor(), enumchatformat.getName()); -+ return new TextColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit - })); - private static final Map NAMED_COLORS = (Map) TextColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { - return chathexcolor.name; -@@ -25,16 +25,22 @@ - private final int value; - @Nullable - public final String name; -+ // CraftBukkit start -+ @Nullable -+ public final ChatFormatting format; - -- private TextColor(int rgb, String name) { -- this.value = rgb & 16777215; -- this.name = name; -+ private TextColor(int i, String s, ChatFormatting format) { -+ this.value = i & 16777215; -+ this.name = s; -+ this.format = format; - } - - private TextColor(int rgb) { - this.value = rgb & 16777215; - this.name = null; -+ this.format = null; - } -+ // CraftBukkit end - - public int getValue() { - return this.value;