mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Async command map building
Reduces lag created on login and world change for sending the command map to client
This commit is contained in:
parent
1e3eae5e0f
commit
6dd459625e
1 changed files with 41 additions and 0 deletions
41
Spigot-Server-Patches/Async-command-map-building.patch
Normal file
41
Spigot-Server-Patches/Async-command-map-building.patch
Normal file
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Callahan <mr.callahhh@gmail.com>
|
||||
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
|
||||
@@ -0,0 +0,0 @@ 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<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
||||
RootCommandNode vanillaRoot = new RootCommandNode();
|
||||
|
||||
@@ -0,0 +0,0 @@ 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<String> bukkit, RootCommandNode<ICompletionProvider> rootcommandnode) {
|
||||
+ // Paper end - Async command map building
|
||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
--
|
Loading…
Reference in a new issue