PaperMC/Spigot-Server-Patches/0291-Configurable-connection-throttle-kick-message.patch

36 lines
2.4 KiB
Diff
Raw Normal View History

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
index f1c1c9c09c6bfe288a239d53953e55bb0c113c79..20524795840a06cfe60de6ffd0a77b6814132af4 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -276,6 +276,11 @@ public class PaperConfig {
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/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 6d9080abb63a6d13d1184ff6949ba86a470ea390..471826ee4b32fe73d3c39755005e3287f9673c3c 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -35,7 +35,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
2019-05-28 01:01:45 +02:00
synchronized (throttleTracker) {
if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
throttleTracker.put(address, currentTime);
- ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
+ ChatMessage chatmessage = new ChatMessage(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message
2020-06-25 16:09:55 +02:00
this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage));
this.c.close(chatmessage);
2019-05-28 01:01:45 +02:00
return;