Folia/patches/server/0004-Max-pending-logins.patch
Spottedleaf fd838ffbee Update to latest paper
Fix two regionizer issues:

In ThreadedRegionizer#addChunk, fix the incorrect handling
of merging two regions where one of the regions had
pending merges. If the first region had pending merges,
and the second was marked as "ready" then the merge would
cause a "ready" region to have pending merges. The fix is
to simply downgrade the "ready" region to "transient,"
as was previously done if the merge was delayed in the
case where the first region was "ticking."

Additionally, prevent the creation of empty regions
by checking if any new sections were created. This would
happen when a section existed, but had no marked chunks
in it AND all of the sections neighbours existed. In these
cases, no region needs to be created as no sections were
created.
2023-06-09 23:44:24 -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 fc58f714b069453b5f6d2f0ca801fbe1beef07aa..7dc9114a994ff265eb66d99c4f15be197b327e55 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -180,6 +180,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);
}