Folia/patches/server/0007-Max-pending-logins.patch
Spottedleaf d113346b6d Fix isTickThread(world, blockX, blockZ)
Need to convert the Z to chunk, not block...

Also throw for CraftPlayer#teleport and friends
2023-03-27 20:29:16 -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 2e96377d628b3a07fb565020074d665f594f32e8..75b1877f8c3e4da3183437f327ef3376fd0a3c21 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 0bdd6f4bea2b3fa7fef2c0a739af37f9c21ff5cd..44c6ff04b7310f3b59a7fa4c600e3221cbec7bb8 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);
}