3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0472-Buffer-joins-to-world.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

38 Zeilen
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 19 Aug 2020 05:05:54 +0100
Subject: [PATCH] Buffer joins to world
This patch buffers the number of logins which will attempt to join
the world per tick, this attempts to reduce the impact that join floods
has on the server
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index b8e35f493458ba9e072953dffe6b2429f1d821ec..c1a59f54f537395bebf6d78459beef3013ea67d9 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -425,8 +425,23 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
// Paper end
+ private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper
+ private static int joinAttemptsThisTick; // Paper
+ private static int currTick; // Paper
public void tick() {
this.flushQueue();
+ // Paper start
+ if (currTick != net.minecraft.server.MinecraftServer.currentTick) {
+ currTick = net.minecraft.server.MinecraftServer.currentTick;
+ joinAttemptsThisTick = 0;
+ }
+ // Paper end
+ if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl) {
+ if ( ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper
+ || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick
+ ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).tick();
+ } // Paper
+ }
PacketListener packetlistener = this.packetListener;
if (packetlistener instanceof TickablePacketListener) {