From 0205b902c2a33405c908ae69819cdd366d20ac21 Mon Sep 17 00:00:00 2001 From: Jason <11360596+jpenilla@users.noreply.github.com> Date: Thu, 26 Aug 2021 11:41:22 -0500 Subject: [PATCH] [ci skip] Cleanup diff in Async command map building (#6492) --- .../0403-Async-command-map-building.patch | 38 ++++--------------- .../0424-Implement-Brigadier-Mojang-API.patch | 12 +++--- ...tize-ResourceLocation-error-logging.patch} | 0 3 files changed, 13 insertions(+), 37 deletions(-) rename patches/server/{0763-Sanitize-resourcelocation-error-logging.patch => 0763-Sanitize-ResourceLocation-error-logging.patch} (100%) diff --git a/patches/server/0403-Async-command-map-building.patch b/patches/server/0403-Async-command-map-building.patch index ddce92406d..96c3da6fb3 100644 --- a/patches/server/0403-Async-command-map-building.patch +++ b/patches/server/0403-Async-command-map-building.patch @@ -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 -index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..81146c07dad098a88d8bd3867d0aaf5c15e33961 100644 +index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..07c4d909324c8aad3a8c5d27811e2c28fe7a91f3 100644 --- a/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; @@ -16,7 +16,7 @@ index 780f46c8fdbaafaca6babfa34ebd97f420d0d612..81146c07dad098a88d8bd3867d0aaf5c import net.minecraft.server.commands.AdvancementCommands; import net.minecraft.server.commands.AttributeCommand; 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 // CraftBukkit start // 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 Map, CommandNode> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues RootCommandNode vanillaRoot = new RootCommandNode(); -- RootCommandNode vanilla = player.server.vanillaCommandDispatcher.getDispatcher().getRoot(); -+ RootCommandNode 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 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 bukkit = new LinkedHashSet<>(); +@@ -352,7 +361,14 @@ public class Commands { for (CommandNode node : rootcommandnode.getChildren()) { bukkit.add(node.getName()); } + // Paper start - Async command map building + MinecraftServer.getServer().execute(() -> { -+ runSync(entityplayer, bukkit, rootcommandnode); ++ runSync(player, bukkit, rootcommandnode); + }); + } -- PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); -+ private void runSync(ServerPlayer entityplayer, Collection bukkit, RootCommandNode rootcommandnode) { ++ private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { + // 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); - // 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 tree, CommandNode result, CommandSourceStack source, Map, CommandNode> resultNodes) { diff --git a/patches/server/0424-Implement-Brigadier-Mojang-API.patch b/patches/server/0424-Implement-Brigadier-Mojang-API.patch index 0e5a87be1f..12ae4a3f2e 100644 --- a/patches/server/0424-Implement-Brigadier-Mojang-API.patch +++ b/patches/server/0424-Implement-Brigadier-Mojang-API.patch @@ -61,23 +61,23 @@ index 880fc9fea286384d002518137972935fdf1d2d72..a59d14e61fcbca7861a5593d0717b812 public boolean hasPermission(int level) { // CraftBukkit start 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 +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -362,6 +362,7 @@ public class Commands { bukkit.add(node.getName()); } // Paper start - Async command map building -+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper ++ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper MinecraftServer.getServer().execute(() -> { - runSync(entityplayer, bukkit, rootcommandnode); + runSync(player, bukkit, rootcommandnode); }); @@ -369,6 +370,7 @@ public class Commands { - private void runSync(ServerPlayer entityplayer, Collection bukkit, RootCommandNode rootcommandnode) { + private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { // Paper end - Async command map building -+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(entityplayer.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.getBukkitEntity(), new LinkedHashSet<>(bukkit)); ++ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper + PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); 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/patches/server/0763-Sanitize-resourcelocation-error-logging.patch b/patches/server/0763-Sanitize-ResourceLocation-error-logging.patch similarity index 100% rename from patches/server/0763-Sanitize-resourcelocation-error-logging.patch rename to patches/server/0763-Sanitize-ResourceLocation-error-logging.patch