mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
48 lines
2.5 KiB
Diff
48 lines
2.5 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/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
|
index 3c866432c8a938c677a315612f3e159bda67a2a2..8661c1b1cfe2b3db000e1f08814fd4409c4b7fab 100644
|
|
--- a/net/minecraft/network/Connection.java
|
|
+++ b/net/minecraft/network/Connection.java
|
|
@@ -617,11 +617,20 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world
|
|
private static int joinAttemptsThisTick; // Paper - Buffer joins to world
|
|
private static int currTick; // Paper - Buffer joins to world
|
|
+ private static int tickSecond; // Purpur
|
|
public void tick() {
|
|
this.flushQueue();
|
|
// Paper start - Buffer joins to world
|
|
if (Connection.currTick != net.minecraft.server.MinecraftServer.currentTick) {
|
|
Connection.currTick = net.minecraft.server.MinecraftServer.currentTick;
|
|
+ // Purpur start
|
|
+ if (org.purpurmc.purpur.PurpurConfig.maxJoinsPerSecond) {
|
|
+ if (++Connection.tickSecond > 20) {
|
|
+ Connection.tickSecond = 0;
|
|
+ Connection.joinAttemptsThisTick = 0;
|
|
+ }
|
|
+ } else
|
|
+ // Purpur end
|
|
Connection.joinAttemptsThisTick = 0;
|
|
}
|
|
// Paper end - Buffer joins to world
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
index 60bb703fdf582bc3ec1081f31818d696e3b276ed..222d1850a9c0c6907dc9de534cff64c122a0bb89 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
@@ -457,8 +457,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;
|