2021-06-11 12:02:28 +00:00
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
2024-01-23 14:43:48 +00:00
index 6025b3ce5a4aee45061dfb72a089deff889fe823..a7d7c676f1ab8c47395b91aea028f143837b8801 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
2022-12-07 19:22:28 +00:00
@@ -69,7 +69,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
2022-06-07 21:45:11 +00:00
static final Logger LOGGER = LogUtils.getLogger();
2021-06-12 23:45:00 +00:00
private static final int CONVERSION_RETRY_DELAY_MS = 5000;
private static final int CONVERSION_RETRIES = 2;
2021-06-11 12:02:28 +00:00
- private final List<ConsoleInput> consoleInput = Collections.synchronizedList(Lists.newArrayList());
2024-01-21 16:39:05 +00:00
+ private final java.util.Queue<ConsoleInput> serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - Perf: use a proper queue
2021-11-23 15:04:41 +00:00
@Nullable
2021-06-11 12:02:28 +00:00
private QueryThreadGs4 queryThreadGs4;
2023-09-21 22:01:00 +00:00
// private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
2023-09-22 20:13:57 +00:00
@@ -439,13 +439,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
return;
}
// Paper end - rewrite chunk system
2021-06-11 12:02:28 +00:00
- this.consoleInput.add(new ConsoleInput(command, commandSource));
2024-01-21 16:39:05 +00:00
+ this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - Perf: use proper queue
2021-06-11 12:02:28 +00:00
}
public void handleConsoleInputs() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
- while (!this.consoleInput.isEmpty()) {
- ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
2024-01-21 16:39:05 +00:00
+ // Paper start - Perf: use proper queue
2021-06-11 12:02:28 +00:00
+ ConsoleInput servercommand;
+ while ((servercommand = this.serverCommandQueue.poll()) != null) {
2024-01-21 16:39:05 +00:00
+ // Paper end - Perf: use proper queue
2021-06-11 12:02:28 +00:00
// CraftBukkit start - ServerCommand for preprocessing
2023-10-26 23:34:58 +00:00
ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.msg);