mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
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
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/network/Connection.java
|
||||
+++ b/net/minecraft/network/Connection.java
|
||||
@@ -588,11 +_,20 @@
|
||||
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 - Max joins per second
|
||||
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 - Max joins per second
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.maxJoinsPerSecond) {
|
||||
+ if (++Connection.tickSecond > 20) {
|
||||
+ Connection.tickSecond = 0;
|
||||
+ Connection.joinAttemptsThisTick = 0;
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end - Max joins per second
|
||||
Connection.joinAttemptsThisTick = 0;
|
||||
}
|
||||
// Paper end - Buffer joins to world
|
||||
@@ -450,8 +450,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 Pattern usernameValidCharactersPattern;
|
||||
|
||||
Reference in New Issue
Block a user