aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0817-Don-t-broadcast-messages-to-command-blocks.patch
blob: c5919aa53c54a9434e2d58bd686b3b2166de9289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 16 Jun 2022 14:22:56 -0700
Subject: [PATCH] Don't broadcast messages to command blocks

Previously the broadcast method would update the last output
in command blocks, and if called asynchronously, would throw
an error

diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
index c56f5173fda6b38c2dcaea196217f2f5a7d7c641..d4ff8c6b7801e33be4ff69b8bae13c09f4872c4b 100644
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
@@ -172,6 +172,7 @@ public abstract class BaseCommandBlock implements CommandSource {
     @Override
     public void sendSystemMessage(Component message) {
         if (this.trackOutput) {
+            org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper
             SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT;
             Date date = new Date();
 
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0759824929144805d55b4953863eacd5ae1542e0..7c8d21499d49aa88ad771e98a8e5302d1b3a3229 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1872,7 +1872,7 @@ public final class CraftServer implements Server {
         // Paper end
         Set<CommandSender> recipients = new HashSet<>();
         for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) {
-            if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
+            if (permissible instanceof CommandSender && !(permissible instanceof org.bukkit.command.BlockCommandSender) && permissible.hasPermission(permission)) { // Paper - don't broadcast to BlockCommandSender (specifically Command Blocks)
                 recipients.add((CommandSender) permissible);
             }
         }