Yatopia/patches/server/0047-Purpur-Skip-events-if-there-s-no-listeners.patch
2020-06-16 16:46:05 +02:00

33 lines
1.6 KiB
Diff

From f9c1e2d385c6f03e1c7353b41f1252d84ec28fa9 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] Purpur Skip events if there's no listeners
---
src/main/java/net/minecraft/server/CommandDispatcher.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
index 2d512aa4f..2c8ef6dd6 100644
--- a/src/main/java/net/minecraft/server/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
@@ -274,6 +274,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));
@@ -286,6 +287,7 @@ public class CommandDispatcher {
}
}
// CraftBukkit end
+ } // Purpur - skip event
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
}
--
2.25.1.windows.1