Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit f551cb4

Browse files
BillyGalbreathgranny
authored andcommitted
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
1 parent eb5eda7 commit f551cb4

3 files changed

Lines changed: 25 additions & 47 deletions

File tree

patches/server/0228-Max-joins-per-second.patch

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- a/net/minecraft/network/Connection.java
2+
+++ b/net/minecraft/network/Connection.java
3+
@@ -588,11 +_,20 @@
4+
private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world
5+
private static int joinAttemptsThisTick; // Paper - Buffer joins to world
6+
private static int currTick; // Paper - Buffer joins to world
7+
+ private static int tickSecond; // Purpur - Max joins per second
8+
public void tick() {
9+
this.flushQueue();
10+
// Paper start - Buffer joins to world
11+
if (Connection.currTick != net.minecraft.server.MinecraftServer.currentTick) {
12+
Connection.currTick = net.minecraft.server.MinecraftServer.currentTick;
13+
+ // Purpur start - Max joins per second
14+
+ if (org.purpurmc.purpur.PurpurConfig.maxJoinsPerSecond) {
15+
+ if (++Connection.tickSecond > 20) {
16+
+ Connection.tickSecond = 0;
17+
+ Connection.joinAttemptsThisTick = 0;
18+
+ }
19+
+ } else
20+
+ // Purpur end - Max joins per second
21+
Connection.joinAttemptsThisTick = 0;
22+
}
23+
// Paper end - Buffer joins to world

purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,10 @@ private static void tpsCatchup() {
450450
}
451451

452452
public static boolean useUPnP = false;
453+
public static boolean maxJoinsPerSecond = false;
453454
private static void networkSettings() {
454455
useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP);
456+
maxJoinsPerSecond = getBoolean("settings.network.max-joins-per-second", maxJoinsPerSecond);
455457
}
456458

457459
public static Pattern usernameValidCharactersPattern;

0 commit comments

Comments
 (0)