Fix command pool submitting on shutdown (#8272)

This commit is contained in:
Owen 2022-08-09 23:51:17 -04:00 committed by GitHub
parent e6f8284125
commit 22ad9eedec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -9,10 +9,10 @@ commands if the server is restarting. Using the default async pool caused issues
due to the shutdown logic generally being much later.
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 2bf67468a6c745bc6243c65210477ba129bfcb07..91b32a4856a4c9d6dc12871ed080f7a67311ead0 100644
index 2bf67468a6c745bc6243c65210477ba129bfcb07..c4315531f93f4ed68b4621157b02572886e1ed30 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -360,6 +360,23 @@ public class Commands {
@@ -360,6 +360,24 @@ public class Commands {
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
@ -28,7 +28,8 @@ index 2bf67468a6c745bc6243c65210477ba129bfcb07..91b32a4856a4c9d6dc12871ed080f7a6
+ new com.google.common.util.concurrent.ThreadFactoryBuilder()
+ .setNameFormat("Paper Async Command Builder Thread Pool - %1$d")
+ .setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER))
+ .build()
+ .build(),
+ new java.util.concurrent.ThreadPoolExecutor.DiscardPolicy()
+ );
+
+ private void sendAsync(ServerPlayer player) {
@ -36,7 +37,7 @@ index 2bf67468a6c745bc6243c65210477ba129bfcb07..91b32a4856a4c9d6dc12871ed080f7a6
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
RootCommandNode vanillaRoot = new RootCommandNode();
@@ -377,7 +394,14 @@ public class Commands {
@@ -377,7 +395,14 @@ public class Commands {
for (CommandNode node : rootcommandnode.getChildren()) {
bukkit.add(node.getName());
}

View File

@ -74,10 +74,10 @@ index 3308d684fc6cd0a83e190a52693b29d30e0087cb..aadddbc16aa719677c3b6fc4969b6145
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 91b32a4856a4c9d6dc12871ed080f7a67311ead0..0efb172c31a211e03d5fd922f65b6feff1317381 100644
index c4315531f93f4ed68b4621157b02572886e1ed30..b141d251eedd31bd115342b878afd68dc51a8518 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -395,6 +395,7 @@ public class Commands {
@@ -396,6 +396,7 @@ public class Commands {
bukkit.add(node.getName());
}
// Paper start - Async command map building
@ -85,7 +85,7 @@ index 91b32a4856a4c9d6dc12871ed080f7a67311ead0..0efb172c31a211e03d5fd922f65b6fef
net.minecraft.server.MinecraftServer.getServer().execute(() -> {
runSync(player, bukkit, rootcommandnode);
});
@@ -402,6 +403,7 @@ public class Commands {
@@ -403,6 +404,7 @@ public class Commands {
private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
// Paper end - Async command map building
@ -93,7 +93,7 @@ index 91b32a4856a4c9d6dc12871ed080f7a67311ead0..0efb172c31a211e03d5fd922f65b6fef
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
event.getPlayer().getServer().getPluginManager().callEvent(event);
@@ -420,6 +422,11 @@ public class Commands {
@@ -421,6 +423,11 @@ public class Commands {
while (iterator.hasNext()) {
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();

View File

@ -35,10 +35,10 @@ index 6fdbe747645eb83f31b56bca77a9d7962237aed8..dd0143f319d4adef8834c513af34b1cc
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 6d480d0332ee9348eacc3269890ee49206623c2a..584d2539d715fef26a2d01f014c7c3f4f8ce8fd9 100644
index 27093aed1f4112a5414671fd5d9c4e683011506d..67ab16743b36dbf8b4336e33988d8e78433f566d 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -432,6 +432,7 @@ public class Commands {
@@ -433,6 +433,7 @@ public class Commands {
private void fillUsableCommands(CommandNode<CommandSourceStack> tree, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) {
Iterator iterator = tree.getChildren().iterator();
@ -46,7 +46,7 @@ index 6d480d0332ee9348eacc3269890ee49206623c2a..584d2539d715fef26a2d01f014c7c3f4
while (iterator.hasNext()) {
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
// Paper start
@@ -458,6 +459,12 @@ public class Commands {
@@ -459,6 +460,12 @@ public class Commands {
if (requiredargumentbuilder.getSuggestionsProvider() != null) {
requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider()));