aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0246-Use-a-Queue-for-Queueing-Commands.patch
blob: 742b00ee96b8e320ab86f5c32f724a154240c052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 39a24292f215920bc3121f4ac903040dd73a9978..4357d5c7c66d9490a34f2d591ddc3d58d36cadd1 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -78,7 +78,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
     private static final int CONVERSION_RETRY_DELAY_MS = 5000;
     private static final int CONVERSION_RETRIES = 2;
     private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$");
-    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 RconConsoleSource rconConsoleSource;
@@ -456,13 +456,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
     }
 
     public void handleConsoleInput(String command, CommandSourceStack commandSource) {
-        this.consoleInput.add(new ConsoleInput(command, commandSource));
+        this.serverCommandQueue.add(new ConsoleInput(command, commandSource));
     }
 
     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);