Paper/Spigot-Server-Patches/0264-Use-a-Queue-for-Queueing-Commands.patch

34 lines
1.9 KiB
Diff
Raw Normal View History

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/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 750b1dc10ffb7adb9194e6cc8ace8fa92a5f0dec..bec26885108442c8e22cdddf5e764ecab6994dca 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -36,7 +36,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
private static final Logger LOGGER = LogManager.getLogger();
2020-06-25 16:09:55 +02:00
private static final Pattern k = Pattern.compile("^[a-fA-F0-9]{40}$");
- private final List<ServerCommand> serverCommandQueue = Collections.synchronizedList(Lists.newArrayList());
2020-06-25 16:09:55 +02:00
+ private final java.util.Queue<ServerCommand> serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - use a proper queue
private RemoteStatusListener remoteStatusListener;
2019-05-05 04:23:25 +02:00
public final RemoteControlCommandListener remoteControlCommandListener;
private RemoteControlListener remoteControlListener;
@@ -395,8 +395,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
public void handleCommandQueue() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
- while (!this.serverCommandQueue.isEmpty()) {
- ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
+ // Paper start - use proper queue
+ ServerCommand servercommand;
+ while ((servercommand = this.serverCommandQueue.poll()) != null) {
+ // Paper end
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);