mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
48 lines
2.4 KiB
Diff
48 lines
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <Blake.Galbreath@Gmail.com>
|
|
Date: Tue, 18 Jan 2022 06:35:54 -0600
|
|
Subject: [PATCH] Max joins per second
|
|
|
|
When this option is set to true the `max-joins-per-tick` setting in paper.yml will be used per second instead of per tick
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
|
index 6967c90c50ea75fb9dd5da808b2c8c8ea046ecec..e1563410e0711de5cf9363978125e637929392da 100644
|
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
|
@@ -554,11 +554,20 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper
|
|
private static int joinAttemptsThisTick; // Paper
|
|
private static int currTick; // Paper
|
|
+ private static int tickSecond; // Purpur
|
|
public void tick() {
|
|
this.flushQueue();
|
|
// Paper start
|
|
if (currTick != net.minecraft.server.MinecraftServer.currentTick) {
|
|
currTick = net.minecraft.server.MinecraftServer.currentTick;
|
|
+ // Purpur start
|
|
+ if (org.purpurmc.purpur.PurpurConfig.maxJoinsPerSecond) {
|
|
+ if (++tickSecond > 20) {
|
|
+ tickSecond = 0;
|
|
+ joinAttemptsThisTick = 0;
|
|
+ }
|
|
+ } else
|
|
+ // Purpur end
|
|
joinAttemptsThisTick = 0;
|
|
}
|
|
// Paper end
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
index 668066e2298eed6de118ff059ea469fa240e9ba9..48cdfb5e6b63bdcaeebeef87a25e3331d45a62cc 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
@@ -469,8 +469,10 @@ public class PurpurConfig {
|
|
}
|
|
|
|
public static boolean useUPnP = false;
|
|
+ public static boolean maxJoinsPerSecond = false;
|
|
private static void networkSettings() {
|
|
useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP);
|
|
+ maxJoinsPerSecond = getBoolean("settings.network.max-joins-per-second", maxJoinsPerSecond);
|
|
}
|
|
|
|
public static java.util.regex.Pattern usernameValidCharactersPattern;
|