2021-06-11 12:02:28 +00:00
|
|
|
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/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index 7d6b416f0889221d63233f8650c530467ea8fbd7..f3bbe012541a71ab75c1863990d0c056c62d8c6e 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
|
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -31,6 +31,7 @@ import net.minecraft.network.chat.MutableComponent;
|
2021-06-11 12:02:28 +00:00
|
|
|
import net.minecraft.network.chat.TextComponent;
|
|
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
|
|
|
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
|
|
|
|
+import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.server.commands.AdvancementCommands;
|
|
|
|
import net.minecraft.server.commands.AttributeCommand;
|
|
|
|
import net.minecraft.server.commands.BanIpCommands;
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -346,6 +347,12 @@ public class Commands {
|
2021-06-11 12:02:28 +00:00
|
|
|
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
|
|
|
// CraftBukkit start
|
|
|
|
// Register Vanilla commands into builtRoot as before
|
|
|
|
+ // Paper start - Async command map building
|
2021-12-04 02:37:33 +00:00
|
|
|
+ net.minecraft.server.MCUtil.scheduleAsyncTask(() -> this.sendAsync(player));
|
2021-06-11 12:02:28 +00:00
|
|
|
+ }
|
|
|
|
+
|
2021-08-26 16:41:22 +00:00
|
|
|
+ private void sendAsync(ServerPlayer player) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper end - Async command map building
|
|
|
|
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
|
|
|
RootCommandNode vanillaRoot = new RootCommandNode();
|
|
|
|
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -363,7 +370,14 @@ public class Commands {
|
2021-06-11 12:02:28 +00:00
|
|
|
for (CommandNode node : rootcommandnode.getChildren()) {
|
|
|
|
bukkit.add(node.getName());
|
|
|
|
}
|
|
|
|
+ // Paper start - Async command map building
|
|
|
|
+ MinecraftServer.getServer().execute(() -> {
|
2021-08-26 16:41:22 +00:00
|
|
|
+ runSync(player, bukkit, rootcommandnode);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
2021-08-26 16:41:22 +00:00
|
|
|
+ private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper end - Async command map building
|
2021-08-26 16:41:22 +00:00
|
|
|
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
2021-06-11 12:02:28 +00:00
|
|
|
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
|
|
|
|