mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
41 lines
2.9 KiB
Diff
41 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
Date: Sat, 12 Dec 2020 23:45:28 +0000
|
|
Subject: [PATCH] Limit recipe packets
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index e3e43c361d8612dbc79fe88730a3794eb44d85e4..b61cb778196a31df2139deb31dfd924abc6e5d1c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -275,6 +275,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200);
|
|
private final TickThrottler tabSpamThrottler = new TickThrottler(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement, io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit); // Paper - configurable tab spam limits
|
|
private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480);
|
|
+ private final TickThrottler recipeSpamPackets = new TickThrottler(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement, io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit);
|
|
private double firstGoodX;
|
|
private double firstGoodY;
|
|
private double firstGoodZ;
|
|
@@ -391,6 +392,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
this.keepConnectionAlive();
|
|
this.chatSpamThrottler.tick();
|
|
this.tabSpamThrottler.tick(); // Paper - configurable tab spam limits
|
|
+ this.recipeSpamPackets.tick(); // Paper - auto recipe limit
|
|
this.dropSpamThrottler.tick();
|
|
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
|
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
|
@@ -3083,6 +3085,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
@Override
|
|
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
|
+ // Paper start - auto recipe limit
|
|
+ if (!org.bukkit.Bukkit.isPrimaryThread()) {
|
|
+ if (!this.recipeSpamPackets.isIncrementAndUnderThreshold()) {
|
|
+ this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"));
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // Paper end - auto recipe limit
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
|
this.player.resetLastActionTime();
|
|
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
|