From 8b829bd61143b3b0efec992a8e95cc135d6794d6 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke <nassim@njahnke.dev> Date: Thu, 28 Jul 2022 01:59:19 +0200 Subject: [PATCH] Don't fire preview event for non-player senders Fixes #8195 --- .../Dont-fire-preview-event-for-console.patch | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 patches/server/Dont-fire-preview-event-for-console.patch diff --git a/patches/server/Dont-fire-preview-event-for-console.patch b/patches/server/Dont-fire-preview-event-for-console.patch new file mode 100644 index 0000000000..4857a4e7cb --- /dev/null +++ b/patches/server/Dont-fire-preview-event-for-console.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nassim Jahnke <nassim@njahnke.dev> +Date: Thu, 28 Jul 2022 01:57:24 +0200 +Subject: [PATCH] Dont fire preview event for console + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + + public ChatDecorator getChatDecorator() { + return (entityplayer, ichatbasecomponent) -> { ++ // Paper start - fix non-player sender ++ if (entityplayer == null) { ++ return CompletableFuture.completedFuture(ichatbasecomponent); ++ } ++ // Paper end + return CompletableFuture.supplyAsync(() -> { + AsyncPlayerChatPreviewEvent event = new AsyncPlayerChatPreviewEvent(true, entityplayer.getBukkitEntity(), CraftChatMessage.fromComponent(ichatbasecomponent), new LazyPlayerSet(this)); + String originalFormat = event.getFormat(), originalMessage = event.getMessage();