Created
June 2, 2022 00:44
-
-
Save electronicboy/f0f06b0bcf6a16e9366d54152c5e8cbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | |
From: Shane Freeder <theboyetronic@gmail.com> | |
Date: Thu, 2 Jun 2022 01:42:43 +0100 | |
Subject: [PATCH] Configurable chat thread limit | |
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java | |
index fafbebbb5e8c1a381b673f97f1fa210687b52823..ef2292600c16adf03f8e818f73a58cca63e600e8 100644 | |
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java | |
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java | |
@@ -693,4 +693,13 @@ public class PaperConfig { | |
private static void useProxyProtocol() { | |
useProxyProtocol = getBoolean("settings.proxy-protocol", false); | |
} | |
+ | |
+ private static void chatThreads() { | |
+ int chatThreads = getInt("settings.chat-threads", -1); | |
+ if (chatThreads <= 0) { | |
+ chatThreads = 0; | |
+ } | |
+ java.util.concurrent.ThreadPoolExecutor executor = ((java.util.concurrent.ThreadPoolExecutor) net.minecraft.network.protocol.game.ServerboundChatPacket.executors); | |
+ executor.setCorePoolSize(chatThreads); | |
+ } | |
} | |
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java | |
index 21588ce5a408fed3454c317b56c05439ad3af27d..4cfefd280c1814435c2286dba35fac2c244292ed 100644 | |
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java | |
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java | |
@@ -26,7 +26,7 @@ public class ServerboundChatPacket implements Packet<ServerGamePacketListener> { | |
} | |
// Spigot Start | |
- private static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool( | |
+ public static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool( // Paper - make public | |
new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon( true ).setNameFormat( "Async Chat Thread - #%d" ).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build() ); // Paper | |
public void handle(final ServerGamePacketListener listener) { | |
if ( !this.message.startsWith("/") ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment