From 06044e24584c48a6c8380872a250275b06418b6d Mon Sep 17 00:00:00 2001 From: Callahan Date: Thu, 9 Apr 2020 01:49:38 -0500 Subject: [PATCH] Async command map building Reduces lag created on login and world change for sending the command map to client --- .../0468-Async-command-map-building.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Spigot-Server-Patches/0468-Async-command-map-building.patch diff --git a/Spigot-Server-Patches/0468-Async-command-map-building.patch b/Spigot-Server-Patches/0468-Async-command-map-building.patch new file mode 100644 index 0000000000..4698acfb47 --- /dev/null +++ b/Spigot-Server-Patches/0468-Async-command-map-building.patch @@ -0,0 +1,43 @@ +From cfe71cd50f913752bbd30d929ebdbe357d56e662 Mon Sep 17 00:00:00 2001 +From: Callahan +Date: Wed, 8 Apr 2020 02:42:14 -0500 +Subject: [PATCH] Async command map building + + +diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java +index 37b1a7947..2414b0a55 100644 +--- a/src/main/java/net/minecraft/server/CommandDispatcher.java ++++ b/src/main/java/net/minecraft/server/CommandDispatcher.java +@@ -241,6 +241,14 @@ public class CommandDispatcher { + if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot + // CraftBukkit start + // Register Vanilla commands into builtRoot as before ++ // Paper start - Async command map building ++ java.util.concurrent.ForkJoinPool.commonPool().execute(() -> { ++ sendAsync(entityplayer); ++ }); ++ } ++ ++ private void sendAsync(EntityPlayer entityplayer) { ++ // Paper end - Async command map building + Map, CommandNode> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues + RootCommandNode vanillaRoot = new RootCommandNode(); + +@@ -258,7 +266,14 @@ public class CommandDispatcher { + for (CommandNode node : rootcommandnode.getChildren()) { + bukkit.add(node.getName()); + } ++ // Paper start - Async command map building ++ MinecraftServer.getServer().execute(() -> { ++ runSync(entityplayer, bukkit, rootcommandnode); ++ }); ++ } + ++ private void runSync(EntityPlayer entityplayer, Collection bukkit, RootCommandNode rootcommandnode) { ++ // Paper end - Async command map building + PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit)); + event.getPlayer().getServer().getPluginManager().callEvent(event); + +-- +2.25.1 +