Folia/patches/server/0007-Max-pending-logins.patch
Spottedleaf c7fbdd87d2 Update to 1.19.4
Patches applied, but not yet checked compile.
2023-03-23 06:55:09 -07:00

43 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Thu, 9 Mar 2023 20:50:15 -0800
Subject: [PATCH] Max pending logins
Should help the floodgates on launch
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 48223b78dd7ea2f065a259ad071f101398f40cfd..30fae97d5fed9de036cc4131a09d404468c69dd4 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -85,7 +85,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
UUID uniqueId = UUIDUtil.getOrCreatePlayerUUID(this.gameProfile);
if (this.server.getPlayerList().pushPendingJoin(name, uniqueId, this.connection)) {
this.handleAcceptedLogin();
- }
+ } else { --this.tick; } // Folia - max concurrent logins
// Folia end - region threading - rewrite login process
} // Folia - region threading - remove delayed accept
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index e49e9cc31a9e05422fd1f48616c5a452011d66e1..132e1e055a8898beb4683dbec821b1f6e4dbf1a2 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -177,6 +177,17 @@ public abstract class PlayerList {
conflictingId = this.connectionById.get(byId);
if (conflictingName == null && conflictingId == null) {
+ // Folia start - max concurrent login
+ int loggedInCount = 0;
+ for (Connection value : this.connectionById.values()) {
+ if (value.isPlayerConnected()) {
+ ++loggedInCount;
+ }
+ }
+ if ((this.connectionById.size() - loggedInCount) >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick) {
+ return false;
+ }
+ // Folia end - max concurrent login
this.connectionByName.put(userName, conn);
this.connectionById.put(byId, conn);
}