From 0000000000000000000000000000000000000000 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/commands/CommandDispatcher.java b/src/main/java/net/minecraft/commands/CommandDispatcher.java index ddbd4c43bbe6d6a5b90f4958c4be80520a40beab..ca33ec8da544272ecf708b0cc1b0123eabc48a8b 100644 --- a/src/main/java/net/minecraft/commands/CommandDispatcher.java +++ b/src/main/java/net/minecraft/commands/CommandDispatcher.java @@ -327,6 +327,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(); @@ -344,7 +352,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);