mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 04:25:26 +01:00
[ci skip] Cleanup diff in Async command map building (#6492)
This commit is contained in:
parent
0a6d320410
commit
0205b902c2
@ -5,7 +5,7 @@ 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
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..81146c07dad098a88d8bd3867d0aaf5c15e33961 100644
|
index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..07c4d909324c8aad3a8c5d27811e2c28fe7a91f3 100644
|
||||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
@@ -29,6 +29,7 @@ import net.minecraft.network.chat.MutableComponent;
|
@@ -29,6 +29,7 @@ import net.minecraft.network.chat.MutableComponent;
|
||||||
@ -16,7 +16,7 @@ index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..81146c07dad098a88d8bd3867d0aaf5c
|
|||||||
import net.minecraft.server.commands.AdvancementCommands;
|
import net.minecraft.server.commands.AdvancementCommands;
|
||||||
import net.minecraft.server.commands.AttributeCommand;
|
import net.minecraft.server.commands.AttributeCommand;
|
||||||
import net.minecraft.server.commands.BanIpCommands;
|
import net.minecraft.server.commands.BanIpCommands;
|
||||||
@@ -335,25 +336,40 @@ public class Commands {
|
@@ -335,6 +336,14 @@ public class Commands {
|
||||||
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
// Register Vanilla commands into builtRoot as before
|
// Register Vanilla commands into builtRoot as before
|
||||||
@ -26,47 +26,23 @@ index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..81146c07dad098a88d8bd3867d0aaf5c
|
|||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private void sendAsync(ServerPlayer entityplayer) {
|
+ private void sendAsync(ServerPlayer player) {
|
||||||
+ // Paper end - Async command map building
|
+ // Paper end - Async command map building
|
||||||
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
||||||
RootCommandNode vanillaRoot = new RootCommandNode();
|
RootCommandNode vanillaRoot = new RootCommandNode();
|
||||||
|
|
||||||
- RootCommandNode<CommandSourceStack> vanilla = player.server.vanillaCommandDispatcher.getDispatcher().getRoot();
|
@@ -352,7 +361,14 @@ public class Commands {
|
||||||
+ RootCommandNode<CommandSourceStack> vanilla = entityplayer.server.vanillaCommandDispatcher.getDispatcher().getRoot();
|
|
||||||
map.put(vanilla, vanillaRoot);
|
|
||||||
- this.fillUsableCommands(vanilla, vanillaRoot, player.createCommandSourceStack(), (Map) map);
|
|
||||||
+ this.fillUsableCommands(vanilla, vanillaRoot, entityplayer.createCommandSourceStack(), (Map) map);
|
|
||||||
|
|
||||||
// Now build the global commands in a second pass
|
|
||||||
RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode();
|
|
||||||
|
|
||||||
map.put(this.dispatcher.getRoot(), rootcommandnode);
|
|
||||||
- this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, player.createCommandSourceStack(), (Map) map);
|
|
||||||
+ this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, entityplayer.createCommandSourceStack(), (Map) map);
|
|
||||||
|
|
||||||
Collection<String> bukkit = new LinkedHashSet<>();
|
|
||||||
for (CommandNode node : rootcommandnode.getChildren()) {
|
for (CommandNode node : rootcommandnode.getChildren()) {
|
||||||
bukkit.add(node.getName());
|
bukkit.add(node.getName());
|
||||||
}
|
}
|
||||||
+ // Paper start - Async command map building
|
+ // Paper start - Async command map building
|
||||||
+ MinecraftServer.getServer().execute(() -> {
|
+ MinecraftServer.getServer().execute(() -> {
|
||||||
+ runSync(entityplayer, bukkit, rootcommandnode);
|
+ runSync(player, bukkit, rootcommandnode);
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
- PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
+ private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
||||||
+ private void runSync(ServerPlayer entityplayer, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
|
||||||
+ // Paper end - Async command map building
|
+ // Paper end - Async command map building
|
||||||
+ PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
||||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
// Remove labels that were removed during the event
|
|
||||||
@@ -363,7 +379,7 @@ public class Commands {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
- player.connection.send(new ClientboundCommandsPacket(rootcommandnode));
|
|
||||||
+ entityplayer.connection.send(new ClientboundCommandsPacket(rootcommandnode));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillUsableCommands(CommandNode<CommandSourceStack> tree, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) {
|
|
||||||
|
@ -61,23 +61,23 @@ index 880fc9fea286384d002518137972935fdf1d2d72..a59d14e61fcbca7861a5593d0717b812
|
|||||||
public boolean hasPermission(int level) {
|
public boolean hasPermission(int level) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
index 81146c07dad098a88d8bd3867d0aaf5c15e33961..f9b37c873b6b02f14bb7a7225197c552a7f7c5b9 100644
|
index 07c4d909324c8aad3a8c5d27811e2c28fe7a91f3..96a33f63024c1f72ab018e15904505832430002c 100644
|
||||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
@@ -362,6 +362,7 @@ public class Commands {
|
@@ -362,6 +362,7 @@ public class Commands {
|
||||||
bukkit.add(node.getName());
|
bukkit.add(node.getName());
|
||||||
}
|
}
|
||||||
// Paper start - Async command map building
|
// Paper start - Async command map building
|
||||||
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
|
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
|
||||||
MinecraftServer.getServer().execute(() -> {
|
MinecraftServer.getServer().execute(() -> {
|
||||||
runSync(entityplayer, bukkit, rootcommandnode);
|
runSync(player, bukkit, rootcommandnode);
|
||||||
});
|
});
|
||||||
@@ -369,6 +370,7 @@ public class Commands {
|
@@ -369,6 +370,7 @@ public class Commands {
|
||||||
|
|
||||||
private void runSync(ServerPlayer entityplayer, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
||||||
// Paper end - Async command map building
|
// Paper end - Async command map building
|
||||||
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
|
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
|
||||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
||||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
Loading…
Reference in New Issue
Block a user