testserver/patches/server/0266-Configurable-connectio...

36 lines
2.7 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 2 Oct 2018 09:57:50 +0100
Subject: [PATCH] Configurable connection throttle kick message
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2022-06-03 04:26:56 +00:00
index 5def23f470c9737884bdf7551e426faf887bca9c..51dd358137d37eb078aff036ccf12db7f01c469b 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -294,6 +294,11 @@ public class PaperConfig {
2021-06-11 12:02:28 +00:00
authenticationServersDownKickMessage = Strings.emptyToNull(getString("messages.kick.authentication-servers-down", authenticationServersDownKickMessage));
}
+ public static String connectionThrottleKickMessage = "Connection throttled! Please wait before reconnecting.";
+ private static void connectionThrottleKickMessage() {
+ connectionThrottleKickMessage = getString("messages.kick.connection-throttle", connectionThrottleKickMessage);
+ }
+
private static void savePlayerData() {
Object val = config.get("settings.save-player-data");
if (val instanceof Boolean) {
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
2022-06-08 00:42:07 +00:00
index 4170bda451df3db43e7d57d87d1abb81934d7dad..941a9d8addd44e95c467b34f77658592b9f4ef06 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
2022-06-08 00:42:07 +00:00
@@ -49,7 +49,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
2021-06-13 06:48:25 +00:00
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
2022-06-08 00:42:07 +00:00
- MutableComponent chatmessage = Component.literal("Connection throttled! Please wait before reconnecting.");
+ MutableComponent chatmessage = Component.literal(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message
2021-06-11 12:02:28 +00:00
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
this.connection.disconnect(chatmessage);
return;