mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 19:07:40 +01:00
Add back discard policy
This commit is contained in:
parent
47f2071350
commit
9039c3923c
@ -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 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684eb89a44f9 100644
|
||||
index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..6212d94503023f7bb5ca21785cbb69babe4421c3 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -455,6 +455,21 @@ public class Commands {
|
||||
@@ -455,6 +455,25 @@ public class Commands {
|
||||
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
||||
// CraftBukkit start
|
||||
// Register Vanilla commands into builtRoot as before
|
||||
@ -22,11 +22,15 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e
|
||||
+ COMMAND_SENDING_POOL.execute(() -> this.sendAsync(player, commandNodes));
|
||||
+ }
|
||||
+
|
||||
+ public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = java.util.concurrent.Executors.newFixedThreadPool(2,
|
||||
+ // Fixed pool, but with discard policy
|
||||
+ public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = new java.util.concurrent.ThreadPoolExecutor(
|
||||
+ 2, 2, 0, java.util.concurrent.TimeUnit.MILLISECONDS,
|
||||
+ new java.util.concurrent.LinkedBlockingQueue<>(),
|
||||
+ 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, Collection<CommandNode<CommandSourceStack>> dispatcherRootChildren) {
|
||||
@ -34,7 +38,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e
|
||||
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
||||
RootCommandNode vanillaRoot = new RootCommandNode();
|
||||
|
||||
@@ -466,13 +481,20 @@ public class Commands {
|
||||
@@ -466,13 +485,20 @@ public class Commands {
|
||||
RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode();
|
||||
|
||||
map.put(this.dispatcher.getRoot(), rootcommandnode);
|
||||
@ -56,7 +60,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e
|
||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@@ -486,8 +508,10 @@ public class Commands {
|
||||
@@ -486,8 +512,10 @@ public class Commands {
|
||||
player.connection.send(new ClientboundCommandsPacket(rootcommandnode));
|
||||
}
|
||||
|
||||
@ -69,7 +73,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
|
||||
@@ -522,7 +546,7 @@ public class Commands {
|
||||
@@ -522,7 +550,7 @@ public class Commands {
|
||||
resultNodes.put(commandnode2, commandnode3);
|
||||
result.addChild(commandnode3);
|
||||
if (!commandnode2.getChildren().isEmpty()) {
|
||||
|
@ -87,10 +87,10 @@ index 4d5f1dd1c3bd742b1bc5e3914101a699041caa7e..5316f148f3f9128690f019d544e462b0
|
||||
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 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523368c0507 100644
|
||||
index 6212d94503023f7bb5ca21785cbb69babe4421c3..642d5c6849debc5a266605b0df30d55222339438 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -488,6 +488,7 @@ public class Commands {
|
||||
@@ -492,6 +492,7 @@ public class Commands {
|
||||
bukkit.add(node.getName());
|
||||
}
|
||||
// Paper start - Perf: Async command map building
|
||||
@ -98,7 +98,7 @@ index 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523
|
||||
net.minecraft.server.MinecraftServer.getServer().execute(() -> {
|
||||
runSync(player, bukkit, rootcommandnode);
|
||||
});
|
||||
@@ -495,6 +496,7 @@ public class Commands {
|
||||
@@ -499,6 +500,7 @@ public class Commands {
|
||||
|
||||
private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
||||
// Paper end - Perf: Async command map building
|
||||
@ -106,7 +106,7 @@ index 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523
|
||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@@ -515,6 +517,11 @@ public class Commands {
|
||||
@@ -519,6 +521,11 @@ public class Commands {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
|
||||
|
@ -2068,7 +2068,7 @@ index fc0c60b22844ed010aede2fa125b9fa440d3de80..3549ffea451b932602efb113844ba21a
|
||||
public org.bukkit.command.CommandSender getBukkitSender() {
|
||||
return this.source.getBukkitSender(this);
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187bcc898a5f 100644
|
||||
index cfa328f06c1b972c8328ff40580b485c02e0c270..62704cbfe3a232809b3e62d1f1d8beb3bea6496e 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -159,7 +159,7 @@ public class Commands {
|
||||
@ -2135,7 +2135,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b
|
||||
StackTraceElement[] astacktraceelement = exception.getStackTrace();
|
||||
|
||||
for (int i = 0; i < Math.min(astacktraceelement.length, 3); ++i) {
|
||||
@@ -475,13 +494,7 @@ public class Commands {
|
||||
@@ -479,13 +498,7 @@ public class Commands {
|
||||
private void sendAsync(ServerPlayer player, Collection<CommandNode<CommandSourceStack>> dispatcherRootChildren) {
|
||||
// Paper end - Perf: Async command map building
|
||||
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
||||
@ -2150,7 +2150,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b
|
||||
RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode();
|
||||
|
||||
map.put(this.dispatcher.getRoot(), rootcommandnode);
|
||||
@@ -516,6 +529,7 @@ public class Commands {
|
||||
@@ -520,6 +533,7 @@ public class Commands {
|
||||
|
||||
// Paper start - Perf: Async command map building; pass copy of children
|
||||
private void fillUsableCommands(Collection<CommandNode<CommandSourceStack>> children, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) {
|
||||
@ -2158,7 +2158,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b
|
||||
Iterator iterator = children.iterator();
|
||||
// Paper end - Perf: Async command map building
|
||||
|
||||
@@ -530,6 +544,42 @@ public class Commands {
|
||||
@@ -534,6 +548,42 @@ public class Commands {
|
||||
|
||||
if (commandnode2.canUse(source)) {
|
||||
ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
|
||||
|
@ -37,10 +37,10 @@ index 3549ffea451b932602efb113844ba21a7bc72371..13bd145b1e8006a53c22f5dc0c78f29b
|
||||
+ // Paper end - tell clients to ask server for suggestions for EntityArguments
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index 622677fb281242681bf8ba39de34187bcc898a5f..daca005854ae2bb68300b19bceedadcbbe1e06fd 100644
|
||||
index 62704cbfe3a232809b3e62d1f1d8beb3bea6496e..2daf16ae4a30fe03bc1a1bbc3eb95b3b7bcd83fa 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -533,6 +533,7 @@ public class Commands {
|
||||
@@ -537,6 +537,7 @@ public class Commands {
|
||||
Iterator iterator = children.iterator();
|
||||
// Paper end - Perf: Async command map building
|
||||
|
||||
@ -48,7 +48,7 @@ index 622677fb281242681bf8ba39de34187bcc898a5f..daca005854ae2bb68300b19bceedadcb
|
||||
while (iterator.hasNext()) {
|
||||
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
|
||||
// Paper start - Brigadier API
|
||||
@@ -595,6 +596,12 @@ public class Commands {
|
||||
@@ -599,6 +600,12 @@ public class Commands {
|
||||
|
||||
if (requiredargumentbuilder.getSuggestionsProvider() != null) {
|
||||
requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider()));
|
||||
|
Loading…
Reference in New Issue
Block a user