From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 4 Apr 2020 03:07:59 -0500
Subject: [PATCH] Skip events if there's no listeners


diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index a6f10d47bc4e2cadcc3e06cffa011ed7fb97c68d..59881c845cc88508736cc3d2a61860512d28964d 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -375,6 +375,7 @@ public class Commands {
     }
 
     private void runSync(ServerPlayer entityplayer, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
+        if (PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Purpur - skip all this crap if there's nothing listening
         // Paper end - Async command map building
         new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
         PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit));
@@ -387,6 +388,7 @@ public class Commands {
             }
         }
         // CraftBukkit end
+        } // Purpur - skip event
         entityplayer.connection.send(new ClientboundCommandsPacket(rootcommandnode));
     }
 
