3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0297-Async-command-map-building.patch

47 Zeilen
2.3 KiB
Diff

2021-06-11 14:02:28 +02: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-07-27 21:49:24 +02:00
index 2bf67468a6c745bc6243c65210477ba129bfcb07..685e04b1f17938d49cd126bcfe2f488f21afbea2 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
2022-07-27 21:49:24 +02:00
@@ -34,6 +34,7 @@ import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
2021-06-11 14:02:28 +02:00
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-07-27 21:49:24 +02:00
@@ -360,6 +361,12 @@ public class Commands {
2021-06-11 14:02:28 +02:00
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
+ // Paper start - Async command map building
+ net.minecraft.server.MCUtil.scheduleAsyncTask(() -> this.sendAsync(player));
2021-06-11 14:02:28 +02:00
+ }
+
+ private void sendAsync(ServerPlayer player) {
2021-06-11 14:02:28 +02: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-07-27 21:49:24 +02:00
@@ -377,7 +384,14 @@ public class Commands {
2021-06-11 14:02:28 +02:00
for (CommandNode node : rootcommandnode.getChildren()) {
bukkit.add(node.getName());
}
+ // Paper start - Async command map building
+ MinecraftServer.getServer().execute(() -> {
+ runSync(player, bukkit, rootcommandnode);
2021-06-11 14:02:28 +02:00
+ });
+ }
+ private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
2021-06-11 14:02:28 +02:00
+ // Paper end - Async command map building
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
2021-06-11 14:02:28 +02:00
event.getPlayer().getServer().getPluginManager().callEvent(event);