Paper/patches/server/0238-Use-a-Queue-for-Queueing-Commands.patch
Noah van der Aa b8edb0e130
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9648)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
6b34da8f SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender

CraftBukkit Changes:
db4ba2897 SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender
4f7ff4dec PR-1246: Add missing AbstractTestingBase to tests which need them
f70a7b68d SPIGOT-7465, MC-264979: Fresh installations print NoSuchFileException for server.properties
8ef7afef6 PR-1240: Call BlockGrowEvent for vines that are growing on additional sides of an existing vine block

Spigot Changes:
d2eba2c8 Rebuild patches
2023-08-28 13:05:48 +02:00

40 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 12 Aug 2018 02:33:39 -0400
Subject: [PATCH] Use a Queue for Queueing Commands
Lists are bad as Queues mmmkay.
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 7533dc44c782b4e31b3823458998bc72739e94b2..ea0d1faa0e27cd7a1b793ad93ba2ef1e6bf71628 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -69,7 +69,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
static final Logger LOGGER = LogUtils.getLogger();
private static final int CONVERSION_RETRY_DELAY_MS = 5000;
private static final int CONVERSION_RETRIES = 2;
- private final List<ConsoleInput> consoleInput = Collections.synchronizedList(Lists.newArrayList());
+ private final java.util.Queue<ConsoleInput> serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - use a proper queuemmands
@Nullable
private QueryThreadGs4 queryThreadGs4;
// public final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
@@ -439,13 +439,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
return;
}
// Paper end - rewrite chunk system
- this.consoleInput.add(new ConsoleInput(command, commandSource));
+ this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - use proper queue
}
public void handleConsoleInputs() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
- while (!this.consoleInput.isEmpty()) {
- ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
+ // Paper start - use proper queue
+ ConsoleInput servercommand;
+ while ((servercommand = this.serverCommandQueue.poll()) != null) {
+ // Paper end
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);