Yatopia/patches/Purpur/patches/server/0052-Skip-events-if-there-s...

27 lines
1.5 KiB
Diff

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/CommandDispatcher.java b/src/main/java/net/minecraft/commands/CommandDispatcher.java
index 7e30ec9a08d919d2ae9218ee0a11f77719129f07..b1bfc42b4153b225243ba65e7f937c0314cb39a5 100644
--- a/src/main/java/net/minecraft/commands/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/commands/CommandDispatcher.java
@@ -368,6 +368,7 @@ public class CommandDispatcher {
}
private void runSync(EntityPlayer entityplayer, Collection<String> bukkit, RootCommandNode<ICompletionProvider> 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<CommandListenerWrapper>(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit));
@@ -380,6 +381,7 @@ public class CommandDispatcher {
}
}
// CraftBukkit end
+ } // Purpur - skip event
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
}